Skip to content

Instantly share code, notes, and snippets.

@tunglam14
Last active October 3, 2016 09:16
Show Gist options
  • Save tunglam14/3a7fba66c66bc8f683851acf70a8de6b to your computer and use it in GitHub Desktop.
Save tunglam14/3a7fba66c66bc8f683851acf70a8de6b to your computer and use it in GitHub Desktop.

User API

User attributes:

- id `(Number)` : unique identifier.
- fname `(String)` : First Name.
- lname `(String)` : Last Name.
- email `(String)` : email id of the user.

Common responses:

- 401
```json
    {
      "error": "error.unauthorized"
    }
```

- 500
```json
    {
      "error": "error.internalserver"
    }
```

- xxx
```json
    {
      "error": "error.xxxxx"
    }
```

Authentication:

  • Describing api authentication

List all users [GET /users]

Retrieve paginated list of users.

  • Parameters:

    • since (optional, String) ... Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ Only users updated at or after this time are returned.
    • limit (optional, Number) ... maximum number of records expected by client.
  • Request (application/json)

  • Response 200 (application/json)

    [
      {
        "id": 1,
        "fname": "Pandurang",
        "lname": "Patil",
        "email": "[email protected]"
      },
      {
        "id": 2,
        "fname": "Sangram",
        "lname": "Shinde",
        "email": "[email protected]"
      }
    ]

Create a User [POST /users/{id}]

  • Request (application/json)
    {
      "fname": "Ram",
      "lname": "Jadhav",
      "email": "[email protected]"
    }
  • Response 201 (application/json)
    {
      "id": 3,
      "fname": "Ram",
      "lname": "Jadhav",
      "email": "[email protected]"
    }

Retrieve a User [GET /users/{id}]

  • Response 200 (application/json)
    • Header:

      • X-My-Header: The Value
    • Body

      {
        "id": 1,
        "fname": "Pandurang",
        "lname": "Patil",
        "email": "[email protected]"
      }

Update a User [POST /users/{id}]

Update user details

  • Request (application/json)
    {
      "id": 1,
      "fname": "Pandurang",
      "lname": "Patil",
      "email": "[email protected]"
    }
  • Response 200 (application/json)
    {
      "id": 1,
      "fname": "Pandurang",
      "lname": "Patil",
      "email": "[email protected]"
    }

Remove a User [DELETE /users/{id}]

  • Response 204
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment