Files
legolog/docs/API.md
Benjamin Kyd c28f774918 lol
Former-commit-id: a7dcbb60b8bd4ab8cc4014ef7c53888904b996bf
2022-03-28 13:35:17 +01:00

106 lines
2.3 KiB
Markdown

# API Documentation
ALL API REQUESTS WILL BE PREFIXED WITH /api/
ALL AUTHENTICATION RELATED REQUESTS WILL BE PREFIXED WITH /api/auth/
this is because the API has no state so middleware will authenticate
automatically every request
## Routes
| Type | Route | Queries | Auth? | Notes |
| --- | --- | --- | -- | --- |
| GET | /api/search/ | query, page | no | Query endpoint |
| GET | /api/bricks/ | query, page | no | Query endpoint |
| GET | /api/sets/ | query, page | no | Query endpoint |
| GET | /api/sets/featured | page | no | Query endpoint |
| GET | /api/brick/:id/ | | no | |
| GET | /api/set/:id/ | | no | |
| GET | /api/cdn/:id/ | | no | |
| PUT | /api/auth/login/ | | yes | |
| POST | /api/auth/signup/ | | yes | |
| GET | /api/auth/orders/ | | yes | |
| GET | /api/auth/basket/ | | yes | |
| PUT | /api/auth/basket/:id | quantity | yes | |
| POST | /api/auth/basket/:id | | yes | manipulate basket content |
| DEL | /api/auth/basket/:id | quantity | yes | if no id, delete whole |
| DEL | /api/auth/basket/ | | yes | if no id, delete whole |
Query endpoints do not return the full data on a brick/set, they return
a subset for product listing pages
## Query structure
## Query parameters
For all endpoints that query, the following parameters are supported:
tags: tags to include in search
page: starting page
pages: pages to return starting from page
q: string to search for (fuzzy)
brick: brick to search for (absolute)
set: brick to search for (absolute)
### /api/search/
### /api/bricks/
GET
Response Object
```json
{
}
```
### /api/sets/
### /api/brick/:id/
### /api/set/:id/
### /api/cdn/:id/
### /api/auth/login/
### /api/auth/signup/
Request Body
```json
{
}
```
Response Object
```json
{
}
```
### /api/auth/orders/
### /api/auth/basket/
## Response Structure
```js
{
error: false
result: {
// defined in the response description for each route
}
}
```
## Error Structure
```js
{
error: {
short: "Error doing x",
long: "y needs to be z",
}
}
```