JavaScript
import { TrophyApiClient } from '@trophyso/node';
const trophy = new TrophyApiClient({
apiKey: 'YOUR_API_KEY'
});
const response = await trophy.users.allMetrics("user-id");from trophy import TrophyApi
client = TrophyApi(api_key='YOUR_API_KEY')
response = client.users.all_metrics("user-id")import (
"context"
trophyclient "github.com/trophyso/trophy-go/client"
"github.com/trophyso/trophy-go/option"
)
client := trophyclient.NewClient(
option.WithApiKey("YOUR_API_KEY"),
)
response, err := client.Users.AllMetrics(context.TODO(), "user-id")curl --request GET \
--url https://api.trophy.so/v1/users/{id}/metrics \
--header 'X-API-KEY: <api-key>'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.trophy.so/v1/users/{id}/metrics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.trophy.so/v1/users/{id}/metrics")
.header("X-API-KEY", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trophy.so/v1/users/{id}/metrics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-KEY"] = '<api-key>'
response = http.request(request)
puts response.read_body[
{
"id": "d01dcbcb-d51e-4c12-b054-dc811dcdc623",
"key": "words-written",
"name": "Words written",
"current": 4500,
"achievements": [
{
"id": "abe3120f-5ca9-4344-92c8-5b891643a04b",
"trigger": "metric",
"name": "Novice Writer",
"description": "null",
"metricId": "d01dcbcb-d51e-4c12-b054-dc811dcdc623",
"metricValue": 500,
"achievedAt": "2021-01-01T00:00:00Z",
"badgeUrl": "https://example.com/badge1.png"
},
{
"id": "8a07f2d0-9c72-4de1-bf92-9530ae82b4b6",
"trigger": "metric",
"name": "Intermediate Writer",
"description": "null",
"metricId": "d01dcbcb-d51e-4c12-b054-dc811dcdc623",
"metricValue": 1000,
"achievedAt": "2021-01-02T00:00:00Z",
"badgeUrl": "https://example.com/badge2.png"
},
{
"id": "2090d038-aa04-4048-ab2e-e2b7bf2d3b9f",
"trigger": "metric",
"name": "Expert Writer",
"description": "null",
"metricId": "d01dcbcb-d51e-4c12-b054-dc811dcdc623",
"metricValue": 2000,
"achievedAt": null,
"badgeUrl": "null"
}
]
}
]{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Users
Get all metrics for a user
Get a single user’s progress against all active metrics.
GET
/
users
/
{id}
/
metrics
JavaScript
import { TrophyApiClient } from '@trophyso/node';
const trophy = new TrophyApiClient({
apiKey: 'YOUR_API_KEY'
});
const response = await trophy.users.allMetrics("user-id");from trophy import TrophyApi
client = TrophyApi(api_key='YOUR_API_KEY')
response = client.users.all_metrics("user-id")import (
"context"
trophyclient "github.com/trophyso/trophy-go/client"
"github.com/trophyso/trophy-go/option"
)
client := trophyclient.NewClient(
option.WithApiKey("YOUR_API_KEY"),
)
response, err := client.Users.AllMetrics(context.TODO(), "user-id")curl --request GET \
--url https://api.trophy.so/v1/users/{id}/metrics \
--header 'X-API-KEY: <api-key>'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.trophy.so/v1/users/{id}/metrics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.trophy.so/v1/users/{id}/metrics")
.header("X-API-KEY", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trophy.so/v1/users/{id}/metrics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-KEY"] = '<api-key>'
response = http.request(request)
puts response.read_body[
{
"id": "d01dcbcb-d51e-4c12-b054-dc811dcdc623",
"key": "words-written",
"name": "Words written",
"current": 4500,
"achievements": [
{
"id": "abe3120f-5ca9-4344-92c8-5b891643a04b",
"trigger": "metric",
"name": "Novice Writer",
"description": "null",
"metricId": "d01dcbcb-d51e-4c12-b054-dc811dcdc623",
"metricValue": 500,
"achievedAt": "2021-01-01T00:00:00Z",
"badgeUrl": "https://example.com/badge1.png"
},
{
"id": "8a07f2d0-9c72-4de1-bf92-9530ae82b4b6",
"trigger": "metric",
"name": "Intermediate Writer",
"description": "null",
"metricId": "d01dcbcb-d51e-4c12-b054-dc811dcdc623",
"metricValue": 1000,
"achievedAt": "2021-01-02T00:00:00Z",
"badgeUrl": "https://example.com/badge2.png"
},
{
"id": "2090d038-aa04-4048-ab2e-e2b7bf2d3b9f",
"trigger": "metric",
"name": "Expert Writer",
"description": "null",
"metricId": "d01dcbcb-d51e-4c12-b054-dc811dcdc623",
"metricValue": 2000,
"achievedAt": null,
"badgeUrl": "null"
}
]
}
]{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Authorizations
Headers
The tenant identifier for multi-tenant organisations. Required when the organisation has multi-tenancy enabled. The value should be your internal ID for the tenant. Ignored for single-tenant organisations.
Path Parameters
ID of the user
Response
Successful operation
The unique ID of the metric.
Example:
"d01dcbcb-d51e-4c12-b054-dc811dcdc623"
The unique key of the metric.
Example:
"words-written"
The name of the metric.
Example:
"Words written"
The user's current total for the metric.
Example:
1500
A list of the metric's achievements and the user's progress towards each.
Show child attributes
Show child attributes
Was this page helpful?
⌘I