Quick start
From zero to your first request in about five minutes.
1. Create a project#
- Create an account and sign in to the dashboard.
- Create a project and keep Add Starter sample content switched on. It creates the
coinsleaderboard, thedaily_coinsreward and a few config keys used throughout these docs. - Open API keys to find the Base URL, the Project ID and the client key (
pk_live_…).
2. Install the SDK#
- Download the Unity SDK from the project page and import it with Assets ▸ Import Package ▸ Custom Package…
- Open Tools ▸ Majacloud ▸ Setup, paste the Base URL, Project ID and client key, then press Test connection.
- Optional: open Tools ▸ Majacloud ▸ Open Starter Sample and press Play to try every service.
- Download the Godot SDK and unzip it into your project so you have
addons/majacloud. - Enable Majacloud under Project ▸ Project Settings ▸ Plugins. This adds the
Majacloudautoload. - Fill in Project Settings ▸ Majacloud, then run Project ▸ Tools ▸ Majacloud: Test connection.
- Add the script tag below to your page (or copy
majacloud.jsinto your project). - Create a client with the Base URL, Project ID and client key. Serve the page over HTTPS (localhost is fine while developing).
<script src="https://majacloud.majanite.com/downloads/majacloud-web-1.0.0.js"></script>
<script type="module">
const mc = Majacloud.createClient({ baseUrl: 'https://majacloud.majanite.com', projectId: '<project id>', clientKey: 'pk_live_…' });
</script>Any HTTP client works. Send X-Project-ID and X-Client-Key with every request, and Authorization: Bearer <access_token> for player calls.
3. Sign in and call a service#
Paste this into your game. It signs the player in as a guest, submits a score and reads a config value.
using MajacloudSdk;
using UnityEngine;
public class GameStart : MonoBehaviour
{
private async void Start()
{
// Restores the saved session or creates a guest
var signIn = await Majacloud.Auth.SignInAnonymouslyAsync();
if (!signIn.Ok)
{
Debug.LogWarning(signIn.Error.Message);
return;
}
Debug.Log("Hello " + signIn.Value.DisplayName);
await Majacloud.Leaderboards.SubmitScoreAsync("coins", 120);
int damage = Majacloud.RemoteConfig.GetInt("enemy_damage", 25);
}
}extends Node
func _ready() -> void:
# Restores the saved session or creates a guest
var signed_in := await Majacloud.auth.sign_in_anonymously()
if not signed_in.ok:
push_warning(signed_in.message)
return
print("Hello ", signed_in.value.display_name)
await Majacloud.leaderboards.submit_score("coins", 120)
var damage := Majacloud.remote_config.get_int("enemy_damage", 25)const mc = Majacloud.createClient({
baseUrl: 'https://majacloud.majanite.com',
projectId: '<project id>',
clientKey: 'pk_live_…',
});
// Restores the saved session or creates a guest
const signIn = await mc.auth.signInAnonymously();
if (!signIn.ok) throw new Error(signIn.error.message);
console.log('Hello ' + signIn.value.display_name);
await mc.leaderboards.submitScore('coins', 120);
await mc.remoteConfig.fetch();
const damage = mc.remoteConfig.getInt('enemy_damage', 25);export PROJECT_ID="<project id>" CLIENT_KEY="pk_live_…"
# Create a guest; keep access_token and refresh_token from the response
curl -X POST https://majacloud.majanite.com/v1/auth/guest -H "X-Project-ID: $PROJECT_ID" -H "X-Client-Key: $CLIENT_KEY" \
-H "Content-Type: application/json" -d '{}'
export TOKEN="<access_token>"
curl -X POST https://majacloud.majanite.com/v1/leaderboards/coins/scores -H "X-Project-ID: $PROJECT_ID" -H "X-Client-Key: $CLIENT_KEY" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" -d '{"score": 120}'4. Check the dashboard#
Open your project in the dashboard: the Getting started card switches to Connected, and every request appears under Logs with its status, latency and request ID.
Next steps#
- Players and sign-in: display names and linking guests to email or Google.
- Leaderboards: resets, periods and anti-cheat.
- Remote config: live values with signature verification.
- Cloud save and rewards.