Skip to content

Instantly share code, notes, and snippets.

@jesseschutt
Forked from sixlive/gistlog.yml
Last active August 24, 2017 17:48
Show Gist options
  • Save jesseschutt/a446c3f66ee30f54de82f2af5d05fd3f to your computer and use it in GitHub Desktop.
Save jesseschutt/a446c3f66ee30f54de82f2af5d05fd3f to your computer and use it in GitHub Desktop.
My API Response "Standard"

Status Codes

Code Meaning
200 All good!
201 Resource created
302 You were redirected
400 The request was unacceptable (you screwed up)
403 You are not authorized to access the resource
401 You are not authorized
404 Requested resource not found
422 Validation failed (you screwed up)
429 Too many requests hit the API too quickly.
500, 502, 503, 504 Server Errors (we screwed up)

Responses

Error

{
  "errors": {
    "url": [
      "The url field is required"
    ],
    "email": [
      "The email field is required"
    ]
  }
  "message": "The provided data is invalid."
}

Single Resource

example.com/resources/{id}

{
  "data": {
    "foo": "bar",
    "biz": {
      "baz": "buz"
    }
  },
  "meta": {}
}

Collection Resource (paginated)

example.com/resources?page=2

{
  "data": [
    { 
      "foo": "bar",
      "biz": {
        "baz": "bar"
      }
    },
    { 
      "foo": "qux",
      "biz": {
        "baz": "foo"
      }
    }
  ],
  "meta": {
    "pagination": {
      "count": 15,
      "current_page": 2,
      "links": {
        "next": "http://resources.dev/page?page=2"
      },
      "per_page": 2,
      "total": 61,
      "total_pages": 5
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment