Designing mobile APIs

Designing mobile APIs

7a0e72a6f55811246bb5d9a946fd2e49?s=128

Radoslav Stankov

November 30, 2013
Tweet

Transcript

  1. 3.
  2. 5.
  3. 8.
  4. 11.
  5. 32.
  6. 40.

    HTTP Statuses Code Description 400 Bad Request 401 Unauthorized 402

    Account Is Locked 404 Not Found 405 Method Not Allowed 422 Unprocessable Entity 426 To Many Requests 500 Internal Server Error
  7. 43.

    422 - Unprocessable Entity { “errors”: {
 “name”: [“Already taken”],

    “budget”: [“Must be more than 0”] } } POST https://mobile.fantasy-football.com/teams/
  8. 50.
  9. 54.

    Tokens Method URL Description POST /token Create new token
 (with

    login credentials) DELETE /token Delete token HEAD /token Check if token is active PATCH /token Renew a token (if tokens can expire)
  10. 57.
  11. 58.

    Teams Method URL Description GET /my/teams Returns all teams POST

    /my/teams Create new team GET /my/teams/1 Return given team PATCH /my/teams/1 Update given team DELETE /my/teams/1 Delete given team
  12. 59.

    {
 “id”: 1, “name”: “Real Blagoevgrad”,
 “players”: { /* players

    */ } } POST /my/teams Accept: application/vnd.fantasy-football.com; version=1,application/json
 Authentication: Token token=“0BD8AF0AAB86619” X-Api-Key: “7C1100AD4A6D45A6B2E022B”
  13. 60.

    {
 “id”: 1, “name”: “Real Blagoevgrad”,
 “players”: { /* players

    */ } } GET /my/teams/1 Accept: application/vnd.fantasy-football.com; version=1,application/json
 Authentication: Token token=“0BD8AF0AAB86619” X-Api-Key: “7C1100AD4A6D45A6B2E022B”
  14. 61.

    {
 “id”: 1, “name”: “Bayern Blagoevgrad”,
 “players”: { /* players

    */ } } PATCH /my/teams/1 Accept: application/vnd.fantasy-football.com; version=1,application/json
 Authentication: Token token=“0BD8AF0AAB86619” X-Api-Key: “7C1100AD4A6D45A6B2E022B”
  15. 62.

    GET /teams Accept: application/vnd.fantasy-football.com; version=1,application/json
 Authentication: Token token=“0BD8AF0AAB86619” X-Api-Key: “7C1100AD4A6D45A6B2E022B”

    [{
 “id”: 1, “name”: “Bayern Blagoevgrad”,
 “owner”: { /* owner */ },
 “players”: { /* players */ }, }, { /* other team */ }]
  16. 67.