List of returned orders empty when using Python API

AI-generated summary

Python and Node.js API calls to Shopify’s orders.json endpoint are returning an empty orders array even though orders are visible in the Shopify admin. The main reported symptom is a successful authenticated request (200 OK) with a very small response body, indicating no orders were returned.

Key points raised:

  • The Python setup successfully creates and activates a Shopify session, but shopify.Order.find() returns no results.
  • The original poster is confused that opening the same admin API URL in a browser shows data, likely because the browser session is already authenticated in Shopify admin.
  • A Shopify response suggests a likely cause: archived orders are excluded by default, so the request may need status=any to include all order states.
  • If that does not fix it, Shopify support requested the X-Request-Id from the response headers for log investigation.
  • A second participant reports the same behavior in Node.js and Postman, sharing a request ID and showing a request that uses selectedView=all, which still returns an empty array.

Status: unresolved in the thread; status=any is the main proposed next step.

NOTE: I have detailed this in a stackoverflow post as well if you would like some internet points: https://stackoverflow.com/questions/62135563/shopify-api-returns-nothing-when-there-really-is-data

Using the Python shopify API, I create a session and try to fetch all orders for a store. The code looks like this:

import shopify
import pprint
import logging

logger=logging.getLogger(__name__)
shopify.Session.setup(api_key=api_key, secret=api_secret)
session = shopify.Session(    myshopify_domain, api_version,    access_token)
shopify.ShopifyResource.activate_session(session)

for order in shopify.Order.find():
    logger.info(pprint.pformat(order.to_dict()))

So shopify API clearly manages to create and use the session to fetch data successfully, as can be gandered from the log output:

2020-06-01 15:08:47 INFO (MainThread) [pyactiveresource.connection:257::_open()] - GET https://my-store.myshopify.com/admin/api/2020-01/orders.json
2020-06-01 15:08:47 INFO (MainThread) [pyactiveresource.connection:301::_open()] - --> 200 OK 13b

However, the returned list of orders is empty (as is also evident by the “13b” in the log).

But when I look in the shopify admin panel for this development store, I have several orders of varying states and with varying data. There should be at least 4 of them submitted within the last week.

And if I just open the URL mentioned in the log https://my-store.myshopify.com/admin/api/2020-01/orders.json (not the real URL) directly in the browser, I also see a bunch of data there.

To me this raises a few questions:

  • How come no orders are returned when using the api, even though it seemingly authenticates fine?
  • How could I possibly get data when opening the URL in the browser since I have no authentication set up there?

Any hints are welcome. Thanks!

Hey @devdude ,

Are you adding any parameters to your call? If those orders in your test store are archived, your GET to the orders endpoint needs to include the param status=any to have those orders included in the response.

If the missing parameter isn’t the cause, please send along the X-Request_Id value found in the response headers for the call, and I can use this to investigate further in our logs.

Hi

Even I’m facing the same issue with node.js request module, I’m using the request module to make a get request on api using access token, even in postman I’m getting empty array,

My reqeust Id is :- fa4a889e-4040-47f2-84d0-ca1f684f4177

My code for accessing shopify api is :

let orderUrl = shopUrl+`/admin/api/${shopifyApiVersion}/orders.json`;
let queryParams = {'selectedView' : 'all'};
let headers = {'X-Shopify-Access-Token': event.requestAttributes.accessToken}
let orderDetails = await request.get(orderUrl, {headers: headers, qs : queryParams});

this is the response I’m getting :

{
'orders' : []
}