Skip to content

Instantly share code, notes, and snippets.

@schroedermatt
Last active June 12, 2017 19:57
Show Gist options
  • Save schroedermatt/80201286e1dd55bf12d3c438bd317720 to your computer and use it in GitHub Desktop.
Save schroedermatt/80201286e1dd55bf12d3c438bd317720 to your computer and use it in GitHub Desktop.
Example API Blueprint for apiary.

FORMAT: 1A HOST: http://farmanimals.apiblueprint.org/

Animals API

Animals is a simple API allowing consumers to view information about the animals on a farm.

Animals Collection [/animals{?type}]

List All Animals [GET]

Retrieve a list of all farm animals. Provide a type filter to pull out only animals of that type.

  • Response 200 (application/json)

      [
          {
              "id": "1",
              "type": "Pig",
              "birth-date": "2015-08-05T08:40:51.620Z",
              "name": "Pinky"
          },
          {
              "id": "6",
              "type": "Duck",
              "birth-date": "2016-08-05T08:40:51.620Z",
              "name": "Donald"
          }
      ]
    

Create a New Animal [POST]

You may create your own animal using this action. It takes a JSON object containing an animal.

  • Request (application/json)

      {
          "type": "Pig",
          "birth-date": "2017-04-05T08:40:51.620Z",
          "name": "Alphy"
      }
    
  • Response 201 (application/json)

    • Headers

        Location: /animals/6
      
    • Body

        {
            "id": "6",
            "type": "Pig",
            "birth-date": "2017-04-05T08:40:51.620Z",
            "name": "Alphy"
        }
      
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment