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

JSON API

JSON API

Introduction to JSON API - a talk I gave at RubyDay 2015.

Marco Otte-Witte

November 13, 2015
Tweet

More Decks by Marco Otte-Witte

Other Decks in Technology

Transcript

  1. GET /articles/1 { "data": { "type": "articles", "id": "1", "attributes":

    { "title": "JSON API paints my bikeshed!" } } }
  2. GET /articles { "data": [ { "type": "articles", "id": "1",

    "attributes": { "title": "JSON API paints my bikeshed!" } }, { "type": "articles", "id": "2", "attributes": { "title": "Rails is Omakase" } } ] }
  3. GET /articles/1 { "data": { "type": "articles", "id": "1", "attributes":

    { "title": "JSON API paints my bikeshed!" }, "relationships": { "author": { "data": { "type": "people", "id": "1" } } } } }
  4. GET /articles/1 { "data": { "type": "articles", "id": "1", "attributes":

    { "title": "JSON API paints my bikeshed!" }, "relationships": { "author": { "links": { "self": "/articles/1/relationships/author", "related": "/articles/1/author" } } } } }
  5. GET /articles/1 { "data": { "type": "articles", "id": "1", "attributes":

    { "title": "JSON API paints my bikeshed!" }, "relationships": { "author": { "data": { "type": "people", "id": "1" } } } }, "included": [{ "type": "people", "id": "1", "attributes": { "name": "Dan Gebhard" } }] }
  6. HTTP/1.1 201 Created Location: http://example.com/articles/1 { "data": { "type": "articles",

    "id": "1", "attributes": { "title": "JSON API paints my bikeshed!" } } }
  7. PATCH /articles/1 { "data": { "type": "articles", "id": "1", "attributes":

    { "title": "json:api paints my bikeshed!" } } }
  8. POST /articles { "data": [{ "type": "articles", "attributes": { "title":

    "JSON API paints my bikeshed!" } }, { "type": "articles", "attributes": { "title": "Rails is Omakase" } }] }
  9. HTTP/1.1 201 Created { "data": [{ "type": "articles", "id": "1",

    "attributes": { "title": "JSON API paints my bikeshed!" } },{ "type": "articles", "id": "2", "attributes": { "title": "Rails is Omakase" } }] }