The Trophy Node SDK provides convenient access to the Trophy API from applications written in server-side JavaScript.
Trophy provides APIs and tools for adding gamification to your application, keeping users engaged through rewards, achievements, streaks, and personalized communication.
Install the package with:
npm install @trophyso/node
The package needs to be configured with your account's API key, which is available in the Trophy web interface. Set the API key with the following:
const { TrophyApiClient } = require('@trophyso/node');
const trophy = new TrophyApiClient({ apiKey: 'your-api-key' });
You can now access the Trophy API through the trophy
object.
trophy.metrics.event('words-written', {
user: {
id: '18',
email: '[email protected]',
tz: 'Europe/London',
},
value: 750,
});
Trophy maintains types for this SDK. You can use them without any additional configuration.
See the Trophy API Docs for more information on the accessible endpoints.