Get rewards
The endpoint to retrieve a list of rewards for your game.
GET /v1/projects/{projectId}/users/{userId}/rewards
Parameters
projectId
(string): The ID of your project.userId
(string): The ID of the user whose rewards you want to retrieve.
Response
{
"data": [
{
"id": "VL-01",
"projectId": "26a1b69e-6d3f-43b7-9d50-163eee83d0c7",
"questId": "7aa2ea8a-e297-47bd-bd53-70ed4881b70b",
"quantity": 1
}
],
"page": 1,
"perPage": 20,
"total": 1,
"pageCount": 1,
"hasPreviousPage": false,
"hasNextPage": false
}
Example
- C#
- Node.js
- cURL
IEnumerator GetRewardsForUser(string projectId, string userId)
{
string endpoint = $"/v1/projects/{projectId}/users/{userId}/rewards";
using (UnityWebRequest www = UnityWebRequest.Get(endpoint))
{
yield return www.SendWebRequest();
if (www.result == UnityWebRequest.Result.Success)
{
string jsonResponse = www.downloadHandler.text;
Debug.Log("Response: " + jsonResponse);
}
else
{
Debug.LogError("Error: " + www.error);
}
}
}
const axios = require("axios");
async function getRewardsForUser(projectId, userId) {
const endpoint = `/v1/projects/${projectId}/users/${userId}/rewards`;
try {
const response = await axios.get(endpoint);
const jsonResponse = response.data;
console.log("Response: " + jsonResponse);
} catch (error) {
console.error("Error: " + error.message);
}
}
// Usage
getRewardsForUser("YOUR_PROJECT_ID", "YOUR_USER_ID");
curl "https://api.quests-system.com/v1/projects/YOUR_PROJECT_ID/users/YOUR_USER_ID/rewards"
Get a User rewards List in Specific Quest
GET /v1/projects/{id}/quests/{id}/users/{id}/rewards
Parameters
id
(string): The ID of the quest whose rewards you want to retrieve.user_id
(string): The ID of the user whose rewards you want to retrieve.
Response
{
"data": [
{
"id": "VL-01",
"projectId": "26a1b69e-6d3f-43b7-9d50-163eee83d0c7",
"questId": "7aa2ea8a-e297-47bd-bd53-70ed4881b70b",
"quantity": 1
}
],
"page": 1,
"perPage": 20,
"total": 1,
"pageCount": 1,
"hasPreviousPage": false,
"hasNextPage": false
}
Example Request
- C#
- Node.js
- cURL
IEnumerator GetRewardsForUserInQuest(string projectId, string questId, string userId)
{
string endpoint = $"/v1/projects/{projectId}/quests/{questId}/users/{userId}/rewards";
using (UnityWebRequest www = UnityWebRequest.Get(endpoint))
{
yield return www.SendWebRequest();
if (www.result == UnityWebRequest.Result.Success)
{
string jsonResponse = www.downloadHandler.text;
Debug.Log("Response: " + jsonResponse);
}
else
{
Debug.LogError("Error: " + www.error);
}
}
}
const axios = require("axios");
async function getRewardsForUserInQuest(projectId, questId, userId) {
const endpoint = `/v1/projects/${projectId}/quests/${questId}/users/${userId}/rewards`;
try {
const response = await axios.get(endpoint);
console.log("Response:", response.data);
} catch (error) {
console.error("Error:", error.message);
}
}
async function start() {
const projectId = "YourProjectID";
const questId = "YourQuestID";
const userId = "YourUserID";
await getRewardsForUserInQuest(projectId, questId, userId);
}
start();
curl -X POST -H "Content-Type: application/json" -d '{
"user_id": "7896-6548-87as-6549",
"name": "Some name",
"properties": {},
"created_at": 1683197285
}' "https://api.quests-system.com/v1/projects/{YourProjectID}/track"