Is the API using estimated or actual cost

Hi there,

I had a question about how this GraphQL API has been implemented.

With the leaky-bucket algorithm in place, cost of API calls is quite important for us as we receive quite a few orders every day (>1000). This number can increase up to 4x depending on promotions, time of the year, etc.

Our main issue is that we have to make a query for shipments. Because we have some large B2B orders, we can’t reduce the amount of items we show for the shipment query.

This leads into my main question: With the credit limit system, is it limiting us based on the estimated cost of the query, or is it using the actual cost?

I’m just concerned because the majority of our orders will not hit anywhere near the 100 line item limit, but they seem to cost the same as an order that would actually have 100 items. This seems strange, as I would think that when the result only brings back, for example 10 items, it should cost less than actually retrieving 100 items.

I will leave an example query below for reference, but if it is in fact using the estimated cost instead of the actual cost, could you inform me as to why that decision was made?

query 
{
  shipments
  (
    order_id: 1234567890
  ) 
  {
    request_id 
    complexity 
    data (first:1) 
    { 
      edges 
      { 
        node 
        { 
          created_date 
          order 
          {
            order_number
          } 
          line_items 
          {
            edges 
            {
              node 
              {
                line_item_id 
                quantity 
                line_item 
                {
                  sku
                  id
                }
              }
            }
          }
          shipping_labels 
          {
            tracking_number
            carrier
          }
        }
      }
    }
  }
}

Thanks!

Hi aadam,
Welcome! The complexity is calculated based on the query and not the results. An optimized query will be the best thing you can do. There is some more information that can help here:Getting Started – Developer Resources | ShipHero