Points API
The points API for consumer apps
Trophy is the points API for consumer apps, adding XP, coins, loyalty points, and levels to your app with a few API calls. Automatically award points for user actions, level up users, and apply multiplers for events, all with full ledger tracking and anti-cheat safeguards.
Quickstart
Quickstart: award and read XP
Configure a points system and metric triggers in the Trophy dashboard (or via MCP), then award points by sending metric events. Fetch the user’s balance, awards, and level for your UI.
import { TrophyApiClient } from "@trophyso/node";
const trophy = new TrophyApiClient({ apiKey: process.env.TROPHY_API_KEY });
// 1. Award XP by tracking the metric that powers your points trigger
const eventResponse = await trophy.metrics.event("workouts", {
user: { id: "user-123" },
value: 1,
});
console.log("Points awarded:", eventResponse.points);
// 2. Read the user's balance, recent awards, level, and maxPoints cap
const points = await trophy.users.points("user-123", "xp");
console.log("Total:", points.total);
console.log("Max points:", points.maxPoints);
console.log("Recent awards:", points.awards);Buy vs. build
Why use Trophy's points API?
Building a reliable points system API requires ledger-grade consistency. Every award, multiplier, and deduction must be atomic — and getting that right in-house is harder than it looks.
Integration Time
Reliability
Scalability
Ongoing Maintenance
Feature Development
Endpoints
Points endpoints
Use Trophy's points API to award and track XP, loyalty points, or any custom currency. Points accrue automatically from metric events with full ledger history and anti-cheating safeguards.
Send a metric event to track user activity and award points.
Path Parameters
keystringrequiredUnique reference of the metric as set when created.
Request Body
userUserrequiredThe user that triggered the event (must include id).
valuenumberrequiredThe value to add to the user's current total for the given metric.
Response
eventIdstringUnique identifier for the created event.
totalnumberThe user's new total for this metric.
pointsPoints[]Points awarded by this event, keyed by points system.
import { TrophyApiClient } from '@trophyso/node';
const trophy = new TrophyApiClient({
apiKey: 'YOUR_API_KEY'
});
// Track a user event
await trophy.metrics.event("lessons", {
user: {
id: "user-123"
},
value: 1
}
);
// This single event:
// - Records user activity
// - Awards points
// - Returns new points balance
Get a user's points for a specific points system, including recent awards.
Path Parameters
idstringrequiredID of the user.
keystringrequiredKey of the points system.
Query Parameters
awardsintegerNumber of recent point awards to return (default: 10).
Response
namestringDisplay name of the points system.
totalnumberTotal points accumulated.
maxPointsnumberMaximum points cap (null if unlimited).
awardsAward[]Recent point awards with trigger details.
import { TrophyApiClient } from '@trophyso/node';
const trophy = new TrophyApiClient({
apiKey: 'YOUR_API_KEY'
});
// Fetch user points balance
const points = await trophy.users
.points("user-123", "xp");
// Response:
// {
// key: "xp",
// name: "XP",
// total: 2450,
// awards: [{
// awarded: 10,
// trigger: {...}
// }]
// }Create points boosts for multiple users. Boosts multiply points earned during a time period.
Request Body
systemKeystringrequiredKey of the points system to boost.
boostsarrayrequiredArray of boost objects with userId, name, multiplier, start, and optional end.
Response
createdBoost[]Successfully created boost objects.
issuesIssue[]Warnings or errors for each boost request.
import { TrophyApiClient } from '@trophyso/node';
const trophy = new TrophyApiClient({
apiKey: 'YOUR_API_KEY'
});
// Create a points boost
await trophy.admin.points.boosts.create({
systemKey: "xp",
boosts: [{
userId: "user-123",
name: "Double XP Weekend",
start: '2024-01-01',
end: '2024-01-03',
multiplier: 2
}]
});Built for production workloads
Reliable infrastructure designed for performance at scale.
- Uptime SLA
- 99.99%
- p95 API Latency
- 200ms
- Monthly API Requests
- 150M
- Users Tracked
- 1M+
FAQ
Frequently asked questions
Have a different question and can’t find the answer you’re looking for? Send us an email.
Get started