All Collections
Integrations & APIs
Download Cargosnap files into Excel
Download Cargosnap files into Excel

Every use case is different. Cargosnap stores it all, but wouldn't it be awesome if you could have all data in your beloved Excel?

Updated over a week ago

A couple of warnings first:

  • This article is aimed at developers and office tigers; it is technical and demonstrates tools and techniques that are not commonly seen by business users.

  • Cargosnap uses tools such as Excel, Power Query and Power Automate in these examples. These are Microsoft solutions and not part of the product offering of CargoSnap. We do not provide, sell or support these tools! We just think they are awesome to achieve business goals, but you may choose a competing product or use the described functionality in your own WMS/TMS.

  • Our API's are useful to pull the data you need. Kindly use them with common sense: we have a fair use policy (but also some hard limits, to protect the use for all our customers). What that means is, do not call the API more than you need and avoid repeating calls. Use our documented methods to pull only incremental data.

TIP! Keep the CargoSnap API documentation handy.

Getting your data into Excel, from the API

Want to get your Cargosnap data into Excel (or PowerBI and similar)? Check out this video explainer:

Annex: Pagination

In order to handle Pagination in Power Query, the following snippets will help:

For the endpoint /forms:

let
Source = List.Skip(List.Generate( () => [Counter = 0, isMore = true],
each [isMore] <> false,
each [WebCall = Json.Document(
Function.InvokeAfter(() => Web.Contents( "https://api.cargosnap.com/api/v2/forms/[my-form-id]?"
& "token=[my-API-token]"
& "&limit=250"
& "&startdate=2023-01-01"
& "&enddate=2023-12-31"
& "&page=" & Number.ToText(Counter)), #duration(0,0,0,1))
),
isMore = if [Counter] < 1 then null else
if [WebCall][current_page] = [WebCall][last_page] then false else true,
Counter = [Counter] + 1
]
), 1),
#"Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
Source

For the endpoint /files:

let 
Source = List.Skip(List.Generate( () => [Counter = 0, isMore = true],

each [isMore] <> false,
each [WebCall = Json.Document(Function.InvokeAfter(() => Web.Contents( "https://api.cargosnap.com/api/v2/files?"
& "token=[my-API-token]"
& "&limit=250"
& "&startdate=2023-01-01"
& "&enddate=2023-12-31"
& "&page=" & Number.ToText(Counter)), #duration(0,0,0,1))),
isMore = if [Counter] < 1 then null else
if [WebCall][current_page] = [WebCall][last_page] then false else true,
Counter = [Counter] + 1
]
), 1),
#"Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
Source

Did this answer your question?