### Get Loyalty Programs (Node.js) Source: https://docs.gameshift.dev/reference/loyalty-programs-2 This Node.js example demonstrates how to fetch loyalty programs using the 'node-fetch' library. It makes a GET request to the specified API endpoint and includes the necessary 'accept' header. ```javascript import fetch from 'node-fetch'; const options = { method: 'GET', headers: { 'accept': 'application/json' } }; fetch('https://api.gameshift.dev/nx/loyalty-rewards/programs', options) .then(response => response.json()) .then(response => console.log(response)) .catch(err => console.error(err)); ``` -------------------------------- ### Get Loyalty Programs (Python) Source: https://docs.gameshift.dev/reference/loyalty-programs-2 This Python example shows how to fetch loyalty programs using the 'requests' library. It performs a GET request to the API endpoint, including the 'accept' header for JSON responses. ```python import requests url = "https://api.gameshift.dev/nx/loyalty-rewards/programs" headers = { "accept": "application/json" } response = requests.get(url, headers=headers) print(response.text) ``` -------------------------------- ### Get Loyalty Programs (Ruby) Source: https://docs.gameshift.dev/reference/loyalty-programs-2 This Ruby snippet demonstrates fetching loyalty programs using the 'net/http' library. It constructs an HTTP GET request to the API endpoint with the required 'accept' header. ```ruby require 'uri' require 'net/http' uri = URI.parse("https://api.gameshift.dev/nx/loyalty-rewards/programs") request = Net::HTTP::Get.new(uri) request["accept"] = "application/json" response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == "https") do |http| http.request(request) end puts response.body ``` -------------------------------- ### Fetch All Users (Node.js) Source: https://docs.gameshift.dev/reference/index Example of fetching all users using Node.js. This typically involves using a library like 'node-fetch' or the built-in 'https' module to make an HTTP GET request to the API. -------------------------------- ### GET /nx/loyalty-rewards/programs/{programId}/enrollments Source: https://docs.gameshift.dev/reference/loyaltyprogramcontroller_getloyaltyprogramenrollments-1 Retrieves a paginated list of enrollments for a given loyalty program. Includes details like enrollment address, start time, and associated program information. ```APIDOC ## GET /nx/loyalty-rewards/programs/{programId}/enrollments ### Description Retrieves a paginated list of enrollments for a given program. ### Method GET ### Endpoint /nx/loyalty-rewards/programs/{programId}/enrollments ### Parameters #### Path Parameters - **programId** (string) - Required - Specifies the program to get enrollment for #### Query Parameters - **x-api-key** (string) - Required - API key for your game - **perPage** (integer) - Optional - The number of items on each page - **page** (integer) - Optional - Specifies the page to fetch (minimum 1) ### Request Example ```json { "example": "Not applicable for GET request body" } ``` ### Response #### Success Response (200) - **data** (array) - A list of Enrollments - **environment** (object) - The Environment of the Enrollment - **id** (string) - The ID of the Enrollment - **enrollmentAddress** (string) - The on-chain address of the Enrollment - **lastSnapshotId** (string) - The ID of the last reward snapshot issued that included the Enrollment - **enrollmentStartTime** (string) - The time the Enrollment was created (date-time format) - **commitmentPeriod** (number) - The time in seconds that the Enrollment will last for - **elapsedEnrollmentTime** (number) - Time elapsed since the creation of the Enrollment (in seconds) - **enrollmentPeriod** (number) - The time that the Enrollment is committed to before it can claim rewards - **ownerAddress** (string) - The on-chain address of the owner of the Enrollment - **ownerId** (string) - The user reference ID of the owner of the Enrollment - **programId** (string) - The ID of the LoyaltyProgram the Enrollment belongs to - **programAddress** (string) - The on-chain address of the LoyaltyProgram the Enrollment belongs to - **enrolledBalance** (string) - The balance of the Enrollment - **allocatedRewards** (string) - The allocated reward balance of the Enrollment #### Response Example ```json { "example": { "data": [ { "environment": {}, "id": "enrollment_id_123", "enrollmentAddress": "0x123abc...", "lastSnapshotId": "snapshot_456", "enrollmentStartTime": "2023-10-27T10:00:00Z", "commitmentPeriod": 86400, "elapsedEnrollmentTime": 3600, "enrollmentPeriod": 7200, "ownerAddress": "0xdef456...", "ownerId": "user_789", "programId": "program_xyz", "programAddress": "0x789ghi...", "enrolledBalance": "1000", "allocatedRewards": "50" } ] } } ``` ``` -------------------------------- ### GET /nx/loyalty-rewards/enrollments Source: https://docs.gameshift.dev/reference/loyaltyprogramenrollmentscontroller_getloyaltyprogramenrollmentsbyproject-1 Retrieves a paginated list of all enrollments in the project. Requires an API key for authentication. ```APIDOC ## GET /nx/loyalty-rewards/enrollments ### Description Retrieves a paginated list of all enrollments in the project. ### Method GET ### Endpoint /nx/loyalty-rewards/enrollments ### Parameters #### Header Parameters - **x-api-key** (string) - Required - API key for your game #### Query Parameters - **perPage** (integer) - Optional - The number of items on each page - **page** (integer) - Optional - Specifies the page to fetch (minimum 1) ### Request Example ```json { "example": "No request body for GET request" } ``` ### Response #### Success Response (200) - **data** (array) - A list of Enrollments - **environment** (object) - The Environment of the Enrollment - **id** (string) - The ID of the Enrollment - **enrollmentAddress** (string) - The on-chain address of the Enrollment - **lastSnapshotId** (string) - The ID of the last reward snapshot issued that included the Enrollment - **enrollmentStartTime** (string, format: date-time) - The time the Enrollment was created - **commitmentPeriod** (number) - The time in seconds that the Enrollment will last for - **elapsedEnrollmentTime** (number) - Time elapsed since the creation of the Enrollment (in seconds) - **enrollmentPeriod** (number) - The time that the Enrollment is committed to before it can claim rewards - **ownerAddress** (string) - The on-chain address of the owner of the Enrollment - **ownerId** (string) - The user reference ID of the owner of the Enrollment - **programId** (string) - The ID of the LoyaltyProgram the Enrollment belongs to - **programAddress** (string) - The on-chain address of the LoyaltyProgram the Enrollment belongs to - **enrolledBalance** (string) - The balance of the Enrollment - **allocatedRewards** (string) - The allocated reward balance of the Enrollment - **claimedRewards** (string) - Number of allocated rewards claimed so far, for the Enrollment #### Response Example ```json { "data": [ { "environment": {}, "id": "string", "enrollmentAddress": "string", "lastSnapshotId": "string", "enrollmentStartTime": "2023-01-20T10:00:00Z", "commitmentPeriod": 12345, "elapsedEnrollmentTime": 6789, "enrollmentPeriod": 10000, "ownerAddress": "string", "ownerId": "string", "programId": "string", "programAddress": "string", "enrolledBalance": "string", "allocatedRewards": "string", "claimedRewards": "string" } ] } ``` ``` -------------------------------- ### GET /nx/loyalty-rewards/programs Source: https://docs.gameshift.dev/reference/loyalty-programs-2 Returns a list of all loyalty programs in the project. Supports pagination and filtering. ```APIDOC ## GET /nx/loyalty-rewards/programs ### Description Returns a list of all loyalty programs in the project. This endpoint supports optional query parameters for pagination. ### Method GET ### Endpoint https://api.gameshift.dev/nx/loyalty-rewards/programs ### Parameters #### Query Parameters - **perPage** (integer) - Optional - The number of items to return per page. - **page** (integer) - Optional - The page number to fetch. Must be greater than or equal to 1. #### Headers - **x-api-key** (string) - Required - API key for your game. ### Request Example ```json { "example": "curl --request GET \ \ --url https://api.gameshift.dev/nx/loyalty-rewards/programs \ \ --header 'accept: application/json'" } ``` ### Response #### Success Response (200) - **data** (array of objects) - Required - The list of loyalty programs. - **data*** (object) - Represents a single loyalty program. - **name** (string) - Required - The name of the Loyalty Program. - **image** (string) - Required - The associated image URL of the Loyalty Program. - **environment** (object) - Required - The environment of the enrollment. Contains additional fields. - **id** (string) - Required - The ID of the Loyalty Program. - **address** (string) - Required - The on-chain address of the Loyalty Program. - **enrollmentCurrencyId** (string) - Required - The currency ID for enrollment. Register new currencies under /nx/currencies. - **enrollmentMintAddress** (string) - Required - The on-chain address of the enrollment currency. - **rewardCurrencyId** (string) - Required - The currency ID for rewards. Register new currencies under /nx/currencies. - **rewardMintAddress** (string) - Required - The on-chain address of the reward currency. - **maxTokens** (string) - Required - The maximum number of tokens that can be enrolled in this program. - **maxEnrollmentPeriod** (number) - Required - The maximum duration in seconds for an enrollment. - **minEnrollmentPeriod** (number) - Required - The minimum duration in seconds for an enrollment. - **maxEnrollments** (number) - Required - The maximum number of enrollments supported by the program. - **projectId** (string) - Required - The project ID that owns this Loyalty Program. - **adminAddress** (string) - Required - The on-chain address of the administrative wallet. - **fundingAddress** (string) - Required - The on-chain address of the rewards token account. - **currentSnapshotId** (string) - Optional - The ID of the latest snapshot of rewards. - **rewards** (object) - Required - A breakdown of rewards allocated to enrollments. - **allowNewEnrollees** (boolean) - Required - Indicates if new enrollments are allowed. - **meta** (object) - Required - Pagination related metadata. - **page** (number) - Required - The page number fetched. - **perPage** (number) - Required - The number of items per page. - **totalPages** (number) - Required - The total number of pages. - **totalResults** (number) - Required - The total count of results. #### Response Example ```json { "example": "{\"data\": [{\"name\": \"Example Program\", \"image\": \"http://example.com/image.png\", \"environment\": {\"id\": \"env-123\", \"address\": \"0x123...\"}, \"id\": \"lp-abc\", \"address\": \"0xabc...\", \"enrollmentCurrencyId\": \"curr-xyz\", \"enrollmentMintAddress\": \"0xxyz...\", \"rewardCurrencyId\": \"curr-pqr\", \"rewardMintAddress\": \"0xpqr...\", \"maxTokens\": \"1000\", \"maxEnrollmentPeriod\": 86400, \"minEnrollmentPeriod\": 3600, \"maxEnrollments\": 100, \"projectId\": \"proj-456\", \"adminAddress\": \"0xdef...\", \"fundingAddress\": \"0xghi...\", \"rewards\": {\"allowNewEnrollees\": true}, \"meta\": {\"page\": 1, \"perPage\": 10, \"totalPages\": 1, \"totalResults\": 1}}], \"meta\": {\"page\": 1, \"perPage\": 10, \"totalPages\": 1, \"totalResults\": 1}}" } ``` ``` -------------------------------- ### Get All SKUs (Python) Source: https://docs.gameshift.dev/reference/storefront-1 This Python script demonstrates how to retrieve all SKUs from the GameShift API using the 'requests' library. It sends a GET request and prints the JSON response. Make sure the 'requests' library is installed (`pip install requests`). ```python import requests url = "https://api.gameshift.dev/nx/storefront/skus" headers = { "accept": "application/json" } response = requests.get(url, headers=headers) print(response.json()) ``` -------------------------------- ### Fetch All Users (cURL) Source: https://docs.gameshift.dev/reference/index Demonstrates how to fetch all users using a cURL command. This requires specifying the GET request method, the API endpoint URL, and the 'accept' header for JSON response. ```shell curl --request GET \ --url https://api.gameshift.dev/nx/users \ --header 'accept: application/json' ``` -------------------------------- ### Create Loyalty Program OpenAPI Definition Source: https://docs.gameshift.dev/reference/loyaltyprogramcontroller_createloyaltyprogram-1 This OpenAPI 3.0 definition describes the POST endpoint for creating a loyalty program. It specifies request headers like 'x-api-key' and 'x-wallet-key', details the required fields for the request body (e.g., currency IDs, max enrollments), and outlines the successful response structure including program ID and transaction details. ```json { "openapi": "3.0.0", "paths": { "/nx/loyalty-rewards/programs": { "post": { "operationId": "LoyaltyProgramController_createLoyaltyProgram", "summary": "Create Loyalty Program", "description": "### Sends a transaction to create a new loyalty program.\n \nNote: This action uses the developer wallet", "parameters": [ { "name": "x-api-key", "in": "header", "description": "API key for your game", "required": true, "schema": { "type": "string" } }, { "name": "x-wallet-key", "required": true, "in": "header", "schema": { "type": "string" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "name": { "type": "string", "description": "Optional name of the program, shown in the UI" }, "image": { "type": "string", "description": "Optional associated image URL of the program, shown in the UI" }, "enrollmentCurrencyId": { "type": "string", "description": "The currency id of the enrollment currency. Register under /nx/currencies" }, "rewardCurrencyId": { "type": "string", "description": "The currency id of the enrollment currency. Register under /nx/currencies" }, "maxEnrollments": { "type": "number", "description": "The max number of enrollments that this pool can support (up to 32,000)" }, "maxTokens": { "type": "string", "description": "The max number of enrolled tokens that this pool can support (as a string). Up to 2^64." }, "maxEnrollmentPeriod": { "type": "number", "description": "The max amount of time in seconds that an enrollment can last." }, "minEnrollmentPeriod": { "type": "number", "description": "The minimum amount of time, in seconds, that an enrollment can last." } }, "required": [ "enrollmentCurrencyId", "rewardCurrencyId", "maxEnrollments", "maxTokens", "maxEnrollmentPeriod", "minEnrollmentPeriod" ], "x-readme-ref-name": "CreateLoyaltyRewardsProgramDto" } } } }, "responses": { "201": { "description": "", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string", "description": "The ID of the newly created program" }, "transactionId": { "type": "string", "description": "The GameShift ID of the on-chain transaction that created the program" }, "transactionHash": { "type": "string", "description": "The transaction hash, can be used on explorers" } }, "required": [ "id", "transactionId", "transactionHash" ], "x-readme-ref-name": "CreateLoyaltyProgramDto" } } } } }, "tags": [ "Loyalty Programs" ] } } }, "info": { "title": "GameShift REST API", "description": "A single API for games to integrate with web3", "version": "3.0.0", "contact": {} }, "servers": [ { "url": "https://api.gameshift.dev" } ], "x-readme": { "explorer-enabled": true, "proxy-enabled": true } } ``` -------------------------------- ### Get Loyalty Programs - Node.js Source: https://docs.gameshift.dev/reference/loyalty-programs-3 This Node.js snippet shows how to make a GET request to retrieve loyalty programs using the 'axios' library. It includes the endpoint URL and sets the 'accept' header to 'application/json'. Ensure 'axios' is installed (`npm install axios`). ```javascript const axios = require('axios'); const getLoyaltyPrograms = async () => { try { const response = await axios.get('https://api.gameshift.dev/nx/loyalty-rewards/programs', { headers: { 'accept': 'application/json' } }); console.log(response.data); return response.data; } catch (error) { console.error('Error fetching loyalty programs:', error); } }; getLoyaltyPrograms(); ``` -------------------------------- ### POST /nx/loyalty-rewards/programs/{programId}/enrollments Source: https://docs.gameshift.dev/reference/loyaltyprogramcontroller_enrolluserinloyaltyprogram-1 Creates a consent URL for a user to enroll in a specified loyalty program. This endpoint is used to initiate the enrollment process by generating a unique URL that the user must visit to provide their consent. ```APIDOC ## POST /nx/loyalty-rewards/programs/{programId}/enrollments ### Description Creates a consent url for a user to enroll in a loyalty program. ### Method POST ### Endpoint `/nx/loyalty-rewards/programs/{programId}/enrollments` ### Parameters #### Path Parameters - **programId** (string) - Required - Specifies the program to enroll the user in #### Header Parameters - **x-api-key** (string) - Required - API key for your game #### Request Body - **amount** (string) - Required - The amount of tokens to enroll (decimals ok) - **userId** (string) - Required - The reference user ID of the enrollment - **enrollmentPeriod** (number) - Required - The period of enrollment in seconds ### Request Example ```json { "amount": "100.50", "userId": "user_123", "enrollmentPeriod": 3600 } ``` ### Response #### Success Response (201) - **transactionId** (string) - The id for the transaction. Can be used to get the status of the transaction. - **consentUrl** (string) - The url the user must visit to provide consent for the transaction. - **enrollmentId** (string) - The enrollment ID created if the user's transaction completes successfully #### Response Example ```json { "transactionId": "txn_abc123", "consentUrl": "https://consent.example.com/xyz789", "enrollmentId": "enroll_def456" } ``` ``` -------------------------------- ### Get Loyalty Programs - Python Source: https://docs.gameshift.dev/reference/loyalty-programs-3 This Python snippet illustrates how to fetch loyalty programs using the 'requests' library. It sends a GET request to the specified API endpoint with an 'accept' header set to 'application/json'. Make sure to install the library (`pip install requests`). ```python import requests url = "https://api.gameshift.dev/nx/loyalty-rewards/programs" headers = { "accept": "application/json" } response = requests.get(url, headers=headers) print(response.json()) ``` -------------------------------- ### Get All SKUs (PHP) Source: https://docs.gameshift.dev/reference/storefront-1 This PHP snippet shows how to get all SKUs from the GameShift API. It uses cURL to make the GET request and processes the JSON response. Ensure the cURL extension is enabled in your PHP installation. ```php ``` -------------------------------- ### Get All SKUs (Node.js) Source: https://docs.gameshift.dev/reference/storefront-1 This Node.js snippet shows how to fetch all SKUs using the GameShift API. It utilizes the 'node-fetch' library to make the GET request and handles the JSON response. Ensure 'node-fetch' is installed. ```javascript import fetch from 'node-fetch'; const options = { method: 'GET', headers: { accept: 'application/json' } }; fetch('https://api.gameshift.dev/nx/storefront/skus', options) .then(response => response.json()) .then(response => console.log(response)) .catch(err => console.error(err)); ``` -------------------------------- ### Fetch User Loyalty Program Enrollments Source: https://docs.gameshift.dev/reference/projectusercontroller_getloyaltyprogramenrollmentsbyuser-1 Retrieves a paginated list of enrollments for a given user. ```APIDOC ## GET /nx/users/{referenceId}/enrollments ### Description Retrieves a paginated list of enrollments for a given user. ### Method GET ### Endpoint /nx/users/{referenceId}/enrollments ### Parameters #### Path Parameters - **referenceId** (string) - Required - Identifies the User. #### Query Parameters - **x-api-key** (string) - Required - API key for your game - **perPage** (integer) - Optional - The number of items on each page - **page** (integer) - Optional - Specifies the page to fetch (minimum: 1) ### Request Example ```json { "example": "request body" } ``` ### Response #### Success Response (200) - **data** (array) - A list of Enrollments - **environment** (object) - The Environment of the Enrollment - **id** (string) - The ID of the Enrollment - **enrollmentAddress** (string) - The on-chain address of the Enrollment - **lastSnapshotId** (string) - The ID of the last reward snapshot issued that included the Enrollment - **enrollmentStartTime** (string) - The time the Enrollment was created (date-time format) - **commitmentPeriod** (number) - The time in seconds that the Enrollment will last for - **elapsedEnrollmentTime** (number) - Time elapsed since the creation of the Enrollment (in seconds) - **enrollmentPeriod** (number) - The time that the Enrollment is committed to before it can claim rewards - **ownerAddress** (string) - The on-chain address of the owner of the Enrollment - **ownerId** (string) - The user reference ID of the owner of the Enrollment - **programId** (string) - The ID of the LoyaltyProgram the Enrollment belongs to - **programAddress** (string) - The on-chain address of the LoyaltyProgram the Enrollment belongs to - **enrolledBalance** (string) - The balance of the Enrollment - **allocatedRewards** (string) - The allocated reward balance of the Enrollment - **claimedRewards** (string) - The claimed reward balance of the Enrollment #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Fetch All Users - PHP Request Source: https://docs.gameshift.dev/reference/users-1 Demonstrates fetching all users using PHP, likely with cURL or file_get_contents. It shows setting the GET request, the API endpoint, and handling the JSON response. ```php // Example for PHP (using cURL) // $url = "https://api.gameshift.dev/nx/users"; // $headers = array( // 'Accept: application/json' // // Add 'x-api-key' if required by your setup // ); // $ch = curl_init(); // curl_setopt($ch, CURLOPT_URL, $url); // curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // $response = curl_exec($ch); // $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); // curl_close($ch); // if ($httpcode == 200) { // echo $response; // } else { // echo "Error: " . $httpcode; // } ``` -------------------------------- ### Fetch All Payments using Ruby Source: https://docs.gameshift.dev/reference/payments-1 Shows how to retrieve all payments using Ruby. This example uses the built-in 'net/http' library to perform the GET request and parse the JSON response. ```ruby require 'net/http' require 'uri' require 'json' uri = URI.parse("https://api.gameshift.dev/nx/payments") request = Net::HTTP::Get.new(uri) request['accept'] = 'application/json' response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http| http.request(request) end puts JSON.parse(response.body) ``` -------------------------------- ### POST /nx/storefront/inventory/OffChainAsset Source: https://docs.gameshift.dev/reference/storefrontcontroller_createoffchaininventory-1 Creates a new OffChainAsset inventory with the provided details. ```APIDOC ## POST /nx/storefront/inventory/OffChainAsset ### Description Creates a new OffChainAsset inventory with the provided details. ### Method POST ### Endpoint /nx/storefront/inventory/OffChainAsset ### Parameters #### Header Parameters - **x-api-key** (string) - Required - API key for your game #### Request Body - **name** (string) - Required - Name of the asset inventory - **imageUrl** (string) - Required - URL of the asset image - **attributes** (array) - Optional - Add attributes to your Asset - **traitType** (string) - Required - The name of the trait - **value** (string) - Required - The value of the trait - **maxQuantity** (number) - Optional - Maximum quantity of assets allowed (minimum: 0) - **vendorData** (object) - Optional - Vendor-specific data ### Request Example ```json { "name": "My Awesome Asset", "imageUrl": "https://example.com/image.png", "attributes": [ { "traitType": "Color", "value": "Red" } ], "maxQuantity": 100, "vendorData": { "internalId": "xyz789" } } ``` ### Response #### Success Response (201) - **id** (string) - Unique identifier for the off-chain asset inventory - **name** (string) - Name of the asset inventory - **imageUrl** (string) - URL of the asset image - **attributes** (array) - Attributes of the asset - **traitType** (string) - The name of the trait - **value** (string) - The value of the trait - **maxQuantity** (number) - Maximum quantity of assets allowed - **currentQuantity** (number) - Current quantity of assets - **vendorData** (object) - Vendor-specific data - **created** (string) - Creation timestamp (format: date-time) #### Response Example ```json { "id": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "name": "My Awesome Asset", "imageUrl": "https://example.com/image.png", "attributes": [ { "traitType": "Color", "value": "Red" } ], "maxQuantity": 100, "currentQuantity": 0, "vendorData": { "internalId": "xyz789" }, "created": "2023-10-27T10:00:00Z" } ``` ``` -------------------------------- ### GET /nx/crafting-recipes Source: https://docs.gameshift.dev/reference/crafting-recipes-1 Retrieves a paginated list of all available crafting recipes. This endpoint requires an API key for authentication. ```APIDOC ## GET /nx/crafting-recipes ### Description Get a paginated list of all Crafting Recipes. ### Method GET ### Endpoint https://api.gameshift.dev/nx/crafting-recipes ### Query Parameters - **perPage** (integer) - Optional - The number of items on each page. - **page** (integer) - Optional - Specifies the page to fetch (minimum 1). ### Headers - **x-api-key** (string) - Required - API key for your game. ### Response #### Success Response (200) - **data** (array of objects) - Required - A list of Crafting Recipes. - **data[].id** (string) - Required - Identifies the recipe. - **data[].consumes** (array) - Required - What this recipe will consume. - **data[].craftingUserReferenceId** (string) - Required - Identifies the user that will fulfill the crafting recipe. - **data[].metadata** (object | null) - Metadata to describe the recipe. - **data[].status** (string) - Required - The status of the recipe (`Deleted`, `Pending`, `Submitting`, `Failed`, `Completed`, `PartiallyCompleted`, `Expired`). - **data[].transactions** (array of objects) - Required - The transactions that are must be complete to fulfill the recipe. - **data[].transactions[].id** (string) - Required - Transaction ID. - **data[].transactions[].created** (date-time) - Required - Transaction creation date. - **data[].transactions[].status** (object) - Required - Transaction confirmation status. - **data[].transactions[].details** (object) - Required - Transaction type and details about asset and balance changes. - **meta** (object) - Required - Pagination related metadata. - **meta.page** (number) - Required - The page number fetched. - **meta.perPage** (number) - Required - The number of items in each page. - **meta.totalPages** (number) - Required - The total number of pages in all results. - **meta.totalResults** (number) - Required - The total result count. ### Request Example ```json { "example": "This is a placeholder for a request body, if applicable. This endpoint does not typically require a request body." } ``` ### Response Example ```json { "data": [ { "id": "recipe_123", "consumes": [], "craftingUserReferenceId": "user_abc", "metadata": null, "status": "Completed", "transactions": [ { "id": "txn_xyz", "created": "2023-10-27T10:00:00Z", "status": {"type": "Confirmed"}, "details": {"type": "CurrencyWithdrawal", "amount": 100} } ] } ], "meta": { "page": 1, "perPage": 10, "totalPages": 5, "totalResults": 50 } } ``` ``` -------------------------------- ### Fetch All Payments using Python Source: https://docs.gameshift.dev/reference/payments-1 A Python example for fetching all payments from the GameShift API. It uses the 'requests' library to make the HTTP GET request and includes basic error handling and JSON parsing. ```python import requests url = "https://api.gameshift.dev/nx/payments" headers = { "accept": "application/json" } try: response = requests.get(url, headers=headers) response.raise_for_status() # Raise an exception for bad status codes data = response.json() print(data) except requests.exceptions.RequestException as e: print(f"Error: {e}") ``` -------------------------------- ### POST /nx/storefront/inventory/NewMintUniqueAsset Source: https://docs.gameshift.dev/reference/storefrontcontroller_createnewmintinventory-1 Creates a new NewMintUniqueAsset inventory with the provided details. This endpoint allows for the creation of unique digital assets within your game's storefront. ```APIDOC ## POST /nx/storefront/inventory/NewMintUniqueAsset ### Description Creates a new NewMintUniqueAsset inventory with the provided details. ### Method POST ### Endpoint /nx/storefront/inventory/NewMintUniqueAsset ### Parameters #### Header Parameters - **x-api-key** (string) - Required - API key for your game #### Request Body - **name** (string) - Required - Name of the asset inventory - **imageUrl** (string) - Required - URL of the asset image - **attributes** (array) - Optional - Add attributes to your Asset - **traitType** (string) - Required - The name of the trait - **value** (string) - Required - The value of the trait - **maxQuantity** (number) - Optional - Maximum quantity of assets allowed (minimum: 0) - **collectionId** (string) - Required - Collection ID for the unique mint asset - **vendorData** (object) - Optional - Vendor-specific data - **description** (string) - Optional - Description of the asset ### Request Example ```json { "name": "ExampleAsset", "imageUrl": "https://example.com/image.png", "attributes": [ { "traitType": "Color", "value": "Blue" } ], "maxQuantity": 100, "collectionId": "collection-123", "description": "A unique game asset." } ``` ### Response #### Success Response (201) - **id** (string) - Unique identifier for the new mint unique asset inventory - **name** (string) - Name of the asset inventory - **imageUrl** (string) - URL of the asset image - **attributes** (array) - Attributes of the asset - **traitType** (string) - The name of the trait - **value** (string) - The value of the trait - **maxQuantity** (number) - Maximum quantity of assets allowed - **currentQuantity** (number) - Current quantity of assets available #### Response Example ```json { "id": "asset-id-xyz", "name": "ExampleAsset", "imageUrl": "https://example.com/image.png", "attributes": [ { "traitType": "Color", "value": "Blue" } ], "maxQuantity": 100, "currentQuantity": 100 } ``` ``` -------------------------------- ### POST /nx/users Source: https://docs.gameshift.dev/reference/projectusercontroller_create-1 Registers a new user with your game. This endpoint allows you to create a new user profile by providing a unique reference ID, email, and optionally an external wallet address. ```APIDOC ## POST /nx/users ### Description Registers a new user with your game. ### Method POST ### Endpoint /nx/users ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **referenceId** (string) - Required - The reference id of the user. Must be unique, and cannot contain the character "/". - **email** (string) - Required - User's email address. - **externalWalletAddress** (string) - Optional - User's wallet address. Signing transactions will require use of a wallet like Phantom or Backpack. ### Request Example ```json { "referenceId": "user123", "email": "user@example.com", "externalWalletAddress": "0x1234567890abcdef" } ``` ### Response #### Success Response (201) - **referenceId** (string) - The reference id of the user - **email** (string) - The email of the user #### Response Example ```json { "referenceId": "user123", "email": "user@example.com" } ``` ``` -------------------------------- ### Fetch All Payments using Node.js Source: https://docs.gameshift.dev/reference/payments-1 Provides a Node.js example for fetching all payments via the GameShift API. It utilizes the 'node-fetch' library to make the HTTP GET request and includes handling for the JSON response. ```javascript import fetch from 'node-fetch'; const url = "https://api.gameshift.dev/nx/payments"; fetch(url, { method: 'GET', headers: { 'accept': 'application/json' } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error(error)); ``` -------------------------------- ### Fetch All Users - Node.js Request Source: https://docs.gameshift.dev/reference/users-1 Example of fetching all users using Node.js, likely with a library like 'node-fetch' or the built-in 'https' module. It shows how to make a GET request to the API endpoint and handle the JSON response. ```javascript // Example for Node.js (requires a fetch implementation or http module) // const fetch = require('node-fetch'); // or use built-in http module // fetch('https://api.gameshift.dev/nx/users', { // method: 'GET', // headers: { // 'accept': 'application/json' // // Add 'x-api-key' if required by your setup // } // }) // .then(response => response.json()) // .then(data => console.log(data)) // .catch(error => console.error('Error:', error)); ``` -------------------------------- ### Fetch Many Items using cURL Source: https://docs.gameshift.dev/reference/items-1 Demonstrates how to fetch multiple items using a cURL command. This includes the GET request method, the API endpoint, and the necessary 'accept' header for JSON responses. ```shell curl --request GET \ --url https://api.gameshift.dev/nx/items \ --header 'accept: application/json' ``` -------------------------------- ### Get All SKUs (cURL) Source: https://docs.gameshift.dev/reference/storefront-1 This cURL command demonstrates how to make a GET request to retrieve all SKUs from the GameShift API. It includes the endpoint URL and specifies the desired response format. ```shell curl --request GET \ --url https://api.gameshift.dev/nx/storefront/skus \ --header 'accept: application/json' ``` -------------------------------- ### POST /nx/tournaments/perpetual Source: https://docs.gameshift.dev/reference/perpetualtournamentprogramcontroller_createtournamentprogram-1 Creates a new perpetual tournament. Requires API key and wallet key in the header. ```APIDOC ## POST /nx/tournaments/perpetual ### Description Creates a new perpetual tournament with specified configurations. ### Method POST ### Endpoint /nx/tournaments/perpetual ### Parameters #### Header Parameters - **x-api-key** (string) - Required - API key for your game - **x-wallet-key** (string) - Required - Wallet key #### Request Body - **entryFeeAmount** (number) - Required - Entry fee amount in USDC. - **maxNumberOfPlayers** (number) - Optional - Max number of players allowed (2-512). - **allowPlayers** (array[string]) - Optional - Allow list of users reference-id. - **denyPlayers** (array[string]) - Optional - Deny list of users reference-id or wallet address. - **commissionRecipients** (array[object]) - Optional - Commission recipients. - **walletAddress** (string) - Required - Wallet address of commission recipient - **commissionBasisPoints** (number) - Required - Commission recipient basis points (1-10000) ### Request Example ```json { "entryFeeAmount": 10, "maxNumberOfPlayers": 64, "allowPlayers": ["user123", "user456"], "denyPlayers": ["baduser789"], "commissionRecipients": [ { "walletAddress": "0xRecipient1", "commissionBasisPoints": 500 } ] } ``` ### Response #### Success Response (201) - **transactionId** (string) - The GameShift ID of the on-chain transaction. - **transactionHash** (string) - The transaction hash. - **tournament** (object) - Created tournament object. - **created** (string) - Timestamp of creation. - **id** (string) - Id to Identifies the Tournament. - **environment** (string) - Current environment (Development, Production). ```json { "transactionId": "gameShiftTransactionId", "transactionHash": "0xTransactionHash", "tournament": { "created": "2024-01-01T00:00:00Z", "id": "tournamentId", "environment": "Development" } } ``` ``` -------------------------------- ### Get All SKUs (Ruby) Source: https://docs.gameshift.dev/reference/storefront-1 This Ruby code snippet illustrates how to fetch all SKUs using the GameShift API. It uses the built-in 'Net::HTTP' library to perform the GET request and parse the JSON response. ```ruby require 'uri' require 'net/http' require 'json' uri = URI.parse('https://api.gameshift.dev/nx/storefront/skus') request = Net::HTTP::Get.new(uri) request['accept'] = 'application/json' response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http| http.request(request) end puts JSON.parse(response.body) ``` -------------------------------- ### Get Loyalty Programs - Ruby Source: https://docs.gameshift.dev/reference/loyalty-programs-3 This Ruby snippet shows how to retrieve loyalty programs using the 'net/http' library. It makes a GET request to the API endpoint and sets the 'accept' header to 'application/json'. ```ruby require 'net/http' require 'uri' uri = URI.parse('https://api.gameshift.dev/nx/loyalty-rewards/programs') request = Net::HTTP::Get.new(uri.request_uri) request['accept'] = 'application/json' response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http| http.request(request) end puts response.body ```