lets-talk-apis



lets-talk-apis

0 0


lets-talk-apis


On Github atomaka / lets-talk-apis

Let's Talk APIs

Well...RESTful ones anyway

Andrew Tomaka / @atomaka

What is an API?

  • Application
  • Programming
  • Interface

Let other people use your stuff!

API Documentation

What is RESTful?

  • REpresentational
  • State
  • Transfer

Constraints to create consistent APIs

REST Constraints

  • Client-server
  • Stateless
  • Cacheable
  • Layered System
  • Code on demand
  • Uniform interface
Code on demand: Servers can temporarily extend or customize the functionality of a client by the transfer of executable code.

REST on the Web

  • Take a base URI
  • Pick a data type (JSON, XML, Atom, etc)
  • Use standard HTTP methods
    • GET, PUT, POST, DELETE, (and PATCH)
  • Use standard HTTP response codes
    • 200 OK, 204 No Content, 404 Not Found

A RESTful Example

Simple example

  • List: GET /jokes
  • Create: POST /jokes
  • Show: GET /jokes/1
  • Update: PUT /jokes/1
  • Delete: DELETE /jokes/1
curl http://lets-talk-apis.herokuapp.com/jokes curl -X POST --data 'joke[joke]=Why did the chicken get to the other side&joke[punchline]=To get to the other side' http://lets-talk-apis.herokuapp.com/jokes curl -X PUT --data 'joke[joke]=New Joke&joke[punchline]=Punchline' http://lets-talk-apis.herokuapp.com/jokes/1 curl -X DELETE http://lets-talk-apis.herokuapp.com/jokes/1

Sample Code

Resources

Other Talks

Let's Talk APIs Well...RESTful ones anyway Andrew Tomaka / @atomaka