Get All orders with line items by date

Hi all. Can someone provide me query for getting all order with line items by specific date(by 1 day). Thank you. I need do that every day at one time

Hi kotofanik!
I donā€™t know what particular information you need on those line items, but this may help you get started with it:

  query {
  orders(order_date_from: "2019-09-23", order_date_to: "2019-09-24") {
    request_id
    complexity
    data(first: 10) {
      edges {
        node {
          id
          legacy_id
          order_number
          shop_name
          fulfillment_status
          order_date
          total_tax
          subtotal
          total_discounts
          total_price
          email
          profile
          packing_note
          required_ship_date
          tags
          line_items(first: 3) {
            edges {
              node {
                id
                legacy_id
                sku
                quantity
                price
                product_name
                fulfillment_status
                quantity_pending_fulfillment
                quantity_shipped
                warehouse
                quantity_allocated
                backorder_quantity
                warehouse_id
                locked_to_warehouse_id
                subtotal
                barcode
              }
            }
          }
        }
        cursor
      }
    }
  }
}

As for first arguments they are supposed to limit the number of possible results, so your query does not get to complex and consume a lot of credits.
You can also add pageInfo field next to edges in case you get many results and need to navigate through results (pagination)

1 Like

Thank you. i tried it with pagination by 3 orders, but i have next problem

There are not enough credits to perfom the requested operation, which requires 301 credits, but the are only 83 credits left. You can execute queries up to that level of credits or wait 21 minutes until your quota is refreshed

One request for 3 orders takes 301 comlexity and i can get only Ā±40-45 orders per hour. What is the best way to resolve it?

I want to get all orders by the day, can you help me please?

Hi kotofanik!,

Our engineering team has been working on a new throttling strategy, that is aimed to solve this kind of problems. We are planning on releasing it next week.

Iā€™ll send you an update once its implemented so you can test if it works better for you

1 Like

Thank you! I`ll waiting your updates.

Out of curiosity, are you setting a first argument for line_items as well when making that request?

Hello,

I am also having a similar issue with the throttling limit when trying to get all orders. Has the new strategy been implemented?

Hi @janiceluong!
It has!, do you happen to have a request_id (the one you get back when running out of credits)?
That way I could check the query and see if I can help you optimize it or suggest a strategy or workaround.
Thanks in advance!
Tom

Hi @tomasw,

Thank you so much for responding! Here is the error information that I get:

ā€˜codeā€™ = {int} 30
ā€˜messageā€™ = {str} ā€˜There are not enough credits to perform the requested operation, which requires 21 credits, but the are only 14 left. In 1 seconds you will have enough credits to perform the operationā€™
ā€˜operationā€™ = {str} ā€˜shipmentsā€™
ā€™request_idā€™ = {str} '5faacfa7ce896646429df613ā€™
ā€˜required_creditsā€™ = {int} 21
ā€˜remaining_creditsā€™ = {int} 14
ā€˜time_remainingā€™ = {str} ā€˜1 secondsā€™

Hi @janiceluong!
That Query looks ok, is it the only one you are sending? and at what frequency?

Hi @tomasw,

I do have another query that Iā€™m sending for ā€œordersā€, but I usually wait 10 mins between them before trying and I am currently testing my python code, so two nights ago I was sending it quite often, but in the past 24 hours I havenā€™t sent any so I tried to again for ā€œshipmentsā€ and I still ran into the same error even though I made sure none of my other queries were running/on debugging. I noticed this error only happens when Iā€™m trying to run the query for ā€œshipmentsā€.

I see, then if its that just one Query you should not be seeing that throttling @janiceluong
Let me just search for all the Queries made on your account and see if I can spot anything.
Thanks again for the patience while I look into it!
Tom

Thank you so much @tomasw!!

Hi @tomasw,

I found out the credit issue that I am having is because another team at my company are also using the credits and theyā€™re pinging the endpoint pretty often, so weā€™re working on requesting more credits with ShipHero. Thanks again for replying and looking into this for me!

Thanks for the update @janiceluong
Makes sense then, please let me know if there is anything else I could help with.
Thanks again!
Tom