Rest for the Web!
The new buzzword in town

Nitesh Oswal
www.niteshoswal.me
APIs: What & Why?
What is an API?
Application Programming Interface
An API is the interface implemented by
an application which allows us to
communicate with it.
What is REST?
REpresentational State Transfer
●

Architectural Style

●

Not a standard, unlike SOAP

●

Modern best practice

●

Developed closely with HTTP 1.1
Constraints
●

Client – Server Independance

●

Stateless

●

Cacheable

●

Layered System

●

Code in demand

●

Uniform Interface
Examples
●

Twitter

●

Dropbox

●

Instagram

●

Github

●

Paypal

●

Soundcloud

●

Google+

●

...
Trends

Source: http://blog.programmableweb.com/2011/03/08/3000-web-apis/
3,000 Web APIs: Trends From a Quickly Growing Directory
REST APIs: ?
Any API which conforms with the REST
constraints for data transfer is called a
REST API!
Top 3 Qualities
●

Intuitive
–

●

No surprises, easy to learn

Documented
–
–

●

Simple answers to simple questions
References, tutorials & quick start guides

Opinionated
–

CamelCase, ids, responses, paginated etc.
Resources,
Representations,
Metadata
Resource
●

Nouns not verbs

●

Could be any information

●

They tell you what they ‘are’
Representation
●

Sequence of bytes

●

Described by representation metadata

●

Less precisely, a document, an entity, or an
instance
Embrace HTTP
●

GET, POST, PUT, PATCH, DELETE

●

Explorable with simple tools
Embrace HTTP
GET /document
GET /document/1
POST /document
PUT /document/1
DELETE /document/1

Retrieve all documents
Retrieve a specific
document #1
Create a new document
Update an existing
document #1
Delete an existing
document #1
Example
Best Practices
security

Https!

base URLs

api.mycompany.com

serialization

json

timestamps

ISO 8601 & UTC

caching

Etag & Last modified

gzip

Always & pretty print responses

versioning

/v1/ OR /v1.1/
Questions?
Thank you

REST for the Web!