Ad

How To Get Reports From Shopify

- 1 answer

I am trying to get the reports from Shopify (Analytics -> Reports) using Python, like this:

import requests

APIkey = "myAPYkey"
APIversion = "2019-04"
Pass = "myPass"
hostname = "myHost"

response = requests.get("https://{}:{}
{}/admin/api/{}/reports.json".format(APIkey,Pass,hostname,APIversion))

print(response.text)

However I get

{"reports":[]}

On the other hand, I do not know where I can find the ID of the reports.

Why is that? If I enter to the section Analytics -> Reports I can see several reports.

Ad

Answer

If you read the description at Report Page in REST API Reference, it states

You can use the Report resource to publish reports to the Reports page in the Shopify admin. For example, a shirt fulfillment app could publish a report that compares the sales of shirts by marketing campaign. The reports are based on queries written in ShopifyQL.

Reports are scoped to the app that created them. When an app creates a report, other apps can't view, modify, or delete that report. Also, apps can't access reports that were created from the Shopify admin.

The first paragraph states that how you can create the reports in Shopify admin based ShopifyQL. This API provides resources for that like Create and Update Reports.

The second paragraph states that the only app that created the Reports can access them via API. Moreover, any reports that were created from Shopify admin are also not accessible via API.

So this empty response for your get All Reports call, just tells that you have not created any report via API. Once you do, you will see the results there.

If you want to replicate the reports in Shopify Admin, have a look at ShopifyQL and then you can create something similar that is also accessible via API. Besides that there is no other way yet to get Shopify reports via Rest API.

Ad
source: stackoverflow.com
Ad