6 API Publishers
kolaente edited this page 2018-01-29 16:00:23 +01:00

[API] Publishers

GET /publishers

Returns all publishers as a JSOn array.

Parameters

s: [optional] Searchstring. If provided, returns only those publishers whose name match the search term.

Response

200 All found publishers.
500 A server error occured.

Example

Request:

curl http://localhost:8082/api/v1/publishers

Result:

[
  {
    "id": 1,
    "name": "møtus",
    "created": 0,
    "updated": 1511968730
  },
  {
    "id": 16,
    "name": "Fantasy Publishing Ltd.",
    "created": 1507747610,
    "updated": 1507747610
  },
  {
    "id": 130,
    "name": "Lorem",
    "created": 1512480155,
    "updated": 1512480155
  }
]

GET /publishers/:id

Returns a JSON-Object with all informations about a single publisher.

Parameters

id: The ID of the publisher you want to retrieve.

Response

200 The publisher.
400 ID is invalid or empty.
404 The publisher does not exist.
500 A server error occured.


PUT /publishers 🔒

Creates a new publisher.

Payload

Expects a JSON publisher object. Either directly as a JSON-object see the example below or as a string via the form value publisher. When sending as JSON, you need to include the Content-Type: application/json;charset=utf-8-Header.

Response

200 The publisher was successfully inserted. Returns the newly created publisher.
400 No publisher 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 publisher='{"forename": "Lorem","lastname": "Ipsum"}' \
http://localhost:8082/api/v1/publishers

Response:

{
  "id": 2409,
  "forename": "Lorem",
  "lastname": "Ipsum",
  "created": 1512644786,
  "updated": 1512644786
}

DELETE /publishers/:id 🔒

Deletes a publisher by its ID.

Parameters

ID: The ID of the publisher you want to delete.

Response

200 The publisher was successfully deleted.
400 ID is invalid or empty.
404 No publisher 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/publishers/2409

Response:

{"message":"success"}

POST /publishers/:id 🔒

Updates an publisher by its ID. Returns the newly updated publisher.

Parameters

ID: The ID of the publisher you want to update.

Payload

Expects a JSON publisher object see inserting an publisher.

Response

200 The publisher was successfully updated.
400 Publisher payload is empty, not valid or ID is invalid.
404 No publisher with this ID exists.
500 An error occured while updating.

Example

Request:

curl \ 
-H 'Authorization: Bearer <YOUR TOKEN HERE>' \
-X POST \
-d publisher='{"name": "Lorem Impsum"}' \
http://localhost:8082/api/v1/publishers/130

Response:

{
  "id": 130,
  "name": "Lorem Impsum",
  "created": 1512480155,
  "updated": 1512651507
}