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

Fun with Options

Keith Casey
September 13, 2012

Fun with Options

At RESTfest 2012, I presented a talk on how to use and (potentially!) abuse the HTTP verb OPTIONS to interrogate API endpoints to retrieve additional information. You can see the video here:
https://vimeo.com/channels/restfest/49613738

Remember: This was written and presented before Swagger/OpenAPI was really a thing.

Keith Casey

September 13, 2012
Tweet

More Decks by Keith Casey

Other Decks in Programming

Transcript

  1. 5 in 5: Fun with OPTIONS D. Keith Casey, Jr.

    Developer Evangelist, Twilio
  2. Keith Casey - Twilio - RESTfest Problem: Docs Suck •

    Usually out of date • Always out of band • Verbs leak implementation details • An API is a user interface too • http://www.twilio.com/engineering/2011/10/31/apis-are-for-human-beings
  3. Keith Casey - Twilio - RESTfest Examples • curl -X

    GET http://localhost/web2project-slim/companies/1 -v | python -m json.too • curl -X GET http://localhost/web2project-slim/projects/ -v | python -m json.tool • curl -X GET http://localhost/web2project-slim/projects/270 -v | python -m json.tool • curl -X GET 'http://localhost/web2project-slim/projects/270/tasks' -v | python -m json.tool • curl -X OPTIONS http://localhost/web2project-slim/ -v | python -m json.tool • curl -X POST 'http://localhost/web2project-slim/links' -d 'link_name=monkey&link_owner=2' -v | python -m json.tool
  4. Keith Casey - Twilio - RESTfest Next Steps • “Proper”

    structure (headers, media types: collection+json, etc) • Document datatypes, validation rules/code • Stu’s Higher order actions - recipes/formulas • Implement for Twilio - constrained vocabulary: phone numbers, urls, id’s (160 bytes), friendly names, methods, area code, status, datetime, others