Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Crafting REST APIs Mobile Devs Will Love

matto1990
December 09, 2015

Crafting REST APIs Mobile Devs Will Love

This talk will cover best practices for creating REST APIs that don't make mobile developers want to cry.

We'll start with an overview of what it means to create a RESTful API, and then go through some best practices on encryption and versioning. We'll then show how your documentation can be used to validate input and test the responses your API gives, meaning the documentation becomes the source of truth for the API. No more outdated documentation and frustrated developers!

Matt is a developer at ribot who has worked on Android, iOS and API servers.

matto1990

December 09, 2015
Tweet

More Decks by matto1990

Other Decks in Technology

Transcript

  1. HTTP Verbs • GET • Gets resource • POST •

    Create a new resource • PUT • Update a resource • PATCH • Update part of a resource • DELETE • Deletes a resource
  2. Resource URIs • GET /games • Retrieves a collection of

    games • GET /games/11 • Retrieves a specific game • POST /games • Creates a new game • DELETE /games/11 • Deletes game #11 • PUT /games/11 • Updates game #11 • PATCH /games/11 • Partially updates game #11
  3. Sub-resources • GET /games/11/rounds • Retrieves collection of rounds for

    game #11 • GET /games/11/rounds/4 • Retrieves round #4 for game #11 • POST /games/11/rounds • Creates a new round in game #11
  4. HTTP Status Codes • 200 OK • Response was successful

    • 201 Created • Response to a POST that results in a creation • 204 No Content • Response to a successful request that won't be returning a body (like a DELETE request) • 400 Bad Request • The request is malformed, such as if the body does not parse or there are validation errors • 404 Not Found • When a non-existent resource is requested • 401 Unauthorized • When no or invalid authentication details are provided • 403 Forbidden • When authentication succeeded but authenticated user doesn't have access to the resource
  5. HTTPS Is Not Enough Secure certificate & correct server settings

    Test at: http://j.mp/ssllabtest Documentation at: http://j.mp/ssllabsdocs
  6. Request & Response Format • Exactly what you expect in

    • What property name? • Which properties are required? • What types are they? • Exactly what you’ll send back • What are the property names? • Which ones may not be sent back (and why)? • What types are they?
  7. API Blueprint A language and set of tools to describe

    your API https://apiblueprint.org/