Skip to content

JakeeUp/cs-skin-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SkinAPI

Real-time CS2 skin market data, budget optimization, and loadout building — powered by C++17

C++17 CMake Steam API License

Live Demo · Getting Started · API Reference


Overview

SkinAPI is a REST API that pulls live CS2 skin pricing from the Steam Community Market and exposes search, price lookup, budget optimization, and full loadout building through a clean JSON interface. The frontend provides a responsive dark-themed UI with grid/list views and client-side filtering.

App Overview


Features

Market Search

Search CS2 skins by weapon name with live Steam Market data. Filter results by price range, wear condition (FN/MW/FT/WW/BS), and StatTrak status. Toggle between grid and list views.

Market Search Demo

Budget Optimizer

Enter a dollar budget and a weapon — the optimizer fetches available skins and runs a 0/1 knapsack algorithm to select the combination that maximizes total value without exceeding your budget. Uses dynamic programming for budgets up to $500, with a greedy fallback for larger inputs.

Budget Optimizer Demo

Loadout Builder

Pick T or CT side and set separate budgets for primary weapons, secondary weapons, knife, and gloves. A round-robin interleaving algorithm ensures variety across weapon types — you won't get five AK-47 skins when you wanted a diverse loadout.

Loadout Builder Demo


Tech Stack

Layer Technology Purpose
Backend C++17 Server, algorithms, API logic
HTTP Framework Crow Routing, CORS, JSON responses
HTTP Client libcurl Steam Market API requests
JSON nlohmann/json Parsing and serialization
Build CMake 3.20+ Cross-platform builds
Frontend Vanilla JS / HTML / CSS UI with no framework dependencies

Architecture

┌─────────────┐       HTTP        ┌──────────────────────────────────┐
│   Browser    │ ◄──────────────► │         Crow HTTP Server         │
│  (index.html │                  │           port 8080              │
│   app.js)    │                  ├──────────────────────────────────┤
└─────────────┘                   │  /search    → fetchQuery()       │
                                  │  /price     → fetchURL()         │
                                  │  /budget    → knapsackOptimize() │
                                  │  /loadout   → fetchSlotOptions() │
                                  ├──────────────────────────────────┤
                                  │         libcurl + rate limiter   │
                                  └────────────┬─────────────────────┘
                                               │ HTTPS
                                  ┌────────────▼─────────────────────┐
                                  │   Steam Community Market API     │
                                  └──────────────────────────────────┘

Getting Started

Prerequisites

  • CMake 3.20+
  • C++17 compiler (GCC, Clang, or MSVC)
  • libcurl development headers

Build & Run

Windows (MSYS2/MinGW)

mkdir build && cd build
cmake .. -G "MinGW Makefiles"
cmake --build .
./cs-skin-api.exe

Linux / macOS

mkdir build && cd build
cmake ..
cmake --build .
./cs-skin-api

The server starts on http://localhost:8080. Open index.html in a browser to use the UI.


API Reference

GET /health

Returns server status.

{ "status": "ok", "message": "CS Skin API is alive" }

GET /search

Search for CS2 skins by name with optional price range filtering.

Parameter Type Required Description
q string Yes Weapon or skin name
min float No Minimum price in USD (default: 0)
max float No Maximum price in USD (default: 999999)

Example: GET /search?q=AK-47+Redline&min=10&max=100

Response
{
  "total_count": 8,
  "results": [
    {
      "name": "AK-47 | Redline (Field-Tested)",
      "hash_name": "AK-47 | Redline (Field-Tested)",
      "sell_listings": 803,
      "sell_price": 4823,
      "sell_price_text": "$48.23",
      "sale_price_text": "",
      "icon_url": "https://community.akamai.steamstatic.com/economy/image/...",
      "market_url": "https://steamcommunity.com/market/listings/730/..."
    }
  ]
}

GET /price

Get price overview for a specific skin.

Parameter Type Required Description
name string Yes Market hash name of the skin

Example: GET /price?name=AK-47+Redline+(Field-Tested)

Response
{
  "name": "AK-47 | Redline (Field-Tested)",
  "lowest_price": "$45.00",
  "median_price": "$48.23",
  "volume": "342"
}

POST /budget/optimize

Select the optimal combination of skins within a budget using a 0/1 knapsack algorithm.

Field Type Required Description
budget float Yes Maximum budget in USD (max $10,000)
query string Yes Weapon or skin name to search
Request / Response

Request:

{
  "budget": 100.00,
  "query": "AK-47 Redline"
}

Response:

{
  "budget": 100.00,
  "total_spent": 88.17,
  "remaining": 11.83,
  "skins_found": 42,
  "skins_selected": 2,
  "algorithm": "knapsack_dp",
  "skins": [
    { "name": "AK-47 | Redline (Field-Tested)", "price": "$48.23", "price_cents": 4823, "listings": 803 },
    { "name": "AK-47 | Redline (Battle-Scarred)", "price": "$39.94", "price_cents": 3994, "listings": 64 }
  ]
}

POST /loadout/build

Build a full loadout for T or CT side with per-slot budgets.

Field Type Required Description
side string Yes "T" or "CT"
weapons_budget float Yes Budget split between primary and secondary
knife_budget float No Budget for knife slot (0 = skip)
gloves_budget float No Budget for gloves slot (0 = skip)
Request / Response

Request:

{
  "side": "T",
  "weapons_budget": 100.00,
  "knife_budget": 50.00,
  "gloves_budget": 30.00
}

Response:

{
  "side": "T",
  "weapons_budget": 100.00,
  "knife_budget": 50.00,
  "gloves_budget": 30.00,
  "slots": {
    "primary": [{ "name": "AK-47 | Redline (FT)", "price": "$48.23", "price_cents": 4823, "listings": 803 }],
    "secondary": [{ "name": "Glock-18 | Fade (FN)", "price": "$42.10", "price_cents": 4210, "listings": 12 }],
    "knife": [{ "name": "Gut Knife | Doppler (FN)", "price": "$49.99", "price_cents": 4999, "listings": 5 }],
    "gloves": [{ "name": "Sport Gloves | Arid (FT)", "price": "$28.50", "price_cents": 2850, "listings": 8 }]
  }
}

Project Structure

cs-skin-api/
├── src/
│   └── main.cpp           # API server, knapsack algorithm, Steam fetcher
├── index.html              # Frontend UI
├── app.js                  # Client-side logic and API calls
├── style.css               # Dark theme styling
├── CMakeLists.txt          # Build configuration
├── third_party/
│   └── crow_all.h          # Crow HTTP framework (single header)
└── assets/                 # Screenshots and demo GIFs
    ├── search-demo.gif
    ├── budget-demo.gif
    └── loadout-demo.gif

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors