[API] Authors
GET /authors
Returns all authors as an array.
Parameters
s: [optional] Searchstring. If provided, returns only those authors whose name match the search term.
Response
200 All found
authors.
500 A server error occured.
Example
Request:
curl http://localhost:8082/api/v1/authors
Result:
[
{
"id": 1,
"forename": "John",
"lastname": "Doe",
"created": 1511968500,
"updated": 1511968500
},
{
"id": 3,
"forename": "Jane",
"lastname": "Doe",
"created": 1507735006,
"updated": 1507746120
},
{
"id": 4,
"forename": "Test",
"lastname": "Author",
"created": 1512639741,
"updated": 1512639741
}
]
GET /authors/:id
Returns a JSON-Object with all informations about a single author.
Parameters
id: The ID
of the author you want to retrieve.
Response
200 The author.
400 ID
is empty.
404 The author does not exist.
500 A server error occured.
PUT /authors
🔒
Creates a new author.
Payload
Expects a JSON author object. Either directly as a JSON-object see the example below
or as a string via the form value author
. When sending as JSON, you need to include the Content-Type: application/json;charset=utf-8
-Header.
Response
200 The author was successfully inserted. Returns the newly created author.
400 No author payload was provided or the title is empty. Returns a more specific message.
500 A server error occured.
Example
Request:
curl \
-H 'Authorization: Bearer <YOUR TOKEN HERE>' \
-X PUT \
-d author='{"forename": "Lorem","lastname": "Ipsum"}' \
http://localhost:8082/api/v1/authors
Response:
{
"id": 2409,
"forename": "Lorem",
"lastname": "Ipsum",
"created": 1512644786,
"updated": 1512644786
}
DELETE /authors/:id
🔒
Deletes a author by its ID
.
Parameters
ID: The ID
of the author you want to delete.
Response
200 The author was successfully deleted.
400 ID
is invalid or empty.
404 No author with this ID
exists.
500 An error occured while deleting.
Example
Request:
curl \
-H 'Authorization: Bearer <YOUR TOKEN HERE>' \
-X DELETE \
http://localhost:8082/api/v1/authors/2409
Response:
{"message":"success"}
POST /authors/:id
🔒
Updates an author by its ID
. Returns the newly updated author.
Parameters
ID: The ID
of the author you want to update.
Payload
Expects a JSON author object see inserting an author
.
Response
200 The author was successfully updated.
400 ID
is empty, invalid or no author with this ID
exists. Returns a more specific message.
500 An error occured while updating.
Example
This example will update only the title.
Request:
curl \
-H 'Authorization: Bearer <YOUR TOKEN HERE>' \
-X POST \
-d author='{"forename": "Test with lorem"}' \
http://localhost:8082/api/v1/authors/110
Response:
{
"id": 110,
"forename": "Test with lorem",
"lastname": "",
"created": 1511968500,
"updated": 1512651628
}