This example JSON responds in accordance with the JSON API 1.0 specification
Available endpoints:
Based on the :id
value passed to the token endpoint you will receive 1 of 3 results, people
, books
or an error.
{
"jsonapi": {
"version": "1.0"
},
"links": {
"self": "http://example.com/v1/tokens/04b42572373080/",
"related": "http://example.com/v1/people/1/"
},
"data": {
"type": "people",
"id": "1",
"attributes": {
"firstname": "Matt",
"lastname": "Rayner",
"email": "matthew.rayner@example.com"
}
},
"relationships": {
"checked_out_books": {
"data": [
{
"type": "books",
"id": "1"
},
{
"type": "books",
"id": "2"
}
]
},
"tokens": {
"data": [
{
"type": "tokens",
"id": "04b42572373080"
}
]
}
},
"included": [
{
"type": "books",
"id": "1",
"attributes": {
"title": "The Will-grounded Rubyist",
"author": "David A. Black",
"year": "2009",
"thumbnail": "http://books.google.co.uk/books/content?id=igPTngEACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api",
"isbn": "1617291692",
"google_books_id": "igPTngEACAAJ"
},
"links": {
"self": "http://example.com/v1/books/1/"
}
},
{
"type": "books",
"id": "2",
"attributes": {
"title": "The Ruby Way",
"author": "Hal Fulton",
"year": "2002",
"thumbnail": "http://books.google.co.uk/books/content?id=ows9jTsyaaEC&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api",
"isbn": "0672320835",
"google_books_id": "ows9jTsyaaEC"
},
"links": {
"self": "http://example.com/v1/books/2/"
}
},
{
"type": "tokens",
"id": "04b42572373080",
"attributes": {
"type": "people",
"foreign_key": "1"
},
"links": {
"self": "http://example.com/v1/tokens/04b42572373080/"
}
}
]
}
{
"jsonapi": {
"version": "1.0"
},
"links": {
"self": "http://example.com/v1/tokens/04a42572373080/",
"related": "http://example.com/v1/books/1/"
},
"data": {
"type": "books",
"id": "1",
"attributes": {
"title": "The Will-grounded Rubyist",
"author": "David A. Black",
"year": "2009",
"thumbnail": "http://books.google.co.uk/books/content?id=igPTngEACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api",
"isbn": "1617291692",
"google_books_id": "igPTngEACAAJ"
}
},
"relationships": {
"checked_out_by": {
"data": [
{
"type": "people",
"id": "1"
}
]
},
"tokens": {
"data": [
{
"type": "tokens",
"id": "04a42572373080"
},
{
"type": "tokens",
"id": "04d42572373080"
}
]
}
},
"included": [
{
"type": "people",
"id": "1",
"attributes": {
"firstname": "Matt",
"lastname": "Rayner",
"email": "matthew.rayner@example.com"
},
"links": {
"self": "http://example.com/v1/people/1/"
}
},
{
"type": "tokens",
"id": "04a42572373080",
"attributes": {
"type": "books",
"foreign_key": "1"
},
"links": {
"self": "http://example.com/v1/tokens/04a42572373080/"
}
},
{
"type": "tokens",
"id": "04d42572373080",
"attributes": {
"type": "books",
"foreign_key": "1"
},
"links": {
"self": "http://example.com/v1/tokens/04d42572373080/"
}
}
]
}
{
"jsonapi": {
"version": "1.0"
},
"links": {
"self": "http://example.com/v1/tokens/1234/"
},
"errors": [
{
"status": "404",
"title": "Token not found",
"details": "The token passed could not be found",
"code": "404-T"
}
]
}
This POST endpoint takes the following data:
{
"book_token_id": "04a42572373080",
"person_token_id": "04b42572373080"
}
And will respond with 1 of 2 responses:
{
"jsonapi": {
"version": "1.0"
},
"links": {
"self": "http://example.com/v1/checkouts/"
},
"data": {
"type": "checkouts",
"id": "1",
"attributes": {
"book_token_id": "04a42572373080",
"person_token_id": "04b42572373080",
"returned_at": null,
"created_at": "2016-03-14 17:32:16"
}
},
"relationships": {
"tokens": {
"data": [
{
"type": "tokens",
"id": "04a42572373080"
},
{
"type": "tokens",
"id": "04b42572373080"
}
]
},
"books": {
"data": [
{
"type": "books",
"id": "1"
}
]
},
"people": {
"data": [
{
"type": "people",
"id": "1"
}
]
}
},
"included": [
{
"type": "tokens",
"id": "04a42572373080",
"attributes": {
"type": "books",
"foreign_key": "1"
},
"links": {
"self": "http://example.com/v1/tokens/04a42572373080/"
}
},
{
"type": "tokens",
"id": "04b42572373080",
"attributes": {
"type": "people",
"foreign_key": "1"
},
"links": {
"self": "http://example.com/v1/tokens/04b42572373080/"
}
},
{
"type": "books",
"id": "1",
"attributes": {
"title": "The Will-grounded Rubyist",
"author": "David A. Black",
"year": "2009",
"thumbnail": "http://books.google.co.uk/books/content?id=igPTngEACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api",
"isbn": "1617291692",
"google_books_id": "igPTngEACAAJ"
},
"links": {
"self": "http://example.com/v1/books/1/"
}
},
{
"type": "people",
"id": "1",
"attributes": {
"firstname": "Matt",
"lastname": "Rayner",
"email": "matthew.rayner@example.com"
},
"links": {
"self": "http://example.com/v1/people/1/"
}
}
]
}
{
"jsonapi": {
"version": "1.0"
},
"links": {
"self": "http://example.com/v1/checkouts/"
},
"errors": [
{
"status": "404",
"title": "Book not found",
"details": "The book passed could not be found",
"code": "404-B"
},
{
"status": "404",
"title": "Person not found",
"details": "The person passed could not be found",
"code": "404-P"
},
{
"status": "400",
"title": "Book already checked-out",
"details": "The book passed has already been checked out",
"code": "401-CO"
}
]
}
This POST endpoint takes the following data:
{
"book_token_id": "04a42572373080"
}
and will respond with 1 of 2 results:
{
"jsonapi": {
"version": "1.0"
},
"links": {
"self": "http://example.com/v1/returns/"
},
"data": {
"type": "checkouts",
"id": "1",
"attributes": {
"book_token_id": "04a42572373080",
"person_token_id": "04b42572373080",
"returned_at": "2016-03-14 18:58:53",
"created_at": "2016-03-14 17:32:16"
}
},
"relationships": {
"tokens": {
"data": [
{
"type": "tokens",
"id": "04a42572373080"
},
{
"type": "tokens",
"id": "04b42572373080"
}
]
},
"books": {
"data": [
{
"type": "books",
"id": "1"
}
]
},
"people": {
"data": [
{
"type": "people",
"id": "1"
}
]
}
},
"included": [
{
"type": "tokens",
"id": "04a42572373080",
"attributes": {
"type": "books",
"foreign_key": "1"
},
"links": {
"self": "http://example.com/v1/tokens/04a42572373080/"
}
},
{
"type": "tokens",
"id": "04b42572373080",
"attributes": {
"type": "people",
"foreign_key": "1"
},
"links": {
"self": "http://example.com/v1/tokens/04b42572373080/"
}
},
{
"type": "books",
"id": "1",
"attributes": {
"title": "The Will-grounded Rubyist",
"author": "David A. Black",
"year": "2009",
"thumbnail": "http://books.google.co.uk/books/content?id=igPTngEACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api",
"isbn": "1617291692",
"google_books_id": "igPTngEACAAJ"
},
"links": {
"self": "http://example.com/v1/books/1/"
}
},
{
"type": "people",
"id": "1",
"attributes": {
"firstname": "Matt",
"lastname": "Rayner",
"email": "matthew.rayner@example.com"
},
"links": {
"self": "http://example.com/v1/people/1/"
}
}
]
}
{
"jsonapi": {
"version": "1.0"
},
"links": {
"self": "http://example.com/v1/returns/"
},
"errors": [
{
"status": "404",
"title": "Book not found",
"details": "The book passed could not be found",
"code": "404-B"
},
{
"status": "400",
"title": "Book already returned",
"details": "The book passed has already been checked out",
"code": "400-RA"
},
{
"status": "400",
"title": "Book not checked-out",
"details": "The book passed is not checked-out",
"code": "400-RN"
}
]
}
This endpoint takes the following data:
{
"title": "The Will-grounded Rubyist",
"author": "David A. Black",
"year": "2009",
"thumbnail": "http://books.google.co.uk/books/content?id=igPTngEACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api",
"isbn": "1617291692",
"google_books_id": "igPTngEACAAJ"
}
NOTE: title
, author
and year
are the only required attributes
{
"jsonapi": {
"version": "1.0"
},
"links": {
"self": "http://example.com/v1/books/1/"
},
"data": {
"type": "books",
"id": "1",
"attributes": {
"title": "The Will-grounded Rubyist",
"author": "David A. Black",
"year": "2009",
"thumbnail": "http://books.google.co.uk/books/content?id=igPTngEACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api",
"isbn": "1617291692",
"google_books_id": "igPTngEACAAJ"
}
},
"relationships": {
"checked_out_by": {
"data": [
{
"type": "people",
"id": "1"
}
]
},
"tokens": {
"data": [
{
"type": "tokens",
"id": "04a42572373080"
},
{
"type": "tokens",
"id": "04d42572373080"
}
]
}
},
"included": [
{
"type": "people",
"id": "1",
"attributes": {
"firstname": "Matt",
"lastname": "Rayner",
"email": "matthew.rayner@example.com"
},
"links": {
"self": "http://example.com/v1/people/1/"
}
},
{
"type": "tokens",
"id": "04a42572373080",
"attributes": {
"type": "books",
"foreign_key": "1"
},
"links": {
"self": "http://example.com/v1/tokens/04a42572373080/"
}
},
{
"type": "tokens",
"id": "04d42572373080",
"attributes": {
"type": "books",
"foreign_key": "1"
},
"links": {
"self": "http://example.com/v1/tokens/04d42572373080/"
}
}
]
}
This endpoint takes the following data:
{
"firstname": "Matt",
"lastname": "Rayner",
"email": "matthew.rayner@example.com"
}