Difference between revisions of "API"

From Tycoon Gaming
m
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 +
{{otherlang
 +
  | noborder=true
 +
  | nl=NL:API
 +
}}
 +
 
== Transport Tycoon API ==
 
== Transport Tycoon API ==
Root API URI is het adres van de server
+
Root API URI is the servers address
  
API is beschikbaar per server instantie
+
API is available per server instance
  
 
=== API Keys ===
 
=== API Keys ===
  
 
TL;DR:
 
TL;DR:
Maak een nieuwe key met '''/api key new'''
+
Create a new key using '''/api key new'''
  
Voeg charges toe met '''/api key refill''' (voegt 1000 charges voor $1M)
+
Add charges using '''/api key refill''' (adds 1000 charges for $1M)
  
  
De API vereist een API-sleutel om toegang te krijgen tot de meeste functies.
+
The API requires an API Key to access most features.
  
Elke sleutel heeft een beperkt aantal API Calls (ook wel charges genoemd), die elke keer dat een API Call wordt gedaan met de key wordt verbruikt.
+
Each key has a limited amount of API calls (also called charges), which is consumed every time an API call is made using the key.
  
Extra cahrges kunnen in de game worden gekocht met de '''/api key refill''' command voor de kost van $1000 (in-game geld) per charge.
+
Additional charges can be purchased in-game using the '''/api key refill''' command at the cost of $1000 (in-game money) per charge.
  
Elke gebruiker kan een API Key genereren, deze key is de privésleutel van de gebruiker.
+
Any user can generate an API key, this key is said users private key.
  
Om een key te genereren, gebruikt u de'''/api key new''' command in-game.
+
To generate a key, use the '''/api key new''' command in-game.
  
Als u al een key heeft gegenereerd, wordt de oude verwijderd en komt er een nieuwe in de plaats.
+
If you already have a key generated, the old one will be deleted and a new one takes its place.
  
Wanneer u voor de eerste keer een key genereert, worden er enkele gratis charges voor in rekening gebracht, zodat u de API gratis kunt testen.
+
When you generate a key for the first time, it will come with some free charges allowing you to test the API for free.
  
De API key kan worden gekopieerd met de '''/api key copy''' command. (Dit zal uw key op het scherm laten zien!)
+
The API Key can be copied using the '''/api key copy''' command. (This will show your key on screen!)
  
=== Voor developers ===
+
=== For developers ===
De API key moet worden geplaatst als een `X-Tycoon-Key` header.
+
The API Key must be placed as an `X-Tycoon-Key` header.
  
=== Key Gerelateerde Endpoints ===
+
=== Key Related Endpoints ===
  
 
/charges.json
 
/charges.json
Geeft het resterende charges terug (geen charges verbruikt om te controleren)
+
Returns the amount of charges left (does not cost charges to check)
  
=== Legenda ===
+
=== Legend ===
  type name (gegevenstype en een eigenschapnaam)
+
  type name (data type and a property name)
  
  type? name (het gegevenstype kan variëren op basis van de gegevenscontext)
+
  type? name (data type may vary based on data context)
  
  type! name (gegevens bestaan mogelijk niet op basis van gegevenscontext)
+
  type! name (data might not exist based on data context)
'''Note:''' Array-gegevenstypen bevatten geen benoemde eigenschappen, de namen die hier worden gebruikt, zijn ter verduidelijking
+
'''Note:''' Array data types do not contain named properties, the names used here are for clarifiation
  
=== Krijg wereldinformatie voor online spelers ===
+
=== Get world information for online players ===
Retourneert een lijst met alle online spelers met positiegegevens.
+
Returns a list of all online players with positional data.
  
Hun huidige vervoerswijze en enkele andere details zijn ook opgenomen.
+
Their current mode of transportation and some other details are also included.
  
Dit eindpunt wordt gebruikt om de live map van de server te produceren.
+
This endpoint is used to produce the servers livemap.
  
 
  GET /status/map/positions.json
 
  GET /status/map/positions.json
Line 75: Line 80:
 
  --- string name
 
  --- string name
  
=== Krijg servergegevens en online spelers ===
+
=== Get server details and online players ===
Retourneert de servernaam en details, evenals gegevens voor elke online speler.
+
Returns the servers name and details, as well as data for every player online.
  
Dit eindpunt wordt gebruikt om de serverlijst te produceren: http://connect.tycoon.community/
+
This endpoint is used to produce the server list: http://connect.tycoon.community/
  
 
  GET /status/widget/players.json
 
  GET /status/widget/players.json
Line 109: Line 114:
  
 
=== Airline Routes ===
 
=== Airline Routes ===
Retourneert de actieve Airline Pilot-routes op de server
+
Returns the active Airline Pilot routes on the server
  
 
  GET /status/airline.json
 
  GET /status/airline.json
Line 124: Line 129:
 
  -- bool atTerminal
 
  -- bool atTerminal
  
=== Krijg resourceconfiguraties ===
+
=== Get resource configurations ===
Dit kan worden gebruikt om gemakkelijk vectorgegevens voor routes enz. In bepaalde banen te krijgen
+
This can be used to easily get vector data for routes etc. in certain jobs
Niet alle bronnen hebben zichtbare configuraties
+
Not all resources have viewable configs
  
 
  GET /status/config/[resource]
 
  GET /status/config/[resource]
 
  returns a raw .lua file dump
 
  returns a raw .lua file dump
  
=== Top10 Statistieken ===
+
=== Top10 Stats ===
Retourneert een lijst met de top 10 voor de stat in aflopende volgorde.<br>
+
Returns a list of the top 10 for the stat in descending order.<br>
Notitie: Gebruikersnamen zijn nogal onbetrouwbaar, dus de kans is groot dat ze een verkeerde indeling hebben of ongeldige tekens bevatten.
+
Note: Usernames are kinda unreliable so likely theyll be malformed or include invalid characters.
  
Enkele geldige statistieken:<br>
+
Some valid stats:<br>
 
firefighter_streak_record<br>
 
firefighter_streak_record<br>
 
omni_void_leaderboard<br>
 
omni_void_leaderboard<br>

Latest revision as of 00:15, 17 October 2020

Nederlands

Transport Tycoon API

Root API URI is the servers address

API is available per server instance

API Keys

TL;DR: Create a new key using /api key new

Add charges using /api key refill (adds 1000 charges for $1M)


The API requires an API Key to access most features.

Each key has a limited amount of API calls (also called charges), which is consumed every time an API call is made using the key.

Additional charges can be purchased in-game using the /api key refill command at the cost of $1000 (in-game money) per charge.

Any user can generate an API key, this key is said users private key.

To generate a key, use the /api key new command in-game.

If you already have a key generated, the old one will be deleted and a new one takes its place.

When you generate a key for the first time, it will come with some free charges allowing you to test the API for free.

The API Key can be copied using the /api key copy command. (This will show your key on screen!)

For developers

The API Key must be placed as an `X-Tycoon-Key` header.

Key Related Endpoints

/charges.json Returns the amount of charges left (does not cost charges to check)

Legend

type name (data type and a property name)
type? name (data type may vary based on data context)
type! name (data might not exist based on data context)

Note: Array data types do not contain named properties, the names used here are for clarifiation

Get world information for online players

Returns a list of all online players with positional data.

Their current mode of transportation and some other details are also included.

This endpoint is used to produce the servers livemap.

GET /status/map/positions.json
object
- int time
- array[array player] data
-- string name
-- int source
-- int user_id
-- vec3 position
-- object owned_vehicles
--- object[string vehicle_type]!
---- string vehicle_spawn
-- object vehicle
--- int vehicle_class
--- string vehicle_type
--- int! model
--- string! vehicle_label
--- string! vehicle_name
--- bool? has_trailer
--- string! trailer
--- string! vehicle_spawn
-- object job
--- string group
--- string name

Get server details and online players

Returns the servers name and details, as well as data for every player online.

This endpoint is used to produce the server list: http://connect.tycoon.community/

GET /status/widget/players.json
object
- object server
-- string name
-- string motd
-- string number
-- string region
-- string beta
-- string uptime
-- int limit
- array[array player] players
-- string name
-- int source
-- int user_id
-- string? avatar
-- bool staff
-- string job_name
-- bool whitelist

Get Online Players

Returns a list of online players

GET /status/players.json
array players
- string name
- int? source
- int user_id

Airline Routes

Returns the active Airline Pilot routes on the server

GET /status/airline.json
object
- object[string player] player
-- string plane
-- object destination
--- float x
--- float y
--- float z
--- float h
--- string airport
--- string name
-- bool atTerminal

Get resource configurations

This can be used to easily get vector data for routes etc. in certain jobs Not all resources have viewable configs

GET /status/config/[resource]
returns a raw .lua file dump

Top10 Stats

Returns a list of the top 10 for the stat in descending order.
Note: Usernames are kinda unreliable so likely theyll be malformed or include invalid characters.

Some valid stats:
firefighter_streak_record
omni_void_leaderboard
ems_streak_record
houses_crafted
toll_paid
drops_collected

GET /status/top10/[stat]
object
-array top
-- int user_id
-- string user_name
-- int stat_count