Files
legolog/docs/API.md
Ben f6667bbf92 style
Former-commit-id: aad14d70472dd4412e02e0870086a4c28f42792b
2022-03-30 19:04:38 +01:00

2.7 KiB

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/special/ no
GET /api/type/:id no
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/special/

GET /api/special/

Response Object

{
    "data": {
        "title": "Special 1",
        "end": "2020-01-31T00:00:00.000Z",
    }
}

/api/type/:id

GET /api/type/:id

Response Object

{
    "data": {
        "type": "brick", // or set
    }
}

/api/search/

GET /api/search?params

/api/bricks/

GET

Response Object

{

}

/api/sets/

/api/brick/:id/

/api/set/:id/

/api/cdn/:id/

/api/auth/login/

/api/auth/signup/

Request Body

{

}

Response Object

{
    
}

/api/auth/orders/

/api/auth/basket/

Response Structure

{
    error: false
    result: {
        // defined in the response description for each route
    }
}

Error Structure

{
    error: {
        short: "Error doing x",
        long: "y needs to be z",
    }
}