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.
115 lines
2.5 KiB
115 lines
2.5 KiB
7 years ago
|
# HTTP API documentation
|
||
7 years ago
|
|
||
|
## Get specific quote
|
||
|
|
||
|
```HTTP
|
||
|
GET /quotes/:id
|
||
|
```
|
||
|
|
||
|
```BASH
|
||
7 years ago
|
curl --request GET 'https://ladylilia.com/quotes/api/quotes/28'
|
||
7 years ago
|
```
|
||
|
|
||
|
Example response:
|
||
|
|
||
|
```JSON
|
||
|
{
|
||
|
"id": 28,
|
||
7 years ago
|
"date": "2017-10-16",
|
||
|
"game": "Call of Cthulhu: Shadow of the Comet",
|
||
|
"text": "Hey, nerd. Sit down so I can have speaks with you.",
|
||
|
"created_at": "2018-04-29T20:00:00",
|
||
|
"updated_at": "2018-04-29T20:00:00"
|
||
7 years ago
|
}
|
||
|
```
|
||
|
|
||
|
## Get list of quotes
|
||
|
|
||
|
```HTTP
|
||
|
GET /quotes
|
||
|
```
|
||
|
|
||
|
```BASH
|
||
7 years ago
|
curl --request GET --data 'https://ladylilia.com/quotes/api/quotes?filter=balls&sort_by=date&sort_order=asc'
|
||
7 years ago
|
```
|
||
|
|
||
7 years ago
|
*Note: `X-Total-Count` header is set to a total number of quotes after filtering (useful for pagination)*
|
||
|
|
||
7 years ago
|
Example response:
|
||
|
|
||
|
```JSON
|
||
|
[
|
||
|
{
|
||
7 years ago
|
"id": 6,
|
||
|
"date": "2017-10-10",
|
||
|
"game": "The Elder Scrolls IV: Oblivion",
|
||
|
"text": "Being a vampire in Oblivion sucks balls.",
|
||
|
"created_at": "2018-04-29T20:00:00",
|
||
|
"updated_at": "2018-04-29T20:00:00"
|
||
7 years ago
|
},
|
||
|
{
|
||
7 years ago
|
"id": 25,
|
||
|
"date": "2017-10-12",
|
||
|
"game": "Alien: Isolation",
|
||
|
"text": "Holy balls!",
|
||
|
"created_at": "2018-04-29T20:00:00",
|
||
|
"updated_at": "2018-04-29T20:00:00"
|
||
7 years ago
|
}
|
||
|
]
|
||
|
```
|
||
|
|
||
|
Parameters:
|
||
|
|
||
|
* `filter` (optional) - Filter string
|
||
7 years ago
|
* `sort_by` (optional) - Sort field, one of `id`, `date`, `game`, `text`
|
||
|
* `sort_order` (optional) - Sort order, one of `asc`, `desc`, `random`
|
||
7 years ago
|
* `page_number` (optional) - Page number to retrieve
|
||
|
* `page_size` (optional) - Number of quotes per page
|
||
|
|
||
|
## Create quote
|
||
|
|
||
|
```HTTP
|
||
|
POST /quotes
|
||
|
```
|
||
|
|
||
|
```BASH
|
||
7 years ago
|
curl --request POST --header 'X-Quotes-API-Key: $API_KEY' --data 'id=666&date=2018-10-31&game=IRL&text=Cheese' 'https://ladylilia.com/quotes/api/quotes'
|
||
7 years ago
|
```
|
||
|
|
||
7 years ago
|
*Note: the quote is replaced if it exists already*
|
||
7 years ago
|
|
||
|
Parameters:
|
||
|
|
||
|
* `id` (required) - Quote ID
|
||
7 years ago
|
* `date` (required) - Date in **ISO 8601** format
|
||
7 years ago
|
* `game` (required) - Related game
|
||
|
* `text` (required) - Text of the quote
|
||
|
|
||
|
## Replace specific quote
|
||
|
|
||
|
```HTTP
|
||
|
PUT /quotes/:id
|
||
|
```
|
||
|
|
||
|
```BASH
|
||
7 years ago
|
curl --request PUT --header 'X-Quotes-API-Key: $API_KEY' --data 'date=2018-10-31&game=IRL&text=Coffee' 'https://ladylilia.com/quotes/api/quotes/666'
|
||
7 years ago
|
```
|
||
|
|
||
7 years ago
|
*Note: the quote is created if it doesn't exist yet*
|
||
7 years ago
|
|
||
|
Parameters:
|
||
|
|
||
7 years ago
|
* `date` (required) - Date in **ISO 8601** format
|
||
7 years ago
|
* `game` (required) - Related game
|
||
|
* `text` (required) - Text of the quote
|
||
|
|
||
|
## Delete specific quote
|
||
|
|
||
|
```HTTP
|
||
|
DELETE /quotes/:id
|
||
|
```
|
||
|
|
||
|
```BASH
|
||
7 years ago
|
curl --request DELETE --header 'X-Quotes-API-Key: $API_KEY' 'https://ladylilia.com/quotes/api/quotes/666'
|
||
7 years ago
|
```
|