Hey Terry!
I think I can help you with the API explanation a bit. I'm going to start from the basics, as I'm not sure with what you are familiar, but I hope you can find this of some use! :)
API stands for Application Programming Interface, which means just as it says. It is an interface with which you can access an application through the use of programming. In Shopify's case, we use mainly REST based APIs. This means you can call a url, and get a response in JSON or XML (please use JSON!)
For example, you can hit up https://yourstore.myshopify.com/admin/orders.json and get a list of all orders. Using GET, POST, PUT, DELETE, etc http requests you can manipulate the data.
This is where the Shopify API gem comes into play. To get to the data, you need to have a few things.
- Authentication
- Parameters & Constraints
The authentication is provided by api keys and secrets. These use a secure method over HTTPS to authenticate that you should indeed have access to the information, and then gives it to you.
The parameters and constraints work to provide you with scoped and filtered information, as well as give you back X number of whatever you're looking for etc. Most of the times, you are only able to get back 250 of one thing with each call (though that number could be different, 250 is the limit I think). This is because many stores of thousands of orders, products etc. To provide this to all customers could be a phenomenal strain on both Shopify and the app you are making, so it works in a pagination. You say I was 0-250, then 251 to 500, then etc.
By using the Shopify Ruby API gem, all of this is encapsulated in a very nice Ruby-esque experience to allow for the best experience and native language integration, though using another wrapper you could accomplish the same thing with any other language with web access, like Objective-C, Java, C#, PHP, etc... but if there is not a wrapper you can simply hit up the urls provided, like the example one or ones provided in the docs, with the right JSON parameters and constraints, and you're good to go! Fun fact: Our mobile apps use the API!
To give you a hand in the Ruby code, here is a snippet that I have from a private app I use:
ShopifyAPI::Base.activate_session(session[:shopify]) @collection = ShopifyAPI::CustomCollection.find(:all, :params => {:title => params[:city]}).first @products = ShopifyAPI::Product.find(:all, :params => {:collection_id => @collection.id, :order => "updated_at ASC" })
- This snippet first activates my session with Shopify.
- It then searches for all Custom Collections by finding all collections where the title is equal to the parameter I give called city. It takes the first one it finds.
- From there, it finds all products with the collection id that is specified by the collection I found above, and orders them by the last updated at.
As you might notice, all the syntax is Ruby syntax, giving you the verbosity and native experience that comes with using Ruby.
Essentially, the API is sort of a middle man between Rails and Shopify. It sits there and provides you with a port hole into the Shopify application so that you can fetch information from your store.
I found this image which sums things up nicely, where "Their App" is Shopify:
I hope this clears things up for you.