Skip to main content

Python client for the PlayerData GraphQL API

Project description

PlayerDataPy

A python package for interacting with the PlayerData GraphQL API.

Folder Structure

  • playerdata_api: The main package for interacting with the PlayerData API.
    • gqlauth: The main package for authenticating with the PlayerData API.
    • gqlclient: The main package for interacting with the PlayerData GraphQL API.
    • custom_queries: Custom queries for the PlayerData GraphQL API.
    • custom_mutations: Custom mutations for the PlayerData GraphQL API.
    • custom_fields: Custom fields for the PlayerData GraphQL API.
    • input_types: Input types for the PlayerData GraphQL API.
    • enums: Enums for the PlayerData GraphQL API.
    • custom_typing_fields: Custom typing fields for the PlayerData GraphQL API.
    • custom_responses: Custom responses for the PlayerData GraphQL API.

Installation

uv is the tool we use to build and manage the playerdatapy Python package.

Make sure you install uv using pipx or the official installer. Installing with pip or other methods will lead to unexpected behavior.

We recommend using the official installer.

Then you can install the required dependencies, in a virtual environment if required.

    uv sync

Usage

To use the GraphqlClient, you need to provide your client id, this will be provided to you by PlayerData. To request API credentials, please contact the PlayerData team at support@playerdata.co.uk.

Option 1: Use generated types with PlayerDataAPI

Example usage of this option is provided in the examples/pydantic/ folder. The basic flow is to create a PlayerDataAPI instance, build the query objects using the code-generated Pydantic models (generated by ariadne-codegen), and then call the run_queries method.

For more detailed documentation, see examples/pydantic/README.md.

To run an example of this option, you can use the following command:

python examples/pydantic/quick_start.py

To run this you will need to set the following environment variables or hardcode them in the file:

export CLIENT_ID=your_client_id
export CLIENT_SECRET=your_client_secret
export CLUB_ID=your_club_id

For a more in-depth example, please see the examples/pydantic/example_use.ipynb notebook. This notebook demonstrates how to use the PlayerData API with Pydantic to query specifics such as session details, session metrics, and raw data.

Option 2: Use the GraphqlClient class directly

Example usage of this option is provided in the examples/direct/ folder. The basic flow is to create a GraphqlClient instance, build the query string, and then call the query method.

For more detailed documentation, see examples/direct/README.md.

To run an example of this option, you can use the following command:

python examples/direct/quick_start.py

To run this you will need to set the following environment variables or hardcode them in the file:

export CLIENT_ID=your_client_id
export CLIENT_SECRET=your_client_secret
export CLUB_ID=your_club_id

Authentication Types

These authentication types are set out in the playerdatapy.gqlauth.AuthenticationType enum. The default authentication type is AuthenticationType.AUTHORISATION_CODE_FLOW. These authentication types are used to set the authentication type in the GraphqlAuth class.

Authorisation Code Flow (PKCE)

Authorisation code flow with PKCE is used to authenticate users with non_confidential credentials.

Authorisation Code Flow

Authorisation code flow is used to authenticate users with confidential credentials.

Client Credentials Flow

Client credentials flow is used to authenticate backend to backend communication.

Updates to the API Fields and Mutations

To update the API fields and mutations, you need to set an AUTH_TOKEN environment variable. This code is auto-generated by Ariadne, so any changes to the API fields and mutations will be reflected in the code.

export AUTH_TOKEN=f"Bearer {your_auth_token}"
python -m ariadne-codegen

This will generate code and update files in the playerdatapy package.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

playerdatapy-1.17.0.tar.gz (364.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

playerdatapy-1.17.0-py3-none-any.whl (195.1 kB view details)

Uploaded Python 3

File details

Details for the file playerdatapy-1.17.0.tar.gz.

File metadata

  • Download URL: playerdatapy-1.17.0.tar.gz
  • Upload date:
  • Size: 364.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for playerdatapy-1.17.0.tar.gz
Algorithm Hash digest
SHA256 d4ce8f06340c9121d7afe0dfc0e83f4a654855c96c25d93786f95b693e507267
MD5 fab95f5cc123a8788ec06ea4b21d471d
BLAKE2b-256 d922d93c852b015f8ddf6f80eb022e6b48a9db3f5ef05747756740ed7eff8a75

See more details on using hashes here.

File details

Details for the file playerdatapy-1.17.0-py3-none-any.whl.

File metadata

  • Download URL: playerdatapy-1.17.0-py3-none-any.whl
  • Upload date:
  • Size: 195.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for playerdatapy-1.17.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0c4c1fc37f0efff4b9407ce5990609ffb7faad6e1d40f563a2b3da8345c9e2d4
MD5 3099abc868c8609d8703b0d6fab6897f
BLAKE2b-256 f4a6f6551405c8b0d87dbec66c79a24d25c375b14f860c40ff3e7101b58f67d2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page