API reference

For step by step setup, see Connect your game.

Game server API

Base address: https://votescript.voterank.net/index.php?r=api/v1/

Send your key in the X-Api-Key header, or as Authorization: Bearer. Parameters go in the query string (GET), a form body or a JSON body (POST). Answers are JSON.

MethodRequestWhat it does
pingGETChecks the key
checkGET playerShows what is waiting, claims nothing
claimPOST player, refReturns everything waiting and marks it claimed
claim-codePOST player, code, refRedeems one code (code mode)
topGETThis month’s top 25 voters
pendingGET limit, playersPlayers with something to claim, for automatic payout. players=A,B,C (up to 200) asks only about these, such as who is online
votifierPOST service, player, time, refReports a vote received over Votifier

format=text on claim and claim-code answers ok, a tab and the number of votes, then one line per item: key, amount and name, separated by tabs.

Claim

Request
curl -X POST -H "X-Api-Key: YOUR_KEY" \
  -d player=Zezima -d ref=A-NEW-UUID \
  "https://votescript.voterank.net/index.php?r=api/v1/claim"
Answer
{
  "ok": true,
  "player": "Zezima",
  "ref": "5f0c2c1e-…",
  "votes": 2,
  "items": [{"key": "995", "name": "Coins", "amount": 1000000}],
  "grants": [
    {"id": 41, "reason": "vote", "site": "VoteRank", "time": 1795600000,
     "items": [{"key": "995", "name": "Coins", "amount": 500000}]}
  ]
}
FieldMeaning
itemsThe total to hand out
votesThe number of votes behind it, if you prefer your own prizes
grantsEach reward on its own. reason is vote, all (voted on every site), streak or gift
ref8 to 64 letters, digits, - or _. Use a new one for every command a player types. If the request times out, repeat it with the same one: the same rewards come back and nothing is paid twice

Nothing waiting: ok is true with empty lists. Names ignore case, and treat space, _ and - as equal.

Reward types

A key without a slash is an item, a currency or a word. Other rewards have a type before the slash.

KeyAmountMeaning
vip/NAMEdaysVIP or premium time. Adds up
group/NAME, permission/NAMEdaysOr …/forever
title/NAME, unlock/NAMEdaysOr …/forever. _ in a title is a space
teleport/PLACE or teleport/X,Y,Z1Last, and once per claim
storage/IDnumberAdded to the value. storage/ID/VALUE sets it
until/IDdaysA storage set to a time ahead; extends one that runs
xp/SKILLnumberExperience
boost/NAME/PERCENTminutesSuch as boost/experience/50
effect/NAMEseconds
outfit/ID,ADDONS, mount/ID, spell/ID, badge/ID1Once
run/NAMEnumberAn action defined on the game server
custom/ANYTHINGnumberFor your own code

Send types with claim, claim-code, check and pending: what your game can do, such as item,vip/gold,storage/30000-39999,xp. A type alone covers everything of that type. Rewards with anything else stay waiting, and held says how many. Without types everything is handed out. Check every part of a key before you use it, and never run it as a command or code.

Each item also has type and text, such as “VIP for 1 day”. In the text format, held follows the votes when types was sent.

Codes

claim-code answers {"ok": false, "status": "unknown"}, "used" or "held" (see reward types) when the code cannot be redeemed. Dashes, spaces and case do not matter.

Errors

Errors look like {"ok": false, "error": "…"}.

HTTPMeaning
401The key is missing or wrong
405Use POST
422A parameter is missing or not valid
429Slow down
500Retry with the same ref

Public API

Base address: https://votescript.voterank.net/index.php?r=api/public/YOUR-SERVER/

Reading is open to every website and needs no key.

MethodParametersReturns
serverTexts, look, sites with images, rewards, content
topperiod day, week, month, all; limit up to 100players
statsvotes: today, week, month, all, voters_month
recentlimit up to 50votes
playerplayer; header X-Voter in code modeWait per site, items to claim, streak
votePOST site, player, voterurl to send the player to

Limits per address in 5 minutes: 600 requests, or 6,000 with a key.

JavaScript
<script src="https://votescript.voterank.net/embed.js" async defer></script>
<script>
addEventListener('load', async () => {
  const vs = VoteScript.api('your-server');
  const { players } = await vs.top({ period: 'month', limit: 10 });
});
</script>

Start a vote

Returns the address to send the player to. From a browser it works on your allowed websites; from a server, send your API key.

Request
curl -X POST 'https://votescript.voterank.net/index.php?r=api/public/your-server/vote' \
  -H 'X-Api-Key: YOUR_KEY' -H 'Content-Type: application/json' \
  -d '{"site":"voterank","player":"Zezima"}'

voter is 48 characters 0-9 a-f, random, kept by the visitor’s browser. In code mode it proves who earned a code.

Open the toplist in a new tab: toplists do not work inside frames. Open the tab in the click itself and set its address afterwards, or browsers block it.

Webhooks

One POST per counted vote. X-VoteScript-Signature is sha256= and the HMAC-SHA256 of the raw body with your signing secret. Ignore an id you have already handled. Answer with any 2xx; otherwise it is retried for about a day.

Body
{"event":"vote","id":"…","server":"your-server","time":1795600000,
 "player":"Zezima","site":{"slug":"voterank","name":"VoteRank"},
 "vote_id":41,"voted_at":1795600000,
 "items":[{"key":"995","name":"Coins","amount":100000}]}

Items are for display. Players still claim them, or your delivery program does, so do not pay them twice.

The same votes can be sent to a Votifier or NuVotifier in your game, see Send votes to your Votifier.

Embed attributes

AttributeWhat it does
data-serverThe address of your server. Required
data-modeinline or button, which opens the list on top of the page
data-labelText of the button
data-blocktop, recent, count, goal or sites instead of the vote list
data-periodday, week, month or all
data-limitNumber of rows
data-goalNumber of votes for goal
data-titleHeading of a block
data-themeauto, light or dark
data-playerFills in the name of a player who is logged in on your site
data-callbackJavaScript function called after a confirmed vote. For display only
data-stylenone: plain HTML with vs- classes instead of a frame

What callbacks are answered

HTTPMeaning
200Counted, duplicate, ignored, captured or test; the text says which
403Wrong callback URL, secret, signature or sender
405Wrong method
500VoteScript failed; the list should try again