This page was printed on May 19, 2019. For the current version, visit https://help.shopify.com/en/api/guides/using-the-api-console.
If you'll be writing your app in Rails, or want to troubleshoot issues in your app, the Shopify API console will allow you to easily interact with the API without running a full Rails app or making HTTP requests via curl.
This tutorial will get you started using the Shopify API console in development.
Before you begin using the console, you will need a few things:
Setup your development store and get the required gems
To become a Shopify Partner register here for your free Shopify Partner account. As a Shopify Partner, you gain access to the Partner Dashboard where you can create development stores. To create a development store, navigate to the "Development stores" tab and click Create a new development store.
Open up your development store and populate it with Orders, Customers, Products, etc. — whatever you may need to properly develop your app.
You can generate your API key one of two ways:
Create a private API key: In your development store, click on the Apps tab. At the bottom of the screen, click on the Manage private apps link.
Create a public API key: In your Partner Dashboard, click on the Apps tab. Click the Create app button and complete the required form. Once you complete the form, you will be given an API key.
Once you have your API key get the shopify_api and shopify_cli gems. Once you're done, we can get going with the console.
Use the console
Open up your terminal, and type 'shopify-cli'
You're presented with options for setting up and managing connection configuration. Nothing is set up yet, so add a connection. Name it whatever you like, but make sure that the URL matches up with that of your development store. You'll be prompted to enter in your API key and password, which you can find in your shop admin. Be sure to enter the API password, not secret.
That wasn't difficult! Now let's start the console. Type 'shopify-cli console'
To make things easier, we'll include the ShopifyAPI module provided by the shopify_api gem right away. This is optional, but if you leave it off, you'll need to prefix API calls with 'ShopifyAPI::'.
Now you can start to look at the data. Check out the API docs to see what is queryable and mutable.
Let's start out with something simple. To look at your products, type 'Product.all'
Let's try something more advanced. We're going to add a customer with the following values:
Don't forget to save the entry!
You've now successfully added a customer to our shop, and sent them an email invitation. Let's use this example to see how we can troubleshoot errors. Change the entry slightly to set a password instead of sending an email invite, and then save the entry.
If we use this data, we'll see that it fails when we try to save.
So, why did it fail? Type 'i.errors' to find out. We'll get some information back on what we tried to post, and some information on the error, which we see is the following.
It didn't work because the password is too short, and the email address is already registered to the first customer we created. We've just quickly and easily troubleshooted why an API call wasn't working. Success!
Make complex calls
Let's take a look at how to string together a couple more complex calls.
Get a list of something using query parameters
Here we'll find all products, using the limit parameter to limit the results to just three products.