You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
2.4 KiB

# HTTP API documentation
## Get specific quote
```HTTP
GET /quotes/:id
```
```BASH
curl --request GET 'https://tld.example/api/quotes/28'
```
Example response:
```JSON
{
"id": 28,
"video_id": 0,
"date": "2018-01-01",
"game": "IRL",
"text": "Cheese?",
"created_at": "2018-01-01T00:00:00",
"updated_at": "2018-01-01T00:00:00"
}
```
## Get list of quotes
```HTTP
GET /quotes
```
```BASH
curl --request GET --data 'https://tld.example/api/quotes?filter=cheese&sort_by=date&sort_order=asc'
```
*Note: `X-Total-Count` header is set to a total number of quotes after filtering (useful for pagination)*
Example response:
```JSON
[
{
"id": 28,
"video_id": 0,
"date": "2018-01-01",
"game": "IRL",
"text": "Cheese?",
"created_at": "2018-01-01T00:00:00",
"updated_at": "2018-01-01T00:00:00"
},
{
"id": 42,
"video_id": 0,
"date": "2018-02-02",
"game": "IRL",
"text": "Cheese!",
"created_at": "2018-02-02T00:00:00",
"updated_at": "2018-02-02T00:00:00"
}
]
```
Parameters:
* `filter` (optional) - Filter string
* `sort_by` (optional) - Sort field, `id`, `date`, `game` or `text`
* `sort_order` (optional) - Sort order, `asc` or `desc`
* `page_number` (optional) - Page number to retrieve
* `page_size` (optional) - Number of quotes per page
## Create quote
```HTTP
POST /quotes
```
```BASH
curl --request POST --header 'X-Quotes-API-Key: SECRET_KEY' --data 'id=28&date=2018-01-01&game=IRL&text=Cheese?' 'https://tld.example/api/quotes'
```
*Note: the quote is replaced if it exists already*
Parameters:
* `id` (required) - Quote ID
* `date` (required) - Date in ISO 8601 format
* `game` (required) - Related game
* `text` (required) - Text of the quote
* `video_id` (optional) - Twitch video ID
## Replace specific quote
```HTTP
PUT /quotes/:id
```
```BASH
curl --request PUT --header 'X-Quotes-API-Key: SECRET_KEY' --data 'date=2018-01-01&game=IRL&text=Cheese?' 'https://tld.example/api/quotes/28'
```
*Note: the quote is created if it doesn't exist yet*
Parameters:
* `date` (required) - Date in ISO 8601 format
* `game` (required) - Related game
* `text` (required) - Text of the quote
* `video_id` (optional) - Twitch video ID
## Delete specific quote
```HTTP
DELETE /quotes/:id
```
```BASH
curl --request DELETE --header 'X-Quotes-API-Key: SECRET_KEY' 'https://tld.example/api/quotes/28'
```