How To get the reports by API?

Hello,

I want to know that how can I get the reports by API ? like Sales By Month, Sales by hour, Sales by channel, Sales by product , and the other report present in the site.

I am using PHP and laravel framework.

Shop Name = GLBDEMO2

API key = 52d11fe605f478534efc9ec05e4ff3a0

Thanks

1 Like

Hi Raj,

You have two options for getting reports through the API; ShopifyQL or the Order API.

The first will allow you to use query language to select, filter, and aggregate data.

The second option requires a bit more legwork, as you would need to GET order data, look at the totals, and keep the records in your reports.

@Busfox, as far as I can see the shopifyql only allows querying ‘Visits’ at this point.

When can we expect additional tables to be available?

Also, will this be made available to basic plans as well?

Thanks

HI
Is there any way that i can get “total page view” or “visitors” counter from shopify api to php?

1 Like

@Busfox

To compile monthly sales report using Orders API,

  1. How do we group orders by month? Is it based on order’s created_at, updated_at, closed_at or processed_at date?
  2. I am mainly concerned with fetching monthly shipping and taxes report. How is it possible to fetch this data with this approach?

Thanks!

Degendra

Hi,

can you help me ?

It looks like i cannot use SHOPIFYQL in my Shopify plan ($79/month) is this correct ? if yes, i could use the orders api but i need some pointers please

i need to output the total amount in $ of all orders for a specific product, in this case it is a buy-button gift card

i hope this makese sense, please help

thanks

Nabil

Hi.

You can’t use ShopifyQL in your plan. You have got plan ‘Shopify’ but for ShopifyQL you need ‘Advanced Shopify’.
https://www.shopify.com/pricing

Having your plan you can work with Shopify REST Admin Api to upload your orders data and then you can use your own app for do reports.
https://help.shopify.com/api/reference

In your case you need to upload records from Orders API:
https://help.shopify.com/api/reference/orders/order

To be able to do this, you need to create private app.
https://help.shopify.com/manual/apps/private-apps

It allow you to work with API using your creditentials, for example:
https://{username}:{password}@carinhofraldasassinatura.myshopify.com/admin/orders.json

Using API Endpoints attributes you can narrow the serch area for example:

  • only closed orders /admin/orders.json?status=closed
  • only orders where financial status is paid /admin/orders.json?financial_status=paid
  • only closed orders and where financial status is paid /admin/orders.json?status=closed&financial_status=paid

Please take a note that Shopify REST API has limitations. As default you will retrieve 50 orders but you can increase it to max. 250. So you need to use ‘limit’ and ‘page’ Endpoints attributes. Below example of your final request:
https://{username}:{password}@carinhofraldasassinatura.myshopify.com/admin/orders.json?status=closed&financial_status=paid&limit=250&page=1

If you will decide to upload your data for your server (or local) please take a note that Shopify Rest API has his own ‘call limit’.
https://help.shopify.com/api/getting-started/api-call-limit

Sending requests you have to staying within this call limit.

After uploading all orders what you need you can start analyzing the data using the method of your choice, for example SQL, if you have saved data to the database.

You can do ‘one time’ scrpit or you can use webhooks to be able to constantly update data:
https://help.shopify.com/api/reference/events/webhook

Well, maybe it not looks easy but Shopify API is very logical, all limitations allow to retrieve necessary data. You need time and knowledge only.

Regards,
Rafał

This is great, thank you Rafal!

After reading, and researching and more reading :slight_smile: i am able to do just that what you have nicely described above. so thank you!

I created a private app and was able to do api calls on the order object and i was able to narrow it down to the amount value I needed.

a couple of questions.

  1. i am calling the api url from another server not my shopify store, using php. do i need to maintain a separate server to be able to make api call or can i use my shopify store to do it. create a template inside my store that make that api call.

  2. I created a private app and got the necessary credentials to make my calls from my partner shopify account. I am not sure what i need to do from my production site to install that private app that i created under my partner shopify account.

Does that make sense ?

Thank you again in advance.

Nabil

Hello.

I am glad that the information was helpful for you.

  1. You can use your server or local machine to send requests to Shopify Rest Api. If you need to use Shopify webhooks, then you should have a server with a domain or subdomain address, e.g. mysubdomain.carinho.co.

  2. You don’t need to install inside your app anything. Your script is your app. If you use PHP then your script should send GET requests, for example via curl, and display or save the results or what you need. The results what you will receive will be in JSON format.

A little trick to check if your app will be work correctly with your creditentials:

This trick will show you that if you use private app, then all what you need it is send correct request to receive data.

If you will need to create, update or delete records you need to use other request methods than GET.

For more information please read Shopify API REST documentation - it is really high level documentation and allows to self-learning.

You can feel free to use other resources to learn eg. https://stackoverflow.com/ or blogs and articles eg. http://gavinballard.com/building-shopify-apps-with-php/

For use tested (and not tested) ready to use code use Git free sources. Eg:
https://github.com/phpclassic/php-shopify
https://github.com/ohmybrew/laravel-shopify

Regards
Rafal

Thats great!

Yes i am successful now at making my api call from a separate server using my private app credentials and it works i get the right value i asked for. I want to add that retrieved value on one of my shopify blog pages, to do that i used an iframe to display it.

It is perfectly fine and it does what i needed to do.

just wandering if iframe is the way to go or if there is another method to diaply that api info from inside the shopify page without using iframe.

thanks a lot i appreciate it!

Nabil

Nabil

That’s great you got success!!!

You can try other way to display your values. In my opinion faster. Use Metafields for store values.

  1. Using REST API store your value as Metafield related to blog (or blog and certain article) and upadte it every time the value is change

https://help.shopify.com/api/reference/metafield

  1. Use Liquid for calling to Metafield Object and retrieve value and display it on your blog.

https://help.shopify.com/themes/liquid/objects/metafield

I think that this solution is more elegant and, and relieves your server (you do not need to handle every request when displaying your blog page, because all is done by Shopify resources). Maybe this method will give you new ideas for using Metafields and dynamic values and make your store even more attractive for your clients.

Regards

Rafal

Did you get any solution to the problem? Also I can’t GET the API to retrieve visitor quantity data.

Anyone can help?