Getting started with the Shopify API

If you haven't used the Shopify API before, then you can use this guide to walk through the steps required to start making API calls in a matter of minutes.

Generate private app credentials

Your application needs to authenticate with Shopify to perform requests to the Shopify API. Shopify supports two methods of authentication: private (basic) authentication and OAuth. In this guide, we’ll use private authentication to get up and running as quickly as possible.

Before you can start using the Shopify API, you need to sign up for a Partners account. From there, you can generate the private credentials that you'll need to use the Shopify API. See our private authentication docs for the necessary steps to follow when you create your Partners account.

After you create a private app from your Partner Dashboard, you'll receive API key and password to use for private authentication.

Making requests

A common API operation is retrieving products from a store. In this guide, we’ll walk you through the process of retrieving products using two different HTTP clients: cURL and Postman. If you haven't already done so, you should add a few products in your Shopify admin for testing purposes.

Regardless of the HTTP client that you're using, you'll be performing basic authentication (with your API key and password), and interacting with a Shopify admin resource as follows:

https://#{apikey}:#{password}@#{shop-name}.myshopify.com/admin/#{resource}.json

Where {shop-name} is the name of your development store and {resource} is the name of the resource you want to interact with; in this guide we interact with the products resource.

cURL

To make a request to the Shopify API using cURL, you can supply your application credentials using the -u option flag, as in the following example:

curl -u bc663f1c58f2d72355a38acbfbb58df9:215e08b2ed1615c7e437f23c49beeec0 https://johns-apparel.myshopify.com/admin/products.json

After executing the cURL command, the products in your test store (formatted as JSON) will be returned.

Postman

Postman is an application that makes it easy to send HTTP requests to API endpoints.

To make a request to retrieve a store's products, use the following process from Postman:

  1. In Postman, open a new tab and then paste the URL to your store/resource in the URL bar to make a GET request. For example: https://johns-apparel.myshopify.com/admin/products.json
  2. Click Authorization, and select Basic Auth from the drop-down menu.
  3. Enter the API key and Private app password that you generated from your Partner Dashboard in the Username and Password fields.
  4. Click Send.

The products are returned in the body of the response, formatted as JSON.

Alternately, you can simply paste a properly formatted URL directly into the Postman URL bar before clicking Send. For example:

https://{apikey}:{password}@johns-apparel.myshopify.com/admin/products.json

See the full instructions for using Postman

Working with query parameters

By default, only the first 50 products in a store will be retrieved. If you want to retrieve more products, then you can specify the limit parameter in the request (up to a maximum of 250). To retrieve additional pages of data, you can specify the page parameter.

For example, to return 250 records you need to append the limit query parameter to the resource url as follows:

https://johns-apparel.myshopify.com/admin/products.json?limit=250

See the Product API reference for a complete list of query parameters that are possible for the products resource.

Next steps

Now that you’ve made a few basic calls to the Shopify API, you can start using this knowledge to build powerful applications for Shopify merchants.

See the tutorial for building a public Shopify application