Use Takaro data in your own app
You can read your community’s data from Takaro and show it anywhere: a website, a launcher, a Discord bot or a status board. This guide covers the common reads and, more importantly, how to do it without leaking your key.
You need an API key first. See API and Settings and account. The examples read it from TAKARO_API_KEY.
Keep your key safe
Section titled “Keep your key safe”Pick one of these:
- Call Takaro from your own small backend (recommended). Your website or launcher calls your server, and your server calls Takaro with the key. The key never leaves your server.
- Use a domain key with a read-only role. Create a role that only has
READ_PLAYERS, then create a domain key with only that role. Add a scope ofREAD_PLAYERSand an IP allowlist of your server’s address. If it leaks, it can read player data from that address and nothing else.
Even with option 2, only call Takaro from a server you control. For a public page, have your backend fetch the data every minute or so and serve a cached copy.
Find your game server ID
Section titled “Find your game server ID”Player data is per game server. You identify a server by its Takaro UUID, not by its IP address and port. List your servers:
curl -X POST https://api.takaro.io/gameserver/search \ -H "Authorization: Bearer $TAKARO_API_KEY" \ -H "Content-Type: application/json" \ -d '{}'Each result has an id and a name. You can also copy the ID from the URL when you open the server in the dashboard.
Read player data
Section titled “Read player data”POST /gameserver/player/search returns one record per player on a server. It needs the READ_PLAYERS permission. Each record includes currency, playtimeSeconds, online, lastSeen, ping and the player’s position.
Who is online
Section titled “Who is online”curl -X POST https://api.takaro.io/gameserver/player/search \ -H "Authorization: Bearer $TAKARO_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "filters": { "gameServerId": ["<game-server-id>"], "online": [true] }, "extend": ["player"], "limit": 100 }'extend: ["player"] adds the player’s name and platform IDs to each record. Without it you only get IDs.
Currency and playtime
Section titled “Currency and playtime”The same request answers both. Drop the online filter to include players who are offline, and read currency and playtimeSeconds (in seconds) from each record:
curl -X POST https://api.takaro.io/gameserver/player/search \ -H "Authorization: Bearer $TAKARO_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "filters": { "gameServerId": ["<game-server-id>"] }, "extend": ["player"], "limit": 100 }'Leaderboard
Section titled “Leaderboard”Sort by currency, highest first. Use "playtimeSeconds" for a playtime board.
curl -X POST https://api.takaro.io/gameserver/player/search \ -H "Authorization: Bearer $TAKARO_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "filters": { "gameServerId": ["<game-server-id>"] }, "extend": ["player"], "sortBy": "currency", "sortDirection": "desc", "limit": 10 }'One player
Section titled “One player”curl https://api.takaro.io/gameserver/<game-server-id>/player/<player-id> \ -H "Authorization: Bearer $TAKARO_API_KEY"<player-id> is the player’s Takaro ID, which you can get from the search above.
For more than 100 players, page through results with page and limit. See Querying data.
Next steps
Section titled “Next steps”- API explains keys, scope and errors.
- The API reference lists every operation, with the permission each one needs.