Rocket Fortune
API Organization
This service, in addition to the human-readable frontend, has an API which exposes 3 endpoints:
- GET /json, which returns a JSON object representing a random quote
- GET /json/all, which returns a list of JSON objects representing all known quotes
- POST /json/add, which accepts a JSON object representing a single quote and adds it to the database
JSON Representations
The JSON representation of a quote is very straightforward. It contains three keys:
- "quote", which contains the text of the quote
- "author", which contains text representing the author to whom the quote is attributed
- "source", which contains either text representing a citation, like a URI or book title, or null
Sample curl Commands
curl
is a convenient tool for interacting with APIs. This command
would add a quote to the database, for instance:
curl -i -X POST -H 'Content-Type: application/json' -d '{"quote":"A Quote with a Source", "author":"Author M. Name", "source":"ISBN: 31337000000"}' http://localhost:8000/json/add