So I grammed a while back that I was looking into the shopify API and thinking of ways to automate a bit of the processes and communication I have to handle with my customers on Luxury Craft. I have finally (After very long procrastination) decided to get a new side project going and build my github cred.
In this blog I’ll give a quick run down of the project I have in mind, look at the APIs and the different end points I would have to use to get the project going. We will make a few pull requests to get data out from Shopify and eventually The next blog will go more into the actual design and architecture
PROJECT IDEA
So one of the most important things with an online store is continuous engagement, because you are not physically visible to trigger that need to buy, you need good communication protocols and methods to ensure you stay fresh and relevant in your customers mind. There are a lot of ways to keep the communication going from monthly or weekly emails, to calls and even smses with the main aim of the communication being conversion to sales.
One of the most neglected ways to convert communication to sales, is through the order notification emails. Research has shown that emails received to notify a customer of an order’s process state have a high read rate. This means if you are to advertise here you have a greater chance of turning the communication to a sale. Not only are you advertising to someone who is already a customer and therefore more likely to buy again but you also now know a bit about what the customer likes through the ordered products .
I am looking to create an app that can do the above.
On order fulfilment, the application will send out an email telling the customer that the order has been shipped or fulfilled but also add to that email, recommended products likely to be bought by that customer
This means you need to have some way of telling that if a customer bought product A, they would be likely to buy product E and F and not C. How you decide to link and relate the products is not really important for this exercise. You could use some AI to learn which products are “co-bought” (Would really have to have a large number of orders for this) Whichever way you decide, you will need to associate each product with a number related product.
Not a ground breaking project or idea and could be possible to get an app that does the same if I looked well enough but the point of this exercise is not to create great IP but to explore the shopify and mailchimp API
We will need to interface with both the Shopify and MailChimp APIs as our work heavily relies on their data and services. So a great starting point would be understanding the two APIs
WHAT IS AN API (Application Programming Interface)
In very simple terms, an API is the middle man that takes requests from application A to application B, tells application B what you want to do and returns the response given by application B back to A, the requestor. It is basically the unsung hero of all the behind the scenes connectivity allowing us to get data from anywhere. The middle man who understands what you want from a specific platform and returns it to you without you having to understand all the complexities of the implementation of that platform.
So for example Shopify has their software which has their DataStore holding your store data and all the thousands of other stores registered with them. Your store data holds all your products, orders and customer information. Through their web User Interface or mobile app you can see and manage your shop and all the products and orders in your store.

Say one day you decided you wanted to use products and customers information in your store (like we have now) . Say we are a very big company with thousands of customers, we cant possibly sit down to right out each order and customer info. For us to get this information without their API, we would need to somehow get access to their datastore, understand their database model, and figure out how to be able to get just our information out from the thousands of store’s data they have in their datastore with the many tables. Now that would just be a headache and security nightmare
So what the nice guys at Shopify (and many other companies including Mailchimp) do is give you an API from which you can interface with their data. They create a middle man and give that middle man some pre-defined language that you can use to communicate with him (or her, most likely her with her good communication skills:) ) by to get the data you would like. So all you need to do, is understand this language that the middle man speaks. This is clearly documented in their API documentation.

Now that thats out of the way let’s have a look at the shopify API documentation to see what we are allowed to ask the middle man for and how we should ask for her to understand our request.
If you do not have a Shopify store you can register to become a partner to create a mock store with mock data. You can follow here to get started to become a partner and then create your fake store. To keep this short I wont have this included here. If you need assistance you can comment below and I’ll help.
A look at the Shopify API
Authentication
When building applications to integrate with shopify, you would need to select whether you are creating a public application which would be used by more than one store or a private application to be used by one specific store. Your authentication process depends on this decision. I will only be focusing on the private application for this blogpost.
To connect with the API you need to make http calls to the middle man and authentication credentials must be sent with every call. The credentials are used to let the middle man know and trust who you are and know which data you are eligible for.
Your credentials can be sent through by passing your Shopify’s store token prepended with the string “Basic ” in your headers with Authorization as Key. To generating your store credentials, have a quick look here .
An example call using my store data to make a call for my shop data in json below

Responses
When a call is made you will get one of the responses described in detail here
EndPoints
The API documentation lets you know of all the possible requests you can make and the data you can expect from them. For example with the example above,the documentation specified that to get my store customers in json format, i would need to make a call to this endpoint
https://<store url>/admin/customers.json
Get the detailed documentation here
Webhooks
Webhooks are what will make it possible to take action based on an activity that occurred in the store. They are useful when building applications that need to do something after an event has occurred without having to make continuous calls to the API to check if the event has occurred.
Webhooks send a HTTP Post to a specified url to notify you of the event. Your application would then respond to the post and then continue to fulfil any action required on that event. We will look into this in more detail in the following posts
A look at the MailChimp API
The application needs to be able to be notified on order and send out an email to the specified customer.
Authentication
Just like Shopify (Or any self respecting API really), Mailchimp will want to ensure that it is talking to a real and verified person before sending out data. This is again done through token based authentication. Follow steps here to get your token referred to as the APIkey here
EndPoints
All calls are to be made to the following url :https://<dc>.api.mailchimp.com/3.0
Where <dc> refers to the dat centre for your specific Mailchimp account. For example, if the last part of your MailChimp account is us6, All API endpoints for your account are available at https://us6.api.mailchimp.com/3.0/.
See an example of a call for my mailchimp info.

Sending Emails: Mandrill
As of v3.0 of the Mailchimp API Sending out of transactional emails is now handled by Mandrill.
You would also need to authenticate yourself similarly to above with https://mandrillapp.com/api/1.0/ as the base url. You would also need to get another token
When accessing the Mandrill API, All API calls should be made with HTTP POST with the token parsed with the key “key”
See below an example calling to https://mandrillapp.com/api/1.0/users/info.json which returns information about the API-connected user
The full API documentation can be found here
WRAPPING UP
This post covered the API required to create an application integrating with Shopify and MailChimp. We describe a small problem that we will solve over a mini series.
Please comment, correct and give input
“The only legacy I will accept is to know that how far I got, was as far as I was capable of going, to drown in my own sweat, knowing there was nothing left”
-FIGHTING MEDIOCRITY : One thread at a time