Cases API Routes Documentation

The Cases API provides REST endpoints for managing and retrieving case-related data.

Overview

Cases are loot boxes that contain items with different rarity percentages. Users can browse cases, create custom cases, and retrieve case details.

Base Path: /cases


Endpoints

1. GET /cases

Get all cases with optional type filtering.

Query Parameters

Parameter
Type
Default
Description

type

string

"false"

Filter cases by type: "all" (all cases), "true" (Level cases only), "false" (regular cases, excluding Level cases and free-case)

Response

Returns an array of case objects.

Array<{
    id: string;
    name: string;
    price: number;
    creator: string;
    items: Array<{
        appid: number;
        marketHashName: string;
        gunName: string;
        skinName: string;
        image: string;
        price: string;
        nextPriceFetch: number;
        percentage: number;
    }>;
}>;

Example Request

Example Response


2. GET /cases/pagination

Get paginated cases with advanced filtering and sorting options.

Query Parameters

Parameter
Type
Default
Description

caseType

string

"false"

Filter by case type: "all", "true" (Level cases), "false" (regular cases)

page

number

1

Page number for pagination

limit

number

10

Number of items per page

type

string

"all"

Filter by game type: "cs2", "rust", or "all"

search

string

""

Search term to filter case names (case-insensitive)

sort

string

"Most Recent"

Sort option: "Most Recent", "Price Descending", "Price Ascending", "Oldest"

Response

Example Request

Example Response


3. GET /cases/free

Get the free case available to all users.

Response

Returns a single case object with id: "free-case".

Example Request

Error Response

Status Code: 404


4. GET /cases/:caseID

Get a specific case by its ID.

URL Parameters

Parameter
Type
Description

caseID

string

The unique identifier of the case (URL-encoded)

Response

Returns a single case object with items sorted by percentage (ascending).

Example Request

Error Response

Status Code: 404

Notes

  • Automatically updates item prices if any item is missing a price

  • Uses caching for improved performance

  • Items are sorted by percentage (lowest to highest)


5. POST /cases/create

Create a new custom case. Requires authentication.

Authentication

Requires a valid session cookie (connect.sid).

Request Body

Validation Rules

  • Authentication: User must be logged in

  • Level Requirement: User must be at least level 25

  • Name Constraints:

    • Cannot start with "level" (case-insensitive)

    • Cannot start with "free" (case-insensitive)

    • Must be 3-32 characters long

    • Must be unique (case-insensitive)

  • Items:

    • Minimum 2 items required

    • Each item must have a valid marketHashName and percentage

    • Percentages must be numbers between 0 and 100

    • Total percentage must equal exactly 100%

    • Items must exist in the inventory database

  • User Limits: Maximum 50 cases per user

Response (Success)

Example Request

Example Response (Success)

Error Responses

Unauthorized (401)

Forbidden (403)

Bad Request (400)

Internal Server Error (500)

Case Creation Process

  1. Validates user authentication and level

  2. Validates case name and item data

  3. Fetches current item prices from inventory

  4. Calculates the case price with 5% house edge

  5. Checks for duplicate case names

  6. Enforces user case limit (50 max)

  7. Determines case type (cs2/rust/mixed) based on item appids

  8. Saves case to the database


Data Models

Case Object

Item Object

Error Handling

All endpoints include try-catch blocks and return appropriate HTTP status codes:

  • 200: Success

  • 400: Bad Request (validation errors)

  • 401: Unauthorized (not logged in)

  • 403: Forbidden (insufficient permissions)

  • 404: Not Found (case doesn't exist)

  • 500: Internal Server Error


Frontend Integration

Example: Fetching All Cases

Example: Creating a Case

Last updated