Getting Started

This section shows how you can get set-up with CoreLight Services and integrate the API into your game within a few minutes.


Setup Account

First thing to do is register an account at CoreLight Services if you haven't already. Go through the registration process as described and confirm your E-Mail address.

Should you face problems at any point in the registration process. Don't hesitate to contact our support at admin@corelightservices.com. We will get back to you as soon as possible to assist you.

Once you successfully logged in you should see Logged in as: ... at the top right of the website.

Setup Project

Before you can start using the API, you will need to create a project in your CoreLight Services account. A project can be a single game or a collection of games / applications which share common data like scoreboards, achievement and usage statistics.

To create a new project go to User-Menu / Projects / Create new

To use your project with the API you will have to generate an API-Key. in your projects dashboard page, select Create API-Key. A new API-Key will appear. You can always come back to your project page to view your API-Keys.

Integration

Depending on the type of framework / language you are using to develop your game, you can choose between different types of integration. When possible, we always recommend using one of our API-Integration libraries. There are implementations for different languages / frameworks to choose from:

C# .NET

CoreLightServices.API

API Documentation
Java

corelightservices-java-api

API Documentation
Python

Not available yet...

Soon

If none of those suit your needs, you can always talk to the CoreLightServices REST-API directly without the need of any extra libraries.

API

This section introduces you to the different ways of connecting to the CoreLight Services API.
For a detailed documentation visit our Doxygen Pages.


C# .NET (Xamarin / Unity / ...)

To each project that should use the CoreLight Services API, add the CoreLightServices.API NuGet package:

PM> Install-Package CoreLightServices.API -Version 1.4.2.1
> dotnet add package CoreLightServices.API --version 1.4.2.1
<PackageReference Include="CoreLightServices.API" Version="1.4.2.1" ⁄>
> paket add CoreLightServices.API --version 1.4.2.1

Once installed, you can begin writing code. Usually the first thing to do is instantiating CLSApiContext:

public string ApiKey = "## API-KEY ##";

...

CLSApiContext apiContext = new CLSApiContext(ApiKey);
bool valid = await apiContext.ValidateKeyAsync();

Since initializing CLSApiContext does not generate overhead you are free to either initialize once and use from different places inside your game or create a new instance everytime you need one. The API key is not validated until you call ValidateKeyAsync() or any other request method on CLSApiContext.

It is not required to call ValidateKeyAsync() prior to using any request method, although calling a request method with an invalid API key will throw an exception.

try {
   CLSScoreboard scoreboard =
      await apiContext.GetScoreboardResultsAsync("## SCOREBOARD API REFERENCE ##");

   Console.WriteLine("Results:");
   foreach(CLSScoreboardEntry entry in scoreboard.Entries)
   {
      Console.WriteLine($"#{entry.Rank}: {entry.Player.Name} ({entry.Value} Points)");
   }
}
catch (CLSApiException exception) {
   // something went wrong
}

This is an example request for querying scoreboard results. For brevity the catch block catches the more abstract CLSApiException. There are more exception classes all derriving from CLSApiException which you can catch to handle different error cases.

The different request methods, return types and exception classes are documented in the DoxyGen pages.

Java

To each project that should use the CoreLight Services API, add the corelightservices-java-api repository:

<dependency>
   <groupId>com.corelightservices</groupId>
   <artifactId>corelightservices-java-api</artifactId>
   <version>1.4.2.0</version>
   <type>bundle</type>
</dependency>
implementation 'com.corelightservices:corelightservices-java-api:1.4.2.0'
implementation("com.corelightservices:corelightservices-java-api:1.4.2.0")
<dependency org="com.corelightservices" name="corelightservices-java-api" rev="1.4.2.0" />

Once installed, you can begin writing code. Usually the first thing to do is instantiating CLSApiContext:

public string ApiKey = "## API-KEY ##";

...

CLSApiContext apiContext = new CLSApiContext(ApiKey);
boolean valid = apiContext.ValidateKey();

Since initializing CLSApiContext does not generate overhead you are free to either initialize once and use from different places inside your game or create a new instance everytime you need one. The API key is not validated until you call ValidateKeyAsync() or any other request method on CLSApiContext.

It is not required to call ValidateKeyAsync() prior to using any request method, although calling a request method with an invalid API key will throw an exception.

try {
   CLSScoreboard scoreboard =
      apiContext.GetScoreboardResults("## SCOREBOARD API REFERENCE ##", 10);

   System.out.println("Results:");
   for(CLSScoreboardEntry entry : scoreboard.getEntries())
   {
      System.out.println("#" + entry.getRank() + ":" +
         entry.Player.getName() + "(" + entry.getValue() + "Points)");
   }
}
catch (CLSApiException exception) {
   // something went wrong
}

This is an example request for querying scoreboard results. For the sake of brevity the catch block catches the more abstract CLSApiException. There are more exception classes all derriving from CLSApiException which you can catch to handle different error cases.

The different request methods, return types and exception classes are documented in the JavaDoc pages.

Python
The CoreLight API Python library will be available soon.
REST - API
The CoreLight REST API documentation will be available soon.