Reference API Guide

Gaming Inventory API

Gaming Inventory API enable clients to exchange gaming inventory data with Opti-X.


Pre-requirements

To be able to access opti-x endpoints valid x-api-key and x-brand-key headers need to be attached to the request.

Keys could be found in Opti-X admin panel in Developer Tools/API Keys section.

Inventory schema

Gaming inventory needs to be a json-formatted body with games data matching inventory schema .

Example:

{"2345994": { "game_code": "2345994", "game_name": "Adventure Quest", "game_category": "Slots", "game_class": "premium", "game_type": "3D", "description": "A thrilling adventure game with a progressive jackpot.", "desktop": 1, "mobile": 0, "tablet": 1, "extra_channels": "iOS16|iOS17", "rtp": 0.95, "themes": ["Adventure"], "launch_date": "17/05/2023", "new": true, "supplier": "Supplier Inc.", "default_order": 1, "jackpot_type": "progressive", "formatted_summary": "Adventure Quest is a thrilling...", "formatted_summary_short": "Thrilling adventure game...", "image_url": "https://game.example.com/image.jpg", "game_features": [{"feature1": "feature_details"}], "tags": [{"tag1": "value1"}, {"tag2": "value2"}], "skin_id": ["21", "23"], "regulation": ["UKGC", "MGA"], "inclusions": {"country": ["UK", "DE"]}, "exclusions": {"currency": "USD"}, "extra": {"key1": "value1", "key2": "value2"}, }

Uploading file

Processing of the file is performed asynchronously and it’s splitted into two steps.

  1. Get pre-signed URL to upload file into S3 bucket by making GET request to https://api.graphyte.ai/inventory/v1/upload endpoint
  2. Make a POST request using received data with attached file.
  3. After being successfully processed reference and tags data is visible in Data/Datasets section in admin panel.

Python example:

import requests

def get_presigned_url() -> dict:
	return requests.get(
        url="https://api.graphyte.ai/inventory/v1/upload",
        headers={
	        "x-api-key": "znDewPpdik2G71BQweoCoQrxHudgqD2FODFHg-VlsvyLnjM5",
	        "x-brand-key": "V-GLH74z3b02XJk04c3ZnWdQ7y6nSC3MO508o0I8dpuUKTKG"
	      },
    ).json()

def upload_file() -> None:
    response = get_presigned_url()

    local_file = 'games.json'
    with open(f"{local_file}", 'rb') as f:
        files = {'file': (local_file, f)}
        requests.post(response['url'], data=response['fields'], files=files)

Validation of file content

Inventory file validation can be performed by making POST request to https://api.graphyte.ai/inventory/v1/validate endpoint with attached json file.

Due to file size limitation 5MB it’s recommended to validate just sample of inventory data file, for instance 100 games to catch all incompatibilities within data types.

Sample response:

{
    "validation_errors": [
        {
            "1880": [
                {
                    "loc": [
                        "desktop"
                    ],
                    "msg": "value is not a valid integer",
                    "type": "type_error.integer"
                }
            ]
        },
        {
            "1557": [
                {
                    "loc": [
                        "supplier"
                    ],
                    "msg": "str type expected",
                    "type": "type_error.str"
                }
            ]
        },
        {
            "1458": [
                {
                    "loc": [
                        "game_code"
                    ],
                    "msg": "none is not an allowed value",
                    "type": "type_error.none.not_allowed"
                }
            ]
        }
    ]
}