LofoCats API is a simple API built with Ruby on Rails created for demo purposes. (There's also a simple application consuming it, built with Rails: LofoCats UI).
The API provides endpoints for interacting with a registry of lost and found cats.
GET /api/users Retrieves all users. Requires administrator priviledges.
GET /api/users/:id Retrieves a user. Requires administrator priviledges.
POST /api/users Creates a new user. Requires administrator priviledges.
PUT/PATCH /api/users/:id Updates a user. Requires administrator priviledges.
DELETE /api/users/:id Deletes a user. Requires administrator priviledges.
POST /api/sessions Creates an authentication token to be used for subsequent requests for authorization.
DELETE /api/sessions Deletes the previously authentication token. Requires signed in user.
GET /api/cat_entries Retrieves cat entries. Available for all users.
GET /api/cat_entries/:id Retrieves a cat entry. Available for all users.
POST /api/cat_entries Creates a new cat entry. Only for signed in users.
UPDATE /api/cat_entries/:id Updates a cat entry. Administrators can update all entries, signed in users can update only their own entries. Guests can't update any entry.
DELETE /api/cat_entries/:id Deletes a cat entry. Administrators can delete all entries, signed in users can delete only their own entries. Guests can't delete any entry.
Authentication & Authorization
In order to consume endpoints that require a signed in user (administrator or not) you must first obtain an authentication token by posting to the respective sessions endpoint described above. You have to use this token as the
Authorization header of your requests to the desired endpoints.
Setting up the application
- Clone the repository.
bundle installto install the required gems.
rake db:setupto setup the database.
rake db:load_demo_datato load some demo data to the application.
rails serverto start the application on the default port.
If you loaded the demo data, the following users are available:
The application contains RSpec specs. To run the tests:
- Document request parameters & responses