Bakgrundsbild för Server Hytale webbplatsen

Kontrollera röststatus

Verifiera om en användare kan rösta på din server

Slutpunkt

GET/v1/votes/server/:serverToken/:ipAddress

Parametrar

serverTokenstring

Your server's unique identifier

ipAddressstring

The user's IP address (e.g., 192.168.1.1)

Svarsexempel

Can Vote

{
  "can_vote": true,
  "seconds_until_next_vote": 0
}

Cannot Vote Yet

{
  "can_vote": false,
  "seconds_until_next_vote": 86400
}

Kodexempel

async function checkVoteStatus(serverToken, userIp) {
  const url = `https://api.server-hytale.com/v1/votes/server/${serverToken}/${userIp}`;
  const res = await fetch(url);
  const { can_vote, seconds_until_next_vote } = await res.json();

  if (can_vote) {
    console.log('User can vote now!');
  } else {
    console.log(`User can vote in ${seconds_until_next_vote}s`);
  }
}

Behöver du hjälp?

Gå med i vår Discord-gemenskap för att få hjälp med att integrera vårt API i din applikation.