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.
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.
# 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.
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:32Project counters
Total votes, this month and in the last 12 hours — for a global reward to everyone online for every N votes.
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:
// 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:
// .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:
<?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
bad project id or keyWrong project id or API keyno answerL2King unavailable: do not give the reward, the player will retry later