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

2.3 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/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

{

}

/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",
    }
}