Популяризирай сървър
Black Friday започва утре 50% отстъпка за място в Master Server и за списъка Client, който идва с PREMIUM ЗА ЦЯЛ ЖИВОТ
Започва след -- Виж офертите
Vote codes

Vote codes API

Reward the players who vote for your server: check the code they got when they voted, then mark it used.

API key required https://api.counter-strike-boost.com

Overview #

Every vote for a server on Counter-Strike Boost, on the website or from our Discord bot, gives the voter a code like BXCM-GPWY. The player brings that code to your server (a chat command, a menu, your own site), and your plugin or bot asks this API whether it is a real vote for your server and marks it used, so each vote pays out once.

GET/v1/vote-codes/{code}Is this a vote for my server, and is it used?
POST/v1/vote-codes/{code}/redeemMark it used, exactly once

Your server key

These two endpoints do not use the general API key. They take a key for one server, made by its owner: open your server's page, go to the Votes tab and press Make API key. The key starts with csbv_ and is shown once, so copy it into your plugin's config straight away. Making a new one stops the old one at once.

Send it on every request:

Authorization: Bearer csbv_...

A key only sees the codes of its own server. A code from another server answers exactly like a code that does not exist (404 code_not_found).

Keep the key on the server side

Anyone with the key can redeem your server's codes. Keep it in a server config file or your backend, never in a web page, a public repository or a client the players run.

No code to write: the AMX Mod X plugin

CSB Vote Rewards does all of this on your game server: players type /redeem CODE in chat and get money, a command of your choice, or whatever your own plugin gives through its csb_vote_redeemed forward. It uses the AmxxEasyHttp module for HTTPS, so checking a code never freezes the server. Its source is a complete example of the calls below.

Check a vote code #

GET /v1/vote-codes/{code} server key required

Looks a code up without changing it. Use it to show the player what they voted and when, or to apply your own rules before paying out (for example, only votes from the last 24 hours).

Parameters

code string path required

The code as the player typed it. Case, spaces and the dash do not matter: bxcm gpwy is BXCM-GPWY.

Response fields

FieldTypeNotes
voted_at string When the vote was cast, UTC, RFC 3339.
age_seconds integer Seconds since the vote. Handy for "votes from today only" rules without parsing dates.
user string The voter's Counter-Strike Boost account name.
nickname string|null The in-game name the voter gave for your server when voting. Optional for the voter, so often null.
source string website or discord.
redeemed bool Whether the code was already used.
redeemed_at string|null When it was used, UTC, RFC 3339. null while unused.
redeemed_by string|null The player your redeem call passed. null while unused or when none was sent.

Codes can be checked for 30 days after the vote. After that the API answers 404 code_not_found, as for a code that never existed.

Request
cURL
curl -H "Authorization: Bearer $CSB_VOTE_KEY" \
  "https://api.counter-strike-boost.com/v1/vote-codes/BXCM-GPWY"
JavaScript
const res = await fetch(
  `https://api.counter-strike-boost.com/v1/vote-codes/${encodeURIComponent(code)}`,
  { headers: { Authorization: `Bearer ${process.env.CSB_VOTE_KEY}` } }
);
const data = await res.json();

if (!data.status) {
  throw new Error(data.error);   // code_not_found, invalid_code, ...
}
console.log(data.redeemed ? 'already used' : 'valid, not used yet');
PHP
<?php
$ch = curl_init('https://api.counter-strike-boost.com/v1/vote-codes/' . rawurlencode($code));
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('CSB_VOTE_KEY')],
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);

if (empty($data['status'])) {
    throw new RuntimeException($data['error'] ?? 'request_failed');
}
Python
import os, requests

r = requests.get(
    f"https://api.counter-strike-boost.com/v1/vote-codes/{code}",
    headers={"Authorization": f"Bearer {os.environ['CSB_VOTE_KEY']}"},
    timeout=10,
)
data = r.json()
if not data["status"]:
    raise RuntimeError(data["error"])
Response
200 OK
{
  "age_seconds": 5414,
  "code": "BXCM-GPWY",
  "nickname": "Shadow",
  "redeemed": false,
  "redeemed_at": null,
  "redeemed_by": null,
  "server": "203.0.113.7:27015",
  "source": "website",
  "status": true,
  "user": "shadow98",
  "voted_at": "2026-11-19T20:35:01Z"
}
400 Bad Request
{
  "error": "invalid_code",
  "format": "XXXX-XXXX",
  "status": false
}
401 Unauthorized
{
  "error": "unauthorized",
  "hint": "send Authorization: Bearer csbv_... (make the key on your server's Votes tab)",
  "status": false
}
404 Not Found
{
  "error": "code_not_found",
  "status": false
}

Redeem a vote code #

POST /v1/vote-codes/{code}/redeem server key required

Marks the code used and returns it. A code can be redeemed once: if two of your servers try the same code at the same moment, exactly one gets 200 and the other gets 409 already_redeemed. Pay the reward only on 200.

Parameters

code string path required

The code, in any case, with or without the dash.

player string default optional

JSON body {"player": "..."}: who claimed it (in-game name or SteamID). Stored as redeemed_by, up to 64 characters.

Response fields

FieldTypeNotes
status bool true only for the call that used the code.
error string On 409: already_redeemed. The rest of the body is the code as stored, so you can tell the player when it was used.

Both endpoints are rate limited per key; a 429 rate_limited carries retry_after in seconds and a Retry-After header. Normal use, one call per player who types a code, stays far below the limit.

Request
cURL
curl -X POST \
  -H "Authorization: Bearer $CSB_VOTE_KEY" \
  -H "Content-Type: application/json" \
  -d '{"player":"STEAM_0:1:123456"}' \
  "https://api.counter-strike-boost.com/v1/vote-codes/BXCM-GPWY/redeem"
JavaScript
const res = await fetch(
  `https://api.counter-strike-boost.com/v1/vote-codes/${encodeURIComponent(code)}/redeem`,
  {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.CSB_VOTE_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ player: steamId }),
  }
);

if (res.status === 200) giveReward(steamId);
else if (res.status === 409) tell(steamId, 'That code was already used.');
else tell(steamId, 'That is not a vote code for this server.');
PHP
<?php
$ch = curl_init('https://api.counter-strike-boost.com/v1/vote-codes/' . rawurlencode($code) . '/redeem');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => json_encode(['player' => $steamId]),
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('CSB_VOTE_KEY'),
        'Content-Type: application/json',
    ],
]);
$body = curl_exec($ch);
$http = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($http === 200) {
    give_reward($steamId);
}
Python
import os, requests

r = requests.post(
    f"https://api.counter-strike-boost.com/v1/vote-codes/{code}/redeem",
    headers={"Authorization": f"Bearer {os.environ['CSB_VOTE_KEY']}"},
    json={"player": steam_id},
    timeout=10,
)
if r.status_code == 200:
    give_reward(steam_id)
elif r.status_code == 409:
    print("already used at", r.json()["redeemed_at"])
Response
200 OK
{
  "age_seconds": 5417,
  "code": "BXCM-GPWY",
  "nickname": "Shadow",
  "redeemed": true,
  "redeemed_at": "2026-11-19T22:05:18Z",
  "redeemed_by": "STEAM_0:1:123456",
  "server": "203.0.113.7:27015",
  "source": "website",
  "status": true,
  "user": "shadow98",
  "voted_at": "2026-11-19T20:35:01Z"
}
409 Conflict
{
  "age_seconds": 5417,
  "code": "BXCM-GPWY",
  "error": "already_redeemed",
  "nickname": "Shadow",
  "redeemed": true,
  "redeemed_at": "2026-11-19T22:05:18Z",
  "redeemed_by": "STEAM_0:1:123456",
  "server": "203.0.113.7:27015",
  "source": "website",
  "status": false,
  "user": "shadow98",
  "voted_at": "2026-11-19T20:35:01Z"
}
404 Not Found
{
  "error": "code_not_found",
  "status": false
}

Recipe: a /redeem command with a reward #

The usual flow on a game server: the player types the code in chat, your side calls redeem with the player's SteamID, and pays the reward only on 200. No separate check is needed first: redeem already says whether the code exists and whether it was used.

  1. Shell

    BASH
    API=https://api.counter-strike-boost.com
    CODE_TYPED="bxcm gpwy"   # as typed; case and spaces do not matter
    
    http=$(curl -s -o /tmp/vote.json -w '%{http_code}' -X POST \
      -H "Authorization: Bearer $CSB_VOTE_KEY" \
      -H 'Content-Type: application/json' \
      -d '{"player":"STEAM_0:1:123456"}' \
      "$API/v1/vote-codes/$(printf %s "$CODE_TYPED" | tr -d ' ')/redeem")
    
    case $http in
      200) echo "reward $(jq -r .user /tmp/vote.json)" ;;
      409) echo "already used at $(jq -r .redeemed_at /tmp/vote.json)" ;;
      *)   echo "not a vote for this server ($http)" ;;
    esac

Want a time limit, such as "today's vote only"? Check age_seconds on the 200 body before paying out, or call the check endpoint first.

Recipe: the same flow in AMX Mod X #

The core of CSB Vote Rewards, with the AmxxEasyHttp module. The request is asynchronous: the server keeps running and the callback fires when the answer arrives. Pass the player's userid, not the slot, so the answer cannot reach someone who took the slot in the meantime.

  1. Pawn

    PAWN
    #include <amxmodx>
    #include <easy_http>
    
    redeem(id, const code[])
    {
        new url[128], auth[80], body[64], steamid[35], data[1];
        formatex(url, charsmax(url), "https://api.counter-strike-boost.com/v1/vote-codes/%s/redeem", code);
        formatex(auth, charsmax(auth), "Bearer %s", g_key);           // csbv_... from the Votes tab
        get_user_authid(id, steamid, charsmax(steamid));
        formatex(body, charsmax(body), "{^"player^":^"%s^"}", steamid);
    
        new EzHttpOptions:opt = ezhttp_create_options();
        ezhttp_option_set_header(opt, "Authorization", auth);
        ezhttp_option_set_header(opt, "Content-Type", "application/json");
        ezhttp_option_set_body(opt, body);
        data[0] = get_user_userid(id);
        ezhttp_option_set_user_data(opt, data, sizeof(data));
    
        ezhttp_post(url, "on_redeemed", opt);
    }
    
    public on_redeemed(EzHttpRequest:req)
    {
        new data[1];
        ezhttp_get_user_data(req, data);
        new id = find_player("k", data[0]);                          // by userid
        if (!id) return;
    
        if (ezhttp_get_error_code(req) != EZH_OK)
            client_print(id, print_chat, "Vote service unreachable, your code is not used.");
        else switch (ezhttp_get_http_code(req))
        {
            case 200: give_reward(id);
            case 409: client_print(id, print_chat, "That code was already used.");
            case 404: client_print(id, print_chat, "That is not a vote code for this server.");
            default:  client_print(id, print_chat, "Try again later.");
        }
    }

The full plugin adds the optional age check, chat commands, rewards and the forward. Download it, or read its source, on its plugin page.