# Get orders and tracking data in one call

**URL:** <https://community.shiphero.com/t/get-orders-and-tracking-data-in-one-call/1355>\
**Category:** GraphQL API\
**Created:** [June 3, 2021, 8:28pm UTC](https://community.shiphero.com/t/get-orders-and-tracking-data-in-one-call/1355 "2021-06-03T20:28:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeffro25](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@jeffro25](https://community.shiphero.com/u/jeffro25)\
**Post date:** [June 3, 2021, 8:28pm UTC](https://community.shiphero.com/t/get-orders-and-tracking-data-in-one-call/1355/1 "2021-06-03T20:28:04Z")

</div>

Hey all! New to this API, was wondering if there is a way to get orders and tracking numbers in a single call. We seem to be getting throttled pretty frequently, so instead of making calls order by order for a selected time range to the shipments object, was wondering if there is way to accomplish this. Seems like it would be a pretty common request. Thanks everyone!

---

<div class="post-metadata">

**Author:** ![tomasw](https://sea2.discourse-cdn.com/flex020/user_avatar/community.shiphero.com/tomasw/32/248_2.png) [@tomasw](https://community.shiphero.com/u/tomasw)\
**Post date:** [June 4, 2021, 2:01pm UTC](https://community.shiphero.com/t/get-orders-and-tracking-data-in-one-call/1355/2 "2021-06-04T14:01:26Z")

</div>

Hi @jeffro25!  
Unfortunately not on a single call, you will need to paginate through results.  
But you could also use the Shipment Update webhook to get the data instead of fetching it

[https://developer.shiphero.com/webhooks#shipment-update-webhook](https://developer.shiphero.com/webhooks#shipment-update-webhook)

And then you could also use the Shipments Query

[https://developer.shiphero.com/examples-query/#shipments](https://developer.shiphero.com/examples-query/#shipments)

But instead of using the order\_id use the date filters:

```auto
query {
  shipments(date_from: "2021-06-01" date_to:"2021-06-02") {
    request_id
    complexity
    data {
      edges {
        node {
          id
          legacy_id
          order_id
          user_id
          warehouse_id
          pending_shipment_id
          address {
            name
            address1
            address2
            city
            state
            country
            zip
            phone
          }
          shipped_off_shiphero
          dropshipment
          created_date
          line_items(first: 10) {
            edges {
              node {
                line_item_id
                quantity
              }
            }
          }
          shipping_labels {
            id
            legacy_id
            account_id
            tracking_number
            carrier
            shipping_name
            shipping_method
            cost
            profile
            packing_slip
            warehouse
            insurance_amount
            carrier_account_id
            source
            created_date
          }
        }
      }
    }
  }
}

```

Thanks in advance!  
Tom

---

<div class="post-metadata">

**Author:** ![jeffro25](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@jeffro25](https://community.shiphero.com/u/jeffro25)\
**Post date:** [June 4, 2021, 3:39pm UTC](https://community.shiphero.com/t/get-orders-and-tracking-data-in-one-call/1355/3 "2021-06-04T15:39:42Z")

</div>

@tomasw I figured it had to be separate calls. I will probably go the webhook route. Is there a way to iterate over line items on an order? I keep running into throttling when I don’t specify the first or last x amount of line items. I know how to iterate over the orders if you request more than the credits available, but I don’t really see a way of iterating over line items on an order. Not a huge deal, but curios in case I need to in the future. Thanks Tomas!

---

<div class="post-metadata">

**Author:** ![jeffro25](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@jeffro25](https://community.shiphero.com/u/jeffro25)\
**Post date:** [June 4, 2021, 4:09pm UTC](https://community.shiphero.com/t/get-orders-and-tracking-data-in-one-call/1355/4 "2021-06-04T16:09:29Z")

</div>

@tomasw the other reason I can’t really use the shipments query is because I am looking for shipments on orders for a specific store, which is why I was hoping to be able to lump these together so I could filter by store on the orders query and get only shipments from those specific orders.

---

<div class="post-metadata">

**Author:** ![tomasw](https://sea2.discourse-cdn.com/flex020/user_avatar/community.shiphero.com/tomasw/32/248_2.png) [@tomasw](https://community.shiphero.com/u/tomasw)\
**Post date:** [June 22, 2021, 12:24pm UTC](https://community.shiphero.com/t/get-orders-and-tracking-data-in-one-call/1355/5 "2021-06-22T12:24:30Z")

</div>

Hi @jeffro25  
My apologies for the delayed response about this!

> [@jeffro25](#):
>
> I am looking for shipments on orders for a specific store, which is why I was hoping to be able to lump these together so I could filter by store on the orders query and get only shipments from those specific orders.

So you would like to be able to filter shipments for a specific Store? Or maybe Customers?

> [@jeffro25](#):
>
> Is there a way to iterate over line items on an order? I keep running into throttling when I don’t specify the first or last x amount of line items. I know how to iterate over the orders if you request more than the credits available, but I don’t really see a way of iterating over line items on an order.

Absolutely! this should be similar to other queries: [GraphQL Primer – Developer Resources | ShipHero](https://developer.shiphero.com/graphql-primer/#pagination)

This case would look something like this:

- Example order is ID: 195249449 and has 3 Line Items. I will be fetching them by 2 using `first:2`

```auto
query {
  order (id:"195249449") {
    request_id
    complexity
    data {
      line_items(first:2) {
        pageInfo {
          hasNextPage
          endCursor
        }
        edges {
          cursor
          node {
            sku
            quantity
          }
        }
      }
    }
  }
}

```

I get this in response:

```auto
{
  "data": {
    "order": {
      "request_id": "60d1d5609e9372601ec15bf9",
      "complexity": 3,
      "data": {
        "line_items": {
          "pageInfo": {
            "hasNextPage": true,
            "endCursor": "YXJyYXljb25uZWN0aW9uOjE="
          },
          "edges": [
            {
              "cursor": "YXJyYXljb25uZWN0aW9uOjA=",
              "node": {
                "sku": "1122334459",
                "quantity": 1
              }
            },
            {
              "cursor": "YXJyYXljb25uZWN0aW9uOjE=",
              "node": {
                "sku": "1122334463",
                "quantity": 1
              }
            }
          ]
        }
      }
    }
  }
}

```

And it has: `"hasNextPage": true,` which means it has the next page of results, and the endCursor is `YXJyYXljb25uZWN0aW9uOjE=`

So in order to get the next set of results I will get the results **after** that cursor. The next query would be:

```auto
query {
  order (id:"195249449") {
    request_id
    complexity
    data {
      line_items(first:2 after:"YXJyYXljb25uZWN0aW9uOjE=") {
        pageInfo {
          hasNextPage
          endCursor
        }
        edges {
          cursor
          node {
            sku
            quantity
          }
        }
      }
    }
  }
}

```

And the result I get is for the remaining line item:

```auto
{
  "data": {
    "order": {
      "request_id": "60d1d5d837ccb8a4bc9072ff",
      "complexity": 3,
      "data": {
        "line_items": {
          "pageInfo": {
            "hasNextPage": false,
            "endCursor": "YXJyYXljb25uZWN0aW9uOjI="
          },
          "edges": [
            {
              "cursor": "YXJyYXljb25uZWN0aW9uOjI=",
              "node": {
                "sku": "1122334961",
                "quantity": 3
              }
            }
          ]
        }
      }
    }
  }
}

```

Now it shows `"hasNextPage": false,` which means there are no more results to display after the one we got.

Let me know if that doesn’t help!.  
Thanks again for the patience,  
Tom
