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

Write Better Code Faster with API Data Contracts

Write Better Code Faster with API Data Contracts

by Kris Chant @ APIStrat 2014 in Chicago

More Decks by API Strategy & Practice Conference

Other Decks in Technology

Transcript

  1. Track: Developers #CNX14 Write Better Code Faster with REST Data

    Contracts Kris Chant Sr. Technical Product Manager – API Salesforce ExactTarget Marketing Cloud @sprshrp
  2. Track: Developers #CNX14 What is a REST Data Contract? How

    will we write better code faster? How can I implement them? Goals – Presentation Overview 1 2 3
  3. Track: Developers #CNX14 What is a REST API Data Contract?

    • Not rocket science • Wireframe for API • Defines facts: • URI • Request • Response
  4. Track: Developers #CNX14 Simple Example ## Notes Collection [/notes] ###

    List all Notes [GET] + Response 200 (application/json) [{ "id": 1, "title": "Jogging in park" }, { "id": 2, "title": "Pick-up posters from post-office" }] + Response 401 (application/json) { “message” : “You’re not authorized.” }
  5. Track: Developers #CNX14 Advanced Example ## Note [/notes/{id}] A single

    Note object with all its details + Parameters + id (required, number, `1`) ... Numeric `id` of the Note to perform action with. Has example value. ### Retrieve a Note [GET] + Response 200 (application/json) + Header X-My-Header: The Value + Body { "id": 2, "title": "Pick-up posters from post-office" } ### Remove a Note [DELETE] + Response 204
  6. Track: Developers #CNX14 How can I use them? • Pre-requisite to

    development • Schedule time • API Design Tools • API Blueprint - Apiary • RAML – MuleSoft