To-buy is a CRUD API which serves the front-end side for creating a TODO like list for things you want to buy. Constructed using node.js to create a bridge between front and database using REST API methods.
Build for training and studying
Base URL: https://algumnome.herokuapis.com
This endpoint contains pagination and item limit count, both of them can be change in que params of the request for the server.
Allowed parameters are:
- ?page=1 Which sets the page requested
- ?perPage=10 Which sets how many items will come in the response
Both can be used together.
{
"docs": [
{
"siteUrls": [],
"_id": "5f93595f6033401d2b66e29a",
"title": "calderado",
"price": 123,
"currency": "USD",
"description": "Calde lindo",
"imageUrl": "https://picsum.photos/1000",
"__v": 0
},
{
"siteUrls": [],
"_id": "5f936ac56033401d2b66e29b",
"title": "Burgão Da Manolagem",
"price": 150,
"currency": "BRL",
"description": "O produto é muito legal",
"imageUrl": "https://picsum.photos/1000",
"__v": 0
},
{
"siteUrls": [],
"_id": "5f936aca6033401d2b66e29c",
"title": "Burgão Da Manolagem",
"price": 150,
"currency": "BRL",
"description": "O produto é muito legal",
"imageUrl": "https://picsum.photos/1000",
"__v": 0
}
],
"total": 11,
"limit": 3,
"page": 1,
"pages": 4
}
the /id field is the _id returned in the response
{
"siteUrls": [],
"_id": "5f936ac56033401d2b66e29b",
"title": "Burgão Da Manolagem",
"price": 150,
"currency": "BRL",
"description": "O produto é muito legal",
"imageUrl": "https://picsum.photos/1000",
"__v": 0
}
To create one item, the following style of the request body is required.
{
"title": "Title for the item/object",
"price": "20",
"currency": "EUR",
"description": "Object/item description",
"imageUrl": "https://someurl.com",
"siteUrls" :[
"https://someurl.com",
"https://someurl.com/"
]
}
title: {
type: String,
required: true,
},
price: {
type: Number,
required: false,
},
currency: {
type: String,
required: false
},
siteUrls: {
type: [String],
required: false
},
description: {
type: String,
required: false
},
imageUrl: {
type: String,
required: false
}
If the request body is correct the server will respond with 201 status code and send back the data created including the _id field generated for the object.
{
"siteUrls": [
"https://someurl.com",
"https://someurl.com/"
],
"_id": "5f94508e87f4fe57ad723cb8",
"title": "Title for the item/object",
"price": 20,
"currency": "EUR",
"description": "Object/item description",
"imageUrl": "https://someurl.com",
"__v": 0
}
Otherwise, the response will contain the error founded
{
"errors": [
{
"message": "\"imageUrl\" must be a valid uri",
"path": [
"imageUrl"
],
"type": "string.uri",
"context": {
"label": "imageUrl",
"value": "https://som eurl.com",
"key": "imageUrl"
}
}
]
}
Used only for updating items within the database, cannot be used to create new ones