Introduction
The Shopify Admin API allows you to read and write Shopify store information, including products, inventory, orders, shipping.
In this document we will explain how to integrate this API in Denodo and how to configure its pagination. In our tutorial we will retrieve the information of the products available in a Shopify store.
Accessing the API
API limits
According to the documentation of the Shopify API, the Admin API supports a limit of 40 requests per app per store per minute. If this limit is exceeded, the API will return a 429 error.
Creating a test store
First, we are going to create a store for testing following these steps:
- To access the API you need to log into shopify.dev.
- Go to “Stores”.
- Click on “Add store” > ”Create development store”
.
- We need to enable “Create a store to test and build” and enter a store name.
- Then, we enable “Latest build” and “Start with test data”. After that, click on “Create development store”.
Getting the API key
Once we have created the store, we have to get the credentials in order to use the API. We are going to get API credentials following this tutorial until the “Using Your Token to Connect a Shopify Channel” section. In the final step, copy the Admin API token and save it to a secure place.
Save both the API key and the Admin API token, we will need them later .
Integration to Denodo
Data source
The Shopify Admin API is a REST API and returns responses in JSON format. So the first step is to create a JSON data source. To create the JSON data source, go to File > New > Data source and select JSON(HTTP/OpenAPI).
The Tool will display the dialog to create the data source:
- Data route: HTTP client.
- Base URL:
https://<store name>.myshopify.com/admin/api/<version>/products.json?limit=3
In this example we are retrieving product information and introducing a limit of 3 products per page to show how the pagination works, this limit is by default 50.
Pagination
In this API the response returns the first page of results, and a response header returns links to the next page and the previous page of results.
- In the data source configuration go to the pagination section.
- Introduce a maximum number of requests. In our case we are introducing only 2 requests as our test store has a reduced number of products.
- We need to indicate the HTTP Header that contains the next page URL. For instance, using an http client like Postman, we can see that the link header has this value.
- Check the option “Obtain the next page URL from an HTTP header of the response”. There, we need to indicate that the link to the next page is under the link header of the response. So we have to introduce “link”.
Authentication
To configure the data source we also need to enable authentication. We will use Basic Authentication, with login and password. The login is the API key and the password is the Admin token that we had saved before.
Base view
Once we have created the data source we have to create a base view to retrieve information about the products of our store.
- We create a base view from the data source.
- Click on “OK”.
- Introduce the tuple route /JSONFile/products to flatten the response. This is the JSON route to access product details.
Final result
In order to select the fields that we want to retrieve from product information, we can create a selection view from the base view.
- Right click on the base view and go to New > Selection.
- In our example we are going to remove from the output some fields that we are not interested in. You can select the fields in the output section and there you check in the field that you want to remove and finally click on “Remove”. We have selected the fields shown in the screenshot below.
If we execute the view that we just have created it will return something like in the screenshot below: the product ID, the title, the vendor name, the type of the product; when it was created,updated and published; the status and its tags. In the screenshot we can see 6 rows, this is because we had configured 2 total requests with a limit of 3 products per request.
References
Getting the API Access Token from Your Shopify Store
Obtain the “Next Page URL” from an HTTP Header of the Response
The information provided in the Denodo Knowledge Base is intended to assist our users in advanced uses of Denodo. Please note that the results from the application of processes and configurations detailed in these documents may vary depending on your specific environment. Use them at your own discretion.
For an official guide of supported features, please refer to the User Manuals. For questions on critical systems or complex environments we recommend you to contact your Denodo Customer Success Manager.