This is an early version of Ledge Developer Docs. Our API is still in early stages of development and is subject to change.
Welcome to Ledge Developer Docs. We are constantly improving and we'd greatly appreciate your feedback, so please feel free to create issues or chat with ethan@theledge.io.
- We recommend you use our SDK on the server side for performance and security.
- Ideally, have our SDK integrated and ready for testing 1-2 weeks before the event start date.
- Optionally, setup a chat with our devs to ensure smooth integration.
- API_KEY from one of the Ledge Admins, get in contact (ethan@theledge.io)!
- API_URL from one of the Ledge Admins, get in contact (ethan@theledge.io)!
1. Install our npm package at npm package
npm i @ledgelabs/typescript-api-client
or
yarn add @ledgelabs/typescript-api-client
import { Configuration } from "@ledgelabs/typescript-api-client";
const config = new Configuration({
apiKey: API_KEY
basePath: API_URL,
});
If you've chosen Unique Player Email Method (Recommended), go to step 4.
If you've chosen Unique Player ID Method, go to step 5 & 6.
You can begin tracking player game data right away.
import { ExternalApi } from "@ledgelabs/typescript-api-client";
const ledgeApi = new ExternalApi(config);
await ledgeApi.trackActivity({
email: "myplayeremail@email.com",
activityId: "kill-5-ogres",
occurrence: "2024-04-20T18:18:03.369Z",
userId: "unique-user-id",
count: 1,
});
You're done!
- To start tracking player game data as soon as possible, register this user right when they open the game.
- Original creation date is when this user first joined your game.
- Return this response to the client side
import { ExternalApi } from "@ledgelabs/typescript-api-client";
const ledgeApi = new ExternalApi(config);
const response = await ledgeApi.registerUser("fake-api-key", {
userId: "fake-user-id",
username: "random-fake-username",
originalCreationDate: new Date().toISOString(),
});
await ledgeApi.trackActivity({
activityId: "kill-5-ogres",
occurrence: "2024-04-20T18:18:03.369Z",
userId: "unique-user-id",
count: 1,
});
Property | Description |
---|---|
code | Ledge Specific status code which follows HTTP response status codes for the most part. |
message | Error message associated with this error code |
403
Invalid Api Key. Please reach out to Ledge.
400
Bad Request (e.g missing data, invalid inputs).
409
Conflict: User not registered, skipping this user. Make sure this user is registered with the ledge via registerUser
500
Internal Server Error.