Documentation

NadeoServices plugin dependency

The NadeoServices plugin provides an easy interface into Trackmania's online services authentication.

NadeoServices outside of Openplanet

If you're looking to access the NadeoServices outside of Openplanet, this Gist contains information about authenticating with Nadeo's API externally.

Why use NadeoServices?

It is important to depend on the NadeoServices plugin if you intend to communicate with Nadeo's API in plugins! This is because authentication tokens aren't easy to reliably get in scripts, and multiple plugins trying to access the same token can cause the game to start behaving bad. The NadeoServices plugin takes care of cleanly accessing authentication tokens from the game and creating HTTP requests plugins.

Audiences

Nadeo's API has several types of tokens with different audiences. The following audiences exist:

  • NadeoLiveServices - Live API
  • NadeoClubServices - Club API, Competition API, Matchmaking API
  • NadeoServices - Core API

Note that you can't actually request the last audience with this plugin, and you don't need to - the game's API itself provides functions to access data on the core API.

Getting started

To get started with the NadeoServices plugin, add a dependency to it in your info.toml:

[script]
dependencies = [ "NadeoServices" ]

API

The API consists out of the following functions:

NadeoServices::AddAudience

Tells the NadeoServices plugin that you'd like to use a specific audience.

Parameters:

  • const string &in audience The audience you want to use.

NadeoServices::IsAuthenticated

Checks if the given audience is authenticated. You can only start making requests once the audience has been authenticated.

Parameters:

  • const string &in audience The audience you want to check.

Returns: bool

NadeoServices::BaseURL

Returns the base URL for the live API. (Requires the NadeoLiveServices audience)

Returns: string

NadeoServices::BaseURLClub

Returns the base URL for the club API. (Requires the NadeoClubServices audience)

Returns: string

NadeoServices::BaseURLCompetition

Returns the base URL for the competition API. (Requires the NadeoClubServices audience)

Returns: string

NadeoServices::BaseURLMatchmaking

Returns the base URL for the matchmaking API. (Requires the NadeoClubServices audience)

Returns: string

NadeoServices::Request

Create an HTTP request object with the correct authentication header for the audience already filled in. Throws an exception if the audience is not authenticated yet.

Parameters:

  • const string &in audience The audience you want to use.

Returns: Net::HttpRequest@

NadeoServices::Get

Creates a GET HTTP request with the correct authentication header for the audience already filled in. Throws an exception if the audience is not authenticated yet.

Parameters:

  • const string &in audience The audience you want to use.
  • const string &in url = "" The complete URL to request.

Returns: Net::HttpRequest@

NadeoServices::Post

Creates a POST HTTP request with the correct authentication header for the audience already filled in. Throws an exception if the audience is not authenticated yet.

Parameters:

  • const string &in audience The audience you want to use.
  • const string &in url = "" The complete URL to request.
  • const string &in body = "" The body of the POST request.
  • const string &in contentType = "application/json" The content type header to send.

Returns: Net::HttpRequest@

NadeoServices::Put

Creates a PUT HTTP request with the correct authentication header for the audience already filled in. Throws an exception if the audience is not authenticated yet.

Parameters:

  • const string &in audience The audience you want to use.
  • const string &in url = "" The complete URL to request.
  • const string &in body = "" The body of the POST request.
  • const string &in contentType = "application/json" The content type header to send.

Returns: Net::HttpRequest@

NadeoServices::Delete

Creates a DELETE HTTP request with the correct authentication header for the audience already filled in. Throws an exception if the audience is not authenticated yet.

Parameters:

  • const string &in audience The audience you want to use.
  • const string &in url = "" The complete URL to request.

Returns: Net::HttpRequest@

NadeoServices::Patch

Creates a PATCH HTTP request with the correct authentication header for the audience already filled in. Throws an exception if the audience is not authenticated yet.

Parameters:

  • const string &in audience The audience you want to use.
  • const string &in url = "" The complete URL to request.
  • const string &in body = "" The body of the POST request.
  • const string &in contentType = "application/json" The content type header to send.

Returns: Net::HttpRequest@

NadeoServices::GetDisplayNameAsync

Gets a display name from an account ID. Must be called from a yieldable function. If you want to fetch multiple display names, use NadeoServices::GetDisplayNamesAsync instead, as it will be much more efficient.

Parameters:

  • const string &in accountId The account ID to get the display name for.

Returns: string

NadeoServices::GetDisplayNameAsync

Gets multiple display names (as string) from their account IDs. Must be called from a yieldable function. If you want to fetch only a single display name you can also use GetDisplayNameAsync.

Parameters:

  • const array<string> &in accountIds The account IDs to get display names for.

Returns: dictionary


Page updated 8 months ago by Miss