If you are a Shopify app developer, you may have already heard that they made an update with their Shopify’s Admin API (GraphQL and REST) called Shopify API versioning. At this moment, we are already at 2020-10 and the 2021 release is just around the corner.
Their goal is to ensure that any developers could build Shopify apps and Shopify themes confidently. They have also made changes to their Shopify Partner Dashboard, the Developer Changelog, and to their developer documentation page to make it easier for us developers to stay updated of upcoming new versions.
If you have already built a Shopify app using the old versions of Shopify API. Migrating to Shopify API 2020-10 is very easy. All you needed to do is to update the endpoint URLs that your app calls to explicitly declare the API version.
Each URL should include the following format.
/admin/api/<version date>
Code language: HTML, XML (xml)
For example, if you are trying to call using the REST endpoint, the URL endpoint could go something like:
https://<your-shop-name>.myshopify.com/admin/api/2020-10/smart_collections.json
Code language: JavaScript (javascript)
Shopify API Versioning
Keep in mind that Shopify will release another update for the API versioning quarterly. This means that you should always stay up-to-date on what’s new.
Now, if you are confused about when they’re going to make updates. You may use the following table as your guide or reminder.
Stable version | Release date | Date stable version is supported until |
---|---|---|
2020-04 | April 1, 2020 | April 1, 2021 |
2020-07 | July 1, 2020 | July 1, 2021 |
2020-10 | October 1, 2020 | October 1, 2021 |
2021-01 (Release candidate) | January 1, 2021 | January 1, 2022 |
How to use API versioning?
If you have already developed an app using the old API then I highly recommend you to update your PHP files and change the base URLs.
Also, to make it easier for you. You should just declare a variable holding the version name of the latest API version. By doing so, every time Shopify updates the API, you won’t need to change anything but the variable holding the version name.
For this example, we’ll be using the code that we wrote on our previous tutorial on how to display Shopify products using PHP.
$collectionList = shopify_call($token, $shop, "/admin/custom_collections.json", array(), 'GET');
$collectionList = json_decode($collectionList['response'], JSON_PRETTY_PRINT);
$collection_id = $collectionList['custom_collections'][0]['id'];
$array = array("collection_id"=>$collection_id);
$collects = shopify_call($token, $shop, "/admin/collects.json", $array, 'GET');
$collects = json_decode($collects['response'], JSON_PRETTY_PRINT);
Code language: PHP (php)
If you have noticed, the code above is using the old format of API. No versioning whatsoever.
Migrating to New Shopify API versioning
To migrate from old API to new Shopify API versioning. We must change the code above to something like this.
$shopifyVer = "api/2020-10";
$collectionList = shopify_call($token, $shop, "/admin/".$shopifyVer."/custom_collections.json", array(), 'GET');
$collectionList = json_decode($collectionList['response'], JSON_PRETTY_PRINT);
$collection_id = $collectionList['custom_collections'][0]['id'];
$array = array("collection_id"=>$collection_id);
$collects = shopify_call($token, $shop, "/admin/".$shopifyVer."/collects.json", $array, 'GET');
$collects = json_decode($collects['response'], JSON_PRETTY_PRINT);
Code language: PHP (php)
The code above will make it easier for us to update our Shopify API calls. Just overwrite the value of the variable and that’s it.
Another thing to remember to keep your app updated is to navigate to your app setup. In the Webhook API version section, change the dropdown value to the latest version like below.
Summary
There are a few changes going to happen to Shopify REST this 2021, and so if your app uses API resources such as FulfillmentOrder and Billing then make sure you update your app as soon as the new version of Shopify API is released. Otherwise, your app will break.
I created and installed the dummy app, unfortunately showing a refused connection Error message in the Shopify store(dummy store) after installation.
Kindly help me!!!
Hello Navpreet!
Thank you for sending us a comment!
If you are encountering a refused connection error message. You may want to double-check your URL and see if it gives you
.myshopify.com.myshopify.com
. That’s most likely the reason behind the error. Otherwise, it’s related to your server.We hope we helped you!
Cheers from WeeklyHow
Hi, I have read and watched all your tutorials regarding creating an app using PHP.
I would like to know if it is possible to add an iframe on my app setting page?
My client has a website where users can log in and to see their dash, i want to create an iframe of this website to make it easy instead always going to the external page.
Do you have an article or a video that can help to understand how this can be achived?
Hi Valery,
First off, thank you for reading and watching all of our guides about Shopify app development.
Second, about the iframe. We haven’t really tried this ourselves. Have you tried to just embed it directly?
Bernard
hi Bernard, i am new to shopify apps.
the thing is that i currently don’t have the source files of the dash. how hard is it to embed an existing working dash to a shopify app? and is it possible to release it as public in this case?
thank you for your help
To answer your first question, it depends. If you just need to display it in the Shopify app, you can just use iframe. Though there’s a possibility that you’ll need to set up the iframe source’s headers and yes, you can always submit your app to the app store. Though I recommend reviewing Shopify’s listing guidelines: https://shopify.dev/concepts/app-store/getting-your-app-approved/app-requirements#writing-a-shopify-app-store-listing