Skip to content

API

For a hands-on experience and quick start with the Takaro API, visit the interactive API documentation. You can explore endpoints, make test requests, and view responses in real-time.

To use the API programmatically, authenticate by calling the login endpoint with your credentials. This returns a session token you can use for subsequent requests.

Send a POST request to /login with your email and password:

Terminal window
curl -X POST https://api.takaro.io/login \
-H "Content-Type: application/json" \
-d '{"username": "your-email@example.com", "password": "your-password"}'

The response contains your session token:

{
"meta": {},
"data": {
"token": "your-session-token"
}
}

If you don’t have login credentials (your email and password), ask your server administrator to create them for you.

Include the token as a Bearer token in the Authorization header on all subsequent requests:

Terminal window
curl -X POST https://api.takaro.io/gameserver/search \
-H "Authorization: Bearer your-session-token" \
-H "Content-Type: application/json" \
-H "x-takaro-domain: your-domain-id" \
-d '{}'

The token is valid for the duration of your session. If you receive a 401 Unauthorized response, log in again to get a fresh token.

Takaro is a multi-tenant platform. Each domain is an isolated environment with its own game servers, players, modules, and settings. When you make API calls, you need to tell the API which domain you’re operating in.

There are two ways to specify your domain:

HTTP header (recommended for API integrations):

Add the x-takaro-domain header to your requests, as shown in Using your token above.

Cookie (used by the web dashboard):

The Takaro dashboard uses a takaro-domain cookie to track your selected domain. The dashboard sets this cookie automatically when you switch domains in the UI via the POST /selected-domain/:domainId endpoint. You typically don’t need to manage this cookie manually.

If you don’t specify a domain, the API defaults to your first active domain.

After logging in, call GET /me to see your available domains:

Terminal window
curl https://api.takaro.io/me \
-H "Authorization: Bearer your-session-token"

The response includes your domains:

{
"meta": {},
"data": {
"user": { "..." : "..." },
"domains": [
{ "id": "your-domain-id", "name": "My Game Community" }
],
"domain": "your-domain-id"
}
}

Use the id value as your x-takaro-domain header.

Putting it all together — log in, find your domain, and list your game servers:

Terminal window
# 1. Log in
TOKEN=$(curl -s -X POST https://api.takaro.io/login \
-H "Content-Type: application/json" \
-d '{"username": "your-email@example.com", "password": "your-password"}' | jq -r '.data.token')
# 2. Get your domain ID
DOMAIN=$(curl -s https://api.takaro.io/me \
-H "Authorization: Bearer $TOKEN" | jq -r '.data.domain')
# 3. List game servers
curl -X POST https://api.takaro.io/gameserver/search \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-H "x-takaro-domain: $DOMAIN" \
-d '{}'

Takaro API provides powerful querying capabilities through its various POST /search endpoints. You can use these endpoints to retrieve data based on specific criteria. The querying features include filters for exact matches, searches for partial matches, and pagination for handling large data sets.

Filters allow you to specify exact match criteria for the data you are querying. When you use filters, the API will return only the records that exactly match the specified criteria.

{
"filters": {
"name": ["John Doe"],
"email": ["john.doe@example.com"]
}
}

In the above example, the API will return records where the name is exactly “John Doe” and the email is exactly “john.doe@example.com”.

Searches, on the other hand, allow for partial matches. This is useful when you are looking for records that contain a specific substring.

{
"search": {
"name": ["John"]
}
}

In the above example, the API will return all records where the name contains the substring “John”.

When querying large data sets, it’s often useful to retrieve the data in smaller chunks or pages. You can use the page and limit parameters to achieve this.

{
"page": 2,
"limit": 10
}

In the above example, the API will return the second page of results, with a limit of 10 records per page.

The extend parameter allows you to include related entities in the response. This reduces the need for multiple API calls and improves performance when you need associated data.

{
"extend": ["roles", "gameServers"]
}

When using extend, the related data will be included in the response object under the property name specified in the extend array. This makes it easy to access all necessary information in a single request.

Some endpoints support nested extends using dot notation:

{
"extend": ["listing.items.item"]
}

This will include the listing, its items, and the full item details for each item in the shop order response.

You can combine filters, searches, pagination, and extend in a single query. Here is an example that combines all features:

{
"filters": {
"email": ["john@example.com"]
},
"search": {
"name": ["John"]
},
"page": 1,
"limit": 5,
"extend": ["roles", "gameServers"]
}

This query will return the first page of records where the email field exactly matches “john@example.com”, and the name field contains the substring “John”, with a maximum of 5 records in the response, including the related roles and gameServers data for each record.

The Takaro API returns error information within the response data. In case an error occurs, you should inspect the meta.error property in the response data for details about the error.

If there is an error in the API response, it might look like this:

{
"meta": {
"error": {
"code": "ValidationError",
"details": {}
}
},
"data": null
}

In this example, the meta.error property will contain a description of the error.

To interact with the Takaro API programmatically, you can use the @takaro/apiclient library. Install it via npm:

Terminal window
npm install @takaro/apiclient

Then use it in your project:

import { Client } from '@takaro/apiclient';
const client = new Client({
url: 'https://api.takaro.io',
auth: {
username: 'your-email@example.com',
password: 'your-password',
},
});
// Log in and get your token
await client.login();
// Set your domain context
client.setDomain('your-domain-id');
// Make authenticated requests
const servers = await client.gameserver.gameServerControllerSearch();

For full API coverage, see the interactive API documentation.