Developer Guides ‐ CRCON API - MarechJ/hll_rcon_tool GitHub Wiki
🧭 You are here : Wiki home / Developer Guides / CRCON API
Menu
CRCON API
There is an API for CRCON available at :
http://(your VPS IP):8010/api/
(sending API commands to the CRCON for the first -or only- game server)http://(your VPS IP):8011/api/
(for the second game server)- ...
CRCON API Endpoint Documentation
As of CRCON v11.1.0, there is 278 endpoints available.
You'll find the complete list of available endpoints here : http://(your VPS IP):8010/api/get_api_documentation
For each entry, you'll get :
- endpoint name
- required arguments and types
- API command return type
- description
auto_settings_capable
indicator- allowed HTTP request method (either POST or GET)
ie, for add_map_to_rotation
:
{
"endpoint": "add_map_to_rotation",
"arguments": {
"map_name": {
"default": null,
"annotation": "<class 'str'>"
},
"after_map_name": {
"default": "None",
"annotation": "str | None"
},
"after_map_name_number": {
"default": "None",
"annotation": "int | None"
}
},
"return_type": "<class 'str'>",
"doc_string": null,
"auto_settings_capable": true,
"allowed_http_methods": [
"POST"
]
},
Create API tokens
Most API endpoints require user authentication through an API token.
You can generate an API token in the admin panel.
[!NOTE]
The CRCON admin interface can be reached from all over the world, in any web browser.
For example (replace123.123.123.123
with your VPS IP) :
- Server 1 :
http://123.123.123.123:8010/admin
- Server 2 :
http://123.123.123.123:8011/admin
- Server 3 :
http://123.123.123.123:8012/admin
Each token you'll create will get the permissions of the user it belongs.
We advise you to create dedicated users for each API token you'll use, so you'll be able to give them specific permissions.
Create User
Create new user with permissions you wish for the API key to have.
- Login to the Admin interface at
http://(your VPS IP):8010/admin
- Click the '+Add' link, next to users
- Enter username and password and click
Save and continue editing
- The password can be random and forgotten, Steam ID isn't required.
- Ensure that the account has the
Active
checkbox checked. - Provide permission to user
- You can give specific permissions to each user via the Permissions section or Groups.
- If you want your API token to have full permissions, give "superuser" status to the user.
- Save your new user account.
Create an API Key
- Login to the Admin interface at
http://(your VPS IP):8010/admin
- Click the
+Add
link, next toDjango API Keys
[!IMPORTANT]
The API key will be provided in next step, make sure you copy this down and save it. You will not see it again.
- Fill out API details and click
Save
- Select the user that will own the API Key.
- Add notes (great for tracking API keys)
Using API examples
Curl Examples
Get Current Map rotation
curl https://(your VPS IP):8010/api/get_map_rotation -H "Authorization: Bearer <django-api-token>"
Get Historical Logs
curl -X POST https://(your VPS IP):8010/api/get_historical_logs -H "Authorization: Bearer <django-api-token>" -d '{"log_type":"KILL",
"limit":9999}'
Get Gamestate (hll_seed_vip)
curl -X POST https://(your VPS IP):8010/api/get_gamestate -H "Authorization: Bearer <django-api-token>"
Python Example
import requests
headers = {
"Authorization": "bearer 12345678-your-api-token-123456789",
"Connection": "keep-alive",
"Content-Type": "application/json"
}
data_request={
"player": "ThisGuy",
"steam_id_64": "765611981123456952",
"message": "test"
}
foo = requests.post("http://(your VPS IP):8010/api/do_message_player", data=json.dumps(data_request), headers=headers)
API Browser Tools
You can use Postman to send API requests to your CRCON.
Example config in Postman :