Hi, I saw this code below from another post, but can you please provide the rest of an example query for getting all shipments from a certain date to a certain date? Thanks
query {
shipments(date_from: “2019-10-01”, date_to: “2019-10-03”) {
…
Hi, I saw this code below from another post, but can you please provide the rest of an example query for getting all shipments from a certain date to a certain date? Thanks
query {
shipments(date_from: “2019-10-01”, date_to: “2019-10-03”) {
…
Hi @Orion!
Would a Query like this one work for you?:
query {
shipments(date_from: "2019-01-01", date_to: "2019-01-02") {
request_id
complexity
data(first: 10) {
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
edges {
node {
id
legacy_id
order_id
user_id
warehouse_id
pending_shipment_id
address {
name
address1
address2
city
state
country
zip
phone
}
picked_up
needs_refund
refunded
delivered
shipped_off_shiphero
dropshipment
created_date
line_items {
edges {
node {
id
legacy_id
line_item_id
shipment_id
shipping_label_id
quantity
}
}
}
shipping_labels {
id
legacy_id
account_id
shipment_id
order_id
box_id
status
tracking_number
order_number
carrier
shipping_name
shipping_method
cost
box_code
address {
name
address1
address2
city
state
country
zip
phone
}
device_id
delivered
picked_up
refunded
needs_refund
profile
partner_fulfillment_id
full_size_to_print
packing_slip
warehouse
insurance_amount
carrier_account_id
}
}
cursor
}
}
}
}
Let me know if that is not what you were looking for.
Thanks!
Tom
Hi Tomas,
The query works great! Thank you. Just to verify, when you have data(first: 10), is that only going to return the first 10 shipments, or is it first 10 pages of shipments, and if so how many per page? If it just returns the first 10 shipments, that uses the full 1001 credits so how do you recommend making this work if you are looking to return 155 shipments (say if you query shipments since a week ago? Thanks for the help.
Hi @Orion
The first filter means that it will return you the first 10 shipments that meet that filter.
You can also use sort if, for example, you want to sort by date or shipment id
On the other hand, the maximum amount it will return is 100
If you need to Query for many/shipments you might:
You can play with any of these combinations that work best for you.
In the case of nr 1 you can filter like this:
query {
shipments(date_from: "2019-01-01T20:47:58", date_to: "2019-01-01T20:48:58") {
request_id
complexity
data(first: 10) {
As for alternative nr 2 you will need to also include the pagination info on your query, something like:
query {
shipments(date_from: "2019-01-01", date_to: "2019-01-01") {
request_id
complexity
data(first: 10) {
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
edges {
node {
So for the first 100 you will get something like:
"endCursor": "YXJyYXljb25uZWN0aW9uOjk="
So your next Query should contain:
data(first: 10 after:"YXJyYXljb25uZWN0aW9uOjk=")
Which means it will start from the last shipment you got last time.
Let me know if this sounds confusing and I’ll try to explain better.
Thanks again!
Tom
Thanks Tomas, this is working well and I am setting a 7 second delay between API calls to regenerate credits. One more question though, this query just returns ids for line items, whereas the legacy query returns the SKU as well. How do we get the SKUs for these line items returned by the shipment query?
Hi @Orion!
I’m glad it helped.
You can get the sku using the line_item field inside the line_items connection, which looks like:
line_items {
edges {
node {
id
legacy_id
line_item_id
shipment_id
shipping_label_id
quantity
line_item{
sku
}
}
}
}
Let me know if you need the entire query or with this section is OK.
Thanks again!
Tom
Hey Tomas,
Thanks for the quick reply! This should be enough, it’s good we don’t have to enter another query to find sku by item id. Thanks!
One more quick question for shipments, is there a “weight” field that graphQL can return for package weight, like on the legacy API?
Hi @Orion !
Yes there is, you can find it under shipments --> shipping_labels --> dimensions --> weight
Something like this:
query {
order(id: <order_id>) {
request_id
complexity
data {
id
shipments {
shipping_labels {
dimensions {
weight
}
}
}
}
}
}
Let me know if that was not what you were looking for
Thanks again!
Tom
Yes, that works, thank you.
Hi,
Can you send me the full code how it works in PHP ?
Regards