Hi, How would I go about finding the total shipping label cost for a given date?
I saw querying using shipment_id would give me shipping_labels {cost} - but what’s the simplest way to get the cost using date or order IDs?
Thank you!
Hello @Raj!
There is no single query that replies with the total for a day, but as you stated, you can do it by polling all shipments for a given date and adding the label cost inside each one. Your query should look something like this:
query{
shipments(date_from: ISODateTime, date_to: ISODateTime){
request_id
complexity
data(after: string, first: int){
edges{
node{
shipping_labels{
cost
}
}
}
pageInfo{
endCursor
hasNextPage
}
}
}
}
ISODateTime can be:
- YYYY-mm-dd
- YYYY-mm-dd HH:MM:SS
- YYYY-mm-ddTHH:MM:SS
You can use pageInfo
, first
, and after
to paginate the responses.
If you want to get the label cost for orders, you can do as follows but only a single order at a time:
query{
shipments(order_id: string){
request_id
complexity
data(after: string, first: int){
edges{
node{
shipping_labels{
cost
}
}
}
pageInfo{
endCursor
hasNextPage
}
}
}
}
Please let me know if this doesn’t help.
Kind regards,
Tomas
2 Likes
Thank you so much Tomas for the two options! I think I’ll try first one and see if that works for me - that will hit the SH servers much lesser times.
Much appreciated
2 Likes