The API is available at https://photo-library-api.herokuapp.com. Responses are sent as JSON.
The Photo Library API uses HTTP verbs appropriate to each action.
| Verb | Description |
|---|---|
GET |
Retrieving resources. |
POST |
Creating resources. |
PUT |
Updating resources. |
DELETE |
Deleting resources. |
| Endpoint | Description |
|---|---|
/albums |
Handle albums. Authentication required. |
/photos |
Handle photos. Authentication required. |
/login |
Login and Authentication. |
/register |
Register a new user. |
/refresh |
Refresh access token. |
Retrieve a list of all photos belonging to the logged-in user. (authentication required)
GET /photosNone.
Retrieve a single photo by ID. (authentication required)
GET /photos/:photoId| Param | Type | Description |
|---|---|---|
photoId |
integer |
The photo’s ID. Required |
Create a new photo. (authentication required)
POST /photos| Param | Type | Description |
|---|---|---|
title |
string |
The title of the photo. Required |
url |
string |
The url of the photo. Required |
comment |
string |
The description of the photo. Optional |
Update a photo by ID. (authentication required)
PUT /photos/:photoId| Param | Type | Description |
|---|---|---|
photoId |
integer |
The photo’s ID. Required |
title |
string |
The title of the photo. Optional |
url |
string |
The url of the photo. Optional |
comment |
string |
The description of the photo. Optional |
Delete a photo by ID. (authentication required)
DELETE /photos/:photoId| Param | Type | Description |
|---|---|---|
photoId |
integer |
The photo’s ID. Required |
Retrieve a list of all albums belonging to the logged-in user. (authentication required)
GET /albumsNone.
Retrieve a single album by ID. (authentication required)
GET /albums/:albumId| Param | Type | Description |
|---|---|---|
albumId |
integer |
The album’s ID. Required |
Create a new album. (authentication required)
POST /albums/:albumId| Param | Type | Description |
|---|---|---|
title |
string |
The title of the album. Required |
Update an album by ID. (authentication required)
PUT /albums/:albumId| Param | Type | Description |
|---|---|---|
albumId |
integer |
The album’s ID. Required |
title |
string |
The title of the album. Optional |
Delete an album by ID. (authentication required)
DELETE /albums/:albumId| Param | Type | Description |
|---|---|---|
albumId |
integer |
The album’s ID. Required |
Add photo(s) to a specific album. (authentication required)
POST /albums/:albumId/photos| Param | Type | Description |
|---|---|---|
albumId |
integer |
The album’s ID. Required |
photo_id |
integer or array |
The photo’s ID (single or multiple). Required |
Remove photo(s) from a specific album. (authentication required)
DELETE /albums/:albumId/photos| Param | Type | Description |
|---|---|---|
albumId |
integer |
The album’s ID. Required |
photo_id |
integer or array |
The photo’s ID (single or multiple). Required |
Login to retrieve access token.
POST /login| Param | Type | Description |
|---|---|---|
email |
string |
The registered user's email. Required |
password |
string |
The registered user's password. Required |
If successful, the response body will be a JSON representation of the access and refresh token:
{
"status": "success",
"data": {
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7ImlkIjoxLCJlbWFpbCI6InNv",
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7ImlkIjoxLCJlbWFpbCI6InNv"
}
}On future requests, send access token via the HTTP Authorization header:
Authorization: Bearer ACCESS_TOKENUse refresh token to retrieve a new access token.
POST /refresh
Authorization: Bearer REFRESH_TOKENRegister a new user.
POST /register| Param | Type | Description |
|---|---|---|
email |
string |
The new user's email. Required |
password |
string |
The new user's password. Required |
first_name |
string |
The new user's first name. Required |
last_name |
string |
The new user's last name. Required |