API Documentation

Integrate your server with our voting system using our REST API.

Overview

The DPServers API allows server owners to integrate a vote-for-reward system into their game server. Players vote on our platform and you can verify that vote programmatically to deliver in-game rewards.

Base URL:

https://www.topdofus.com

Authentication

All API requests require an API Key, which is tied to your server. To get your API Key:

  1. Register an account and add your server.
  2. Go to Dashboard > Your Server > API Key.
  3. Copy the API Key and use it in your requests.

How the Vote Flow Works

1
Init Vote

Your server calls POST /api/vote/init with your API key and server ID. You receive a temporary token and a vote URL.

2
Redirect Player

Redirect the player to the vote_url received. The player lands on our voting page.

3
Player Votes

The player completes the vote on our platform. If a callback_url was provided, the player is redirected back to your site.

4
Verify Vote

Your server calls POST /api/vote/verify with the token to check if the vote was completed. If voted=true, deliver the reward.

POST /api/vote/init

Initiates a vote session. Returns a temporary token and a URL where the player should be redirected to vote.

Parameters

Name Type Required Description
api_key string Your server's API key.
server_id integer Your server's ID on DPServers.
username string - The player's in-game username (for tracking).
callback_url string - URL to redirect the player after voting.

Success Response (200)

{
  "success": true,
  "token": "abc123def456...",
  "vote_url": "https://www.topdofus.com/api/vote/callback/abc123def456..."
}

Error Responses

// 400 - Missing parameters{
  "success": false,
  "error": "Missing required parameters: api_key, server_id."
}

// 401 - Invalid API key{
  "success": false,
  "error": "Invalid or revoked API key."
}

// 403 - Key/server mismatch{
  "success": false,
  "error": "API key does not match the provided server_id."
}

GET /api/vote/callback/{token}

This is the URL you redirect the player to. It's returned in the vote_url field from /api/vote/init. You do NOT call this endpoint directly.

This endpoint is for the player's browser. It validates the token and redirects the player to the voting page. After voting, if a callback_url was provided, the player is sent back to your site.

POST /api/vote/verify

Check whether a vote has been completed for a given token.

Parameters

Name Type Required Description
api_key string Your server's API key.
token string The token received from /api/vote/init.

Success Response (200)

// Player has voted{
  "success": true,
  "voted": true,
  "voted_at": "2026-04-11 14:30:00"
}

// Player has not voted yet{
  "success": true,
  "voted": false,
  "voted_at": null
}

Code Examples

PHP

<?php
$apiKey   = 'YOUR_API_KEY';
$serverId = 1;

// Step 1: Init vote
$ch = curl_init('https://www.topdofus.com/api/vote/init');
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS     => [
        'api_key'   => $apiKey,
        'server_id' => $serverId,
        'username'  => 'player123',
    ],
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);

if ($response['success']) {
    // Redirect user to vote
    header('Location: ' . $response['vote_url']);
    exit;
}

// Step 2: Verify vote (after user returns)
$ch = curl_init('https://www.topdofus.com/api/vote/verify');
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS     => [
        'api_key' => $apiKey,
        'token'   => $response['token'],
    ],
]);
$result = json_decode(curl_exec($ch), true);
curl_close($ch);

if ($result['success'] && $result['voted']) {
    echo 'Vote confirmed! Reward the player.';
}

JavaScript (fetch)

const API_KEY   = 'YOUR_API_KEY';
const SERVER_ID = 1;

// Step 1: Init vote
const formData = new FormData();
formData.append('api_key', API_KEY);
formData.append('server_id', SERVER_ID);
formData.append('username', 'player123');

const res = await fetch('https://www.topdofus.com/api/vote/init', {
    method: 'POST',
    body: formData,
});
const data = await res.json();

if (data.success) {
    window.location.href = data.vote_url;
}

// Step 2: Verify vote
const verifyData = new FormData();
verifyData.append('api_key', API_KEY);
verifyData.append('token', data.token);

const verify = await fetch('https://www.topdofus.com/api/vote/verify', {
    method: 'POST',
    body: verifyData,
});
const result = await verify.json();

if (result.success && result.voted) {
    console.log('Vote confirmed!');
}

Python

import requests

API_KEY   = 'YOUR_API_KEY'
SERVER_ID = 1

# Step 1: Init vote
res = requests.post('https://www.topdofus.com/api/vote/init', data={
    'api_key': API_KEY,
    'server_id': SERVER_ID,
    'username': 'player123',
})
data = res.json()

if data['success']:
    vote_url = data['vote_url']
    # Redirect user to vote_url

# Step 2: Verify vote
verify = requests.post('https://www.topdofus.com/api/vote/verify', data={
    'api_key': API_KEY,
    'token': data['token'],
})
result = verify.json()

if result['success'] and result['voted']:
    print('Vote confirmed! Reward the player.')

HTTP Status Codes

Code Meaning
200 Success — request completed successfully.
401 Unauthorized — invalid or revoked API key.
403 Forbidden — API key does not match the server ID.
404 Not Found — token or resource not found.

Important Notes

  • Each IP can only vote once every 12 hours per server.
  • Tokens expire after 30 minutes if not used.
  • The voter's IP is recorded to prevent abuse.
  • Always use HTTPS for API requests in production.