Sinatra and Shopify: A Classy shopifyapp

Published on June 20, 2009 by Jesse Storimer

This week I wrote up a basic sinatra app that allows you to work with the Shopify API. It’s basically just a port of the shopify_app rails plugin to sinatra.


I have been having fun working on Shopify apps lately, but I needed a simpler way than always generating a new rails app, new controllers, etc., for every little idea.

Rails is great, but most of the Shopify apps that I have come up with are one page apps, maybe two or three pages. The point is, I don’t need a controller for that, I don’t need the 63 files or however many the rails generator generates for me.

Sinatra is most awesome when you are working on a small app with just a few routes. You can clone this app and use it as a starting point for a shopify_app. All of the authentication logic/routes are in the lib folder, so they don’t pollute the code of your app.

So in app.rb, you just have to worry about the functionality of your app.


The fastest way to get this thing running:

  • git clone git://
  • cd sinatra-shopify
  • heroku create (make sure that you remember the name of your app as you will need that later)
  • visit the Shopify Partners area
  • Sign up for an account if you don’t already have one
  • Log in to your Shopify partners account
  • Create a new application.
  • Make sure that the Callback URL is set to
  • In the lib/sinatra/shopify.yml file replace API_KEY and SECRET with the Api Key and Secret that you just got from the Shopify Partners area
  • git push heroku master
  • heroku open

The current implementation for authentication is to add the authorize! method at the top of any routes that you want to be authenticated, like so:

Gimme the code!


I am by no means a sinatra expert, this is really my first experience with sinatra. So if you see anything that could be done better, the source is on Github, fork away.

Like what you read?

Join 2,000+ Ruby programmers improving their skills with exclusive content about digging deeper with sockets, processes, threads, and more - delivered to your inbox weekly.

I'll never send spam and you can unsubscribe any time.

comments powered by Disqus