Skip to content

Instantly share code, notes, and snippets.

@hjblok
Created May 3, 2013 09:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hjblok/5508251 to your computer and use it in GitHub Desktop.
Save hjblok/5508251 to your computer and use it in GitHub Desktop.
A rudimentary Shopify App
# We'll use the Ruby library provided by Shopify. You can install this as a gem.
# More info on: https://github.com/shopify/shopify_api
require "shopify_api"
# Next we need some authentication to be able to access our Shop. Lets use a private App for the moment:
# 1. follow the instructions on http://docs.shopify.com/api/tutorials/creating-a-private-app to create one,
# 2. insert the API-KEY and PASSWORD in the url below,
# 3. also change MY-SHOP into your shops subdomain.
ShopifyAPI::Base.site = "https://API-KEY:PASSWORD@MY-SHOP.myshopify.com/admin"
# Now we'll be using the Shopify API to interact with our Shop.
# Our App needs a list of Products. According to the API documentation, this should be possible,
# see http://docs.shopify.com/api/product#index
my_products = ShopifyAPI::Product.all # this will start a HTTP GET request to /admin/products.json
# Yet we can do whatever our App needs to do with our Products, this App just displays our Products
puts my_products.inspect
# Without using a library provided by Shopify, an even more rudimentary App would be:
curl "https://API-KEY:PASSWORD@MY-SHOP.myshopify.com/admin/products.json"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment