Slide 1

Slide 1 text

API Driven Applications An introduction to using Ruby (and Rails) for building API-only applications.

Slide 2

Slide 2 text

Hi, I’m Darcy.

Slide 3

Slide 3 text

GitHub: sutto Twitter: @sutto Email: sutto@sutto.net

Slide 4

Slide 4 text

Filter Squad. and we make...

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

Consuming & Producing APIS

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

What you should know and love.

Slide 9

Slide 9 text

Distinct API apps

Slide 10

Slide 10 text

Build services

Slide 11

Slide 11 text

Embrace HTTP

Slide 12

Slide 12 text

Embrace HTTP Love

Slide 13

Slide 13 text

Cache-Control Expires ETag Vary

Slide 14

Slide 14 text

Efficient Validation http://rtomayko.github.com/rack-cache/ faq#efficient-validation

Slide 15

Slide 15 text

Varnish + Rack-Cache

Slide 16

Slide 16 text

Be consistent, especially in responses.

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

source: http://www.flickr.com/photos/variationblogr/6658533167/, Used under CC.

Slide 19

Slide 19 text

source: http://www.flickr.com/photos/variationblogr/6658533167/, Used under CC.

Slide 20

Slide 20 text

Simple to learn, explore.

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

Use your browser

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

Versioning

Slide 25

Slide 25 text

A Public API vs Mobile Applications vs Your Web Apps (e.g. Backbone)

Slide 26

Slide 26 text

Header versioning vs URI versioning

Slide 27

Slide 27 text

Building APIs

Slide 28

Slide 28 text

Grape https://github.com/intridea/grape

Slide 29

Slide 29 text

Grape is a REST-like API micro- framework for Ruby. It is built to complement existing web application frameworks such as Rails and Sinatra by providing a simple DSL to easily provide APIs.

Slide 30

Slide 30 text

Grape is a REST-like API micro- framework for Ruby. It is built to complement existing web application frameworks such as Rails and Sinatra by providing a simple DSL to easily provide APIs.

Slide 31

Slide 31 text

It has built-in support for common conventions such as multiple formats, subdomain/prefix restriction, and versioning.

Slide 32

Slide 32 text

It has built-in support for common conventions such as multiple formats, subdomain/prefix restriction, and versioning.

Slide 33

Slide 33 text

Standardised Error Handling

Slide 34

Slide 34 text

Simple Resource Conversion

Slide 35

Slide 35 text

Minimal Dependencies

Slide 36

Slide 36 text

Rails::API https://github.com/spastorino/rails-api

Slide 37

Slide 37 text

“Rails::API is a subset of a normal Rails application, created for applications that don't require all functionality that a complete Rails application provides.”

Slide 38

Slide 38 text

“Rails::API is a subset of a normal Rails application, created for applications that don't require all functionality that a complete Rails application provides.”

Slide 39

Slide 39 text

Take Rails, Skip what you don’t need.

Slide 40

Slide 40 text

Familiar setup, Similar controllers, No view layer.

Slide 41

Slide 41 text

No cookies, No flash, No sessions, No front end stuff.

Slide 42

Slide 42 text

gem install rails-api rails-api new my_api

Slide 43

Slide 43 text

Rocket Pants https://github.com/filtersquad/rocket_pants

Slide 44

Slide 44 text

Built on Rails like Rails-API, Both released around the same time.

Slide 45

Slide 45 text

RocketPants::Base

Slide 46

Slide 46 text

URI-based versioning

Slide 47

Slide 47 text

Automatic Header Metadata (X-Api-*)

Slide 48

Slide 48 text

HTTP Link Headers

Slide 49

Slide 49 text

Opinionated responses

Slide 50

Slide 50 text

Smart error handling / mapping

Slide 51

Slide 51 text

TL;DR: Consider Grape, Rails::API or Rocket Pants.

Slide 52

Slide 52 text

More Reading: “Designing Hypermedia APIs” by Steve Klabnik The Echonest Developer Documentation For building APIs, API Smith Want to read my versioning argument? See http://discovr.info/2012/05/on-apis-and- versioning/

Slide 53

Slide 53 text

TYVM. Questions? Colour Pallette: “Wasabi Suicide”. http://www.colourlovers.com/palette/482416/Wasabi_Suicide