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

API's and You

API's and You

I recently decided to share the knowledge I have gained over the past year while trying to build an API for the startup I work for.

If you're interested in seeing the next part of the talk, and happen to live in Austin, Texas you should come to the next Laravel Meetup on July 8th. Link here: http://www.meetup.com/Laravel-Austin/

Links within the presentation:
* http://twitter.com/HSkrasek
* https://github.com/fzaninotto/Faker
* http://info.apigee.com/Portals/62317/docs/web%20api.pdf
* https://leanpub.com/build-apis-you-wont-hate

Hunter Skrasek

June 10, 2014

More Decks by Hunter Skrasek

Other Decks in Programming


  1. • API aka Application Programming Interface • Set of HTTP

    Requests in the "Web" world • Made with XML (yuck), or JSON (yay) • Synonymous with a Web Service • Remember SOAP and SOA? No? Good • Moving towards REST

  2. • Let's assume you've already made the database • Or

    we will be here forever • Dummy data for acceptance tests • DO NOT JUST COPY PRODUCTION DATA!!!!
  3. But how do I make these? • Use Faker! •

    Better at BS than college students • https://github.com/fzaninotto/Faker • Break it down into logical groups • Doesn't have to be 1 to 1
  4. Endpoint Planning • What does your API need? • Talk

    to the customers! (Or business) • List all the "Actions" or possible endpoints
  5. Users Posts Projects Create Read Update Delete List Image Posts

    Projects Create Read Update Delete List (category, author) Comments Create Read Update Delete List (category, author) Comments
  6. Endpoint Theory • GET Resources • GET /resources - List

    all resources • GET /resources/X - Get resource X • GET /resources/X,Y,Z - Get resources X, Y, X • GET /resources/X/subresources/Y - Get sub resource Y of resource X
  7. Speaking of SubResources • SubResources vs. Embedded • Either is

    fine, both is better • We will stick with subresources for now
  8. Endpoint Theory • DELETE Resources • DELETE /resources - Delete

    all the things! (Not really) • DELETE /resources/X - Delete resource X • DELETE /resources/X,Y,Z - Delete resources X, Y, X • DELETE /resources/X/subresources/Y - Get sub resource Y of resource X
  9. POST vs. PUT • Long story short.. who cares! •

    Make sure it is consistent. • “Generally speaking, PUT is used if you know the entire URL before hand and the action is idempotent. Idempotent is a fancy word for ‘can do it over and over again without causing different results’.”
  10. Endpoint Theory • Plural vs. Singular • Consistency is key

    • No /users and /user/1 • Example: opportunity becomes opportunities