RU UA EN
Home Log in Clan crests Advertising Add server

L2King Vote API — vote rewards on your server

How it works

Players vote for your server on L2King once every 12 hours. Your server checks the vote via the API and gives an in-game reward — so players come back every day. Votes are shown on the project page and in L2King lists, and the vote button on your website gives a 25% discount on Elite, Top and VIP.

ℹProject id and API key — in your account, “Votes & buttons” tab.

API key

Log in to your L2King account → “Votes & buttons” tab. Each of your projects has an id, an API key, a ready API address, a voting page link and the button constructor. Keep the key secret — store it only in your server config.

Open “Votes & buttons”

Vote check

Did the player vote in the last 12 hours — by IP or by nickname.

BASHGET /api/votes/ID?key=…&ip=… | &nick=…
# by IP — answer 1 or 0
curl "https://l2king.net/api/votes/ID?key=KEY&ip=1.2.3.4&format=txt"

# by IP — JSON answer
curl "https://l2king.net/api/votes/ID?key=KEY&ip=1.2.3.4"
{"voted":true,"time":"2026-10-07T23:09:32+00:00","vote_time":1791414572,"server_time":1791414600,"hours":12}

# by nickname — the same
curl "https://l2king.net/api/votes/ID?key=KEY&nick=PlayerNick"

Vote list

All votes for N hours (1 to 168) — for batch rewards by nickname.

BASHGET /api/votes/ID?key=…&hours=1…168
curl "https://l2king.net/api/votes/ID?key=KEY&hours=24"
{"project":184,"hours":24,"votes":[{"id":64,"nick":"PlayerNick","time":"2026-10-07T23:09:32+00:00"}]}

# as lines: id;nick;time
curl "https://l2king.net/api/votes/ID?key=KEY&hours=1&format=txt"
64;PlayerNick;2026-10-07 23:09:32

Project counters

Total votes, this month and in the last 12 hours — for a global reward to everyone online for every N votes.

BASHGET /api/votes/ID?key=…&total=1
curl "https://l2king.net/api/votes/ID?key=KEY&total=1"
{"project":184,"total":152,"month":37,"last12h":9,"server_time":1791418200}

.vote command (Java)

Vote check class — no external libraries, works on any Java server pack:

JAVAL2KingVote.java
// L2King: player vote check by IP (L2J, aCis, Mobius and other Java packs)
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

public final class L2KingVote
{
    private static final int PROJECT_ID = 0;          // project id from your L2King account
    private static final String API_KEY = "YOUR_KEY"; // key from your account, keep it private

    /** true if this IP voted on L2King in the last 12 hours */
    public static boolean hasVoted(String ip)
    {
        try
        {
            final URL url = new URL("https://l2king.net/api/votes/" + PROJECT_ID + "?key=" + API_KEY
                + "&format=txt&ip=" + URLEncoder.encode(ip, "UTF-8"));
            final HttpURLConnection con = (HttpURLConnection) url.openConnection();
            con.setConnectTimeout(5000);
            con.setReadTimeout(5000);
            con.setRequestProperty("User-Agent", "L2KingVote/1.0");
            try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), StandardCharsets.UTF_8)))
            {
                return "1".equals(in.readLine());
            }
        }
        catch (Exception e)
        {
            return false; // L2King unavailable — no reward now, the player will retry later
        }
    }
}

Example .vote command. Adjust the reward, time storage and player IP method to your pack:

JAVA.vote
// .vote command (example; method names depend on your pack):
// aCis:   player.getClient().getConnection().getInetAddress().getHostAddress()
// Mobius: player.getIPAddress()
final String ip = player.getIPAddress();
final long last = player.getVariables().getLong("L2KING_VOTE", 0);
if (System.currentTimeMillis() - last < 12 * 3600 * 1000L)
{
    player.sendMessage("Vote reward already received. Next one in 12 hours.");
    return true;
}
ThreadPool.execute(() ->
{
    if (L2KingVote.hasVoted(ip))
    {
        player.getVariables().set("L2KING_VOTE", System.currentTimeMillis());
        player.addItem("L2KingVote", 57, 1_000_000, player, true); // your reward
    }
    else
    {
        player.sendMessage("Vote first: https://l2king.net/en/vote/YOUR_PROJECT");
    }
});

L2King support in VDSystem (a ready reward module for Java packs) is in progress. Once L2King is on its list of supported topsites, you will only need to enable it in the module config.

PHP example

For a server website or web panel — check by nickname:

PHPvote.php
<?php
// Web panel or server website: vote check by nickname
$projectId = 0;          // project id from your L2King account
$key = 'YOUR_KEY';       // API key
$nick = $_POST['nick'];  // player nickname

$r = json_decode(file_get_contents('https://l2king.net/api/votes/' . $projectId
    . '?key=' . $key . '&nick=' . urlencode($nick)), true);

if (!empty($r['voted'])) {
    // vote found: give the reward and store $r['vote_time'],
    // so one vote is never rewarded twice
}

Rules

  • Check a vote when the player asks (command, panel button), not in a loop for everyone online.
  • No more than 120 requests per minute from one server.
  • One vote — one reward: store vote_time and do not reward again within 12 hours.
  • If the API did not respond, do not give the reward — the player will retry later.

Errors

403bad project id or keyWrong project id or API key
—no answerL2King unavailable: do not give the reward, the player will retry later

“Vote for us” button

A vote button on your server website gives a 25% discount on Elite, Top and VIP and sends players to your voting page. Ready code with your project, style and size is in the button constructor in your account. The monthly vote count on the button updates by itself.

HTMLCode example (YOUR_PROJECT — your project address on L2King)
<a href="https://l2king.net/en/vote/YOUR_PROJECT" target="_blank" rel="noopener"><img src="https://l2king.net/buttons/vote/YOUR_PROJECT/v-dark-en?w=193&h=60" width="193" height="60" alt="Vote for YOUR_PROJECT — L2KING.NET" style="border:0"></a>