This project is a REST API to a Steam Market Item model. It was built with FastApi and uses MongoDB as datasource.
It is recommended to run this API with the CSGO Market Crawler, as it is responsible for populating the base with Steam Market items
-
Set up a MongoDB database, I used a free tier Atlas MongoDB.
-
Use package manager pip to install all needed libs.
bash pip install -r requirements.txt
-
Create the file .env in the project root folder with the following content:
DATABASE_URL='mongodb+srv://USER:PASSWORD@HOST/DATABASE?retryWrites=true&w=majority'
LOG_LEVEL='INFO'
API_TOKEN='your_token'
To run this project is very simple, run the server with:
$ uvicorn main:app --reload
or
$ python main.py
Endpoints available are the following:
Accept as parameters: page(default=0) and limit(default=10)
GET /item
curl --location --request GET 'localhost:8000/item?page=0&limit=10' \
--header 'x-token: my_token'
HTTP/1.1 200 OK
Date: Mon, 13 Jun 2022 18:02:48 GMT
Status: 200 OK
Connection: close
Content-Type: application/json
Content-Length: 261
{
"data":[
"id": "96840fb2734935e846da",
"name": "Item Name",
"type": "Item Type",
"subtype": "Item Subtype",
"game_type": "Item Game Type"
],
"code": 200,
"message": "Items data retrieved succesfully"
}
GET /item/{id}
curl --location --request GET 'localhost:8000/item/629d4b340fb273faf5e846da' \
--header 'x-token: my_token'
HTTP/1.1 200 OK
Date: Mon, 13 Jun 2022 18:02:48 GMT
Status: 200 OK
Connection: close
Content-Type: application/json
Content-Length: 289
{
"data": {
"id": "96840fb2734935e846da",
"name": "Item Name",
"type": "Item Type",
"subtype": "Item Subtype",
"game_type": "Item Game Type"
},
"code": 200,
"message": "Item data retrieved succesfully"
}
POST /item
curl --location --request POST 'http://localhost:8000/item' \
--header 'x-token: my_token' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Item Name",
"type": "Item Type",
"subtype": "Item Subtype",
"game_type": "Item Game Type"
}'
HTTP/1.1 200 OK
Date: Mon, 13 Jun 2022 18:02:48 GMT
Status: 200 OK
Connection: close
Content-Type: application/json
Content-Length: 182
{
"data": {
"id": "62ab3c195fd7d6594c281d61",
"name": "Item Name",
"type": "Item Type",
"subtype": "Item Subtype",
"game_type": "Item Game Type"
},
"code": 201,
"message": "Item addeed successfully"
}
PUT /item/{id}
curl --location --request PUT 'http://localhost:8000/item/62ab40abcc85842901cf85ef' \
--header 'x-token: my_token' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Item Name",
"type": "Item Type",
"subtype": "Item Subtype",
"game_type": "Item Game Type"
}'
HTTP/1.1 200 OK
Date: Mon, 13 Jun 2022 18:02:48 GMT
Status: 200 OK
Connection: close
Content-Type: application/json
Content-Length: 151
{
"data": {
"name": "Item Name",
"type": "Item Type",
"subtype": "Item Subtype",
"game_type": "Item Game Type"
},
"code": 200,
"message": "Item updated successfully"
}
DELETE /item/{id}
curl --location --request DELETE 'http://localhost:8000/item/62ab40abcc85842901cf85ef?x-token=my_token' \
--header 'x-token: my_token'
HTTP/1.1 200 OK
Date: Mon, 13 Jun 2022 18:02:48 GMT
Status: 200 OK
Connection: close
Content-Type: application/json
Content-Length: 83
{
"data": "62ab40abcc85842901cf85ef",
"code": 200,
"message": "Item deleted succesfully"
}
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
CSGO png image for the project icon csgo-icon. Credits to Ahkâm.
API png image for the project icon api-icon. Credits to Freepik.