Skip to content

This project is a REST API for a Steam Market Item model. It was built with FastApi and uses MongoDB as datasource.

License

Notifications You must be signed in to change notification settings

ew3g/csgo-market-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSGO Market API

GitHub license GitHub contributors GitHub issues GitHub pull-requests PRs Welcome

GitHub watchers GitHub forks GitHub stars

Counter Strike Logo

This project is a REST API to a Steam Market Item model. It was built with FastApi and uses MongoDB as datasource.

InstallationUsage

It is recommended to run this API with the CSGO Market Crawler, as it is responsible for populating the base with Steam Market items

Installation

  • 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'

Usage

To run this project is very simple, run the server with:

$ uvicorn main:app --reload

or

$ python main.py

REST API

Endpoints available are the following:

Get list of all items

Request

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'

Response

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 a specific item by id

Request

GET /item/{id}

curl --location --request GET 'localhost:8000/item/629d4b340fb273faf5e846da' \
--header 'x-token: my_token'

Response

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

Create an item

Request

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"
}'

Response

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

Update an item

Request

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"
}'

Response

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 an item

Request

DELETE /item/{id}

curl --location --request DELETE 'http://localhost:8000/item/62ab40abcc85842901cf85ef?x-token=my_token' \
--header 'x-token: my_token'

Response

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

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

The MIT License (MIT)

Thanking

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.

About

This project is a REST API for a Steam Market Item model. It was built with FastApi and uses MongoDB as datasource.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages