Connect your game

When a player types your command, the game asks VoteScript what is waiting and hands it out.

What you need

  • A server in VoteScript with at least one reward
  • Access to your game server

Create an API key

Open Game server and create a key. It is shown once. Keep it on the server, never in a client, an app or a web page.

You should now see: “Waiting for the first call from your game”.

Choose your way

Use the page of your game if there is one. It has downloads and the exact files. Everything else can call the API.

Claim

Send the player and a new ref for each command. If you get no answer, ask again with the same ref: you get the same items, never twice.

Terminal
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"
Java 8
VoteScript vote = new VoteScript("https://votescript.voterank.net", "YOUR_KEY");
String ref = UUID.randomUUID().toString();
VoteScript.Claim claim = vote.claim(player.getName(), ref);
for (VoteScript.Item item : claim.items) {
    player.addItem(Integer.parseInt(item.key), item.amount);
}
votescript.mjs
import { VoteScript } from './votescript.mjs';
import { randomUUID } from 'node:crypto';

const vote = new VoteScript('https://votescript.voterank.net', 'YOUR_KEY');
const claim = await vote.claim('Zezima', randomUUID());
votescript.py
import uuid
from votescript import VoteScript

vote = VoteScript("https://votescript.voterank.net", "YOUR_KEY")
claim = vote.claim("Zezima", str(uuid.uuid4()))
JSON
{"ok": true, "player": "Zezima", "votes": 2,
 "items": [{"key": "995", "name": "Coins", "amount": 200000}]}

Try it in the game

Send a test vote from a vote site in your dashboard, then type your command.

You should now see: The items in your game, and “Your game has used a key”.

If it does not work

401
The key is missing or wrong. Create a new one if you lost it.
405
Claims must be sent with POST.
429
Too many requests. Wait a moment before you ask again.
The player has nothing waiting
The name differs, or the vote was not counted. Use check to look without claiming.
Where is claim-code?
With codes, call claim-code instead of claim and add code.

Next

Give your players one place to vote

Your page is live as soon as you create your server. You can connect the rest step by step.