Skip to main content

Python SDK for the Esource.gg Client API

Project description

Esource.gg Python SDK

This is a Python SDK for interacting with the Esource.gg REST API. It provides a simple, consistent interface for authentication and accessing various API resources using both synchronous and asynchronous programming paradigms.

Features

  • Authenticated session management with automatic token refresh.
  • Handles common API errors gracefully (AuthenticationError, EsourceCommunicationError).
  • Provides both synchronous (SyncClient) and asynchronous (AsyncClient) clients.
  • Pythonic access to API resources with Pydantic models for data validation:
    • Sports (/sports)
    • Maps (/maps)
    • Players (/players)
    • Teams (/teams, /teams/{id}/players)
    • Trading Categories (/trading-categories)
    • Trading Tournaments (/trading-tournaments)
    • Trading Events (/trading-events)
    • Changelog (/changelog)
  • Support for common query parameters (skip, take, orderBy, search) where applicable.
  • Support for resource-specific query parameters (e.g., timestamp, sportId, statuses).
  • Reliable and tested implementation.

Installation

Install the package directly from PyPI:

pip install esource-client-api

Authentication

To use the API, you need valid credentials (email and password) and the base URL of the Esource API (obtainable from Esource.gg documentation or support).

You can authenticate either when initializing the client or by calling the login() method afterwards. Provide credentials during initialization

client = SyncClient(API_BASE_URL, email="your_email", password="your_password")

Or initialize first, then login

client = SyncClient(API_BASE_URL)
client.login("your_email", "your_password")

The same applies to the AsyncClient.

Basic Usage

Synchronous Client (SyncClient)

from esource_client_api.sync import SyncClient
from esource_client_api.models.errors import AuthenticationError, EsourceCommunicationError

Replace with your actual API base URL and credentials

API_BASE_URL = "https://esource.gg/api"
EMAIL = "your_email@example.com"
PASSWORD = "your_password"

try:
    # Initialize and log in automatically
    client = SyncClient(API_BASE_URL, email=EMAIL, password=PASSWORD)
    # Alternatively:
    # client = SyncClient(API_BASE_URL)
    # client.login(EMAIL, PASSWORD)

    print("Login successful!")

    # Example: List the first 5 sports
    sports_list = client.sports.list_sports(take=5)
    print("\nAvailable Sports (first 5):")
    for sport in sports_list:
        print(f"- {sport.name} (ID: {sport.id}, Slug: {sport.slug})")

    # Example: Get a specific player by ID (replace with a valid ID)
    try:
        player = client.players.get_player(17497)
        print(f"\nPlayer Details (ID 17497): {player.name}")
    except EsourceCommunicationError as e:
        print(f"\nCould not get player 17497: {e}")


except AuthenticationError as e:
    print(f"Authentication failed: {e}")
except EsourceCommunicationError as e:
    print(f"API communication error: {e}")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

Asynchronous Client (AsyncClient)

Using asyncio and the AsyncClient requires an async context. Authorizing AsyncClient has to be done through invoking login() methond and cannot be done during class initialization.

from esource_client_api.async_ import AsyncClient
from esource_client_api.models.errors import AuthenticationError, EsourceCommunicationError

# Replace with your actual API base URL and credentials
API_BASE_URL = "https://esource.gg/api"
EMAIL = "your_email@example.com"
PASSWORD = "your_password"

async def main():
    # Using the client as an async context manager handles session closing
    async with AsyncClient(API_BASE_URL) as client:
        try:
            # Log in
            await client.login(EMAIL, PASSWORD)
            print("Async login successful!")

            # Example: List the first 5 maps asynchronously
            maps_list = await client.maps.list_maps(take=5)
            print("\nAvailable Maps (first 5):")
            for map_item in maps_list:
                print(f"- {map_item.name} (ID: {map_item.map_id}, Slug: {map_item.slug})")

            # Example: Get a specific team by ID asynchronously (replace with a valid ID)
            try:
                team = await client.teams.get_team(13444)
                print(f"\nTeam Details (ID 13444): {team.name}")
            except EsourceCommunicationError as e:
                print(f"\nCould not get team 13444: {e}")


        except AuthenticationError as e:
            print(f"Authentication failed: {e}")
        except EsourceCommunicationError as e:
            print(f"API communication error: {e}")
        except Exception as e:
            print(f"An unexpected error occurred: {e}")

if __name__ == "__main__":
    # Required to run the async main function
    asyncio.run(main())

Available Resources

Once the client is initialized and authenticated, you can access the different API resources via the client's attributes:

  • client.sports: Access sports data.
  • client.maps: Access map data.
  • client.players: Access player data.
  • client.teams: Access team data, including players per team.
  • client.trading_categories: Access trading category data.
  • client.trading_tournaments: Access trading tournament data.
  • client.trading_events: Access trading event data, including markets and outcomes.
  • client.changelog: Access the changelog for data updates.

Refer to the method docstrings within the SDK or the official Esource API documentation for details on available methods and parameters for each resource (e.g., list_sports(), get_player(player_id), list_trading_events(sport_id=...)).

API URL & Docs

URL to interact with the API: https://esource.gg/api/

Swagger Docs for Api are available here: https://esource.gg/api/docs/

Please contact support for access.

License

This SDK is distributed under the MIT License. See the LICENSE file for more details.

Support & Source Code

For issues or questions regarding the SDK, please refer to the GitHub repository.

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

esource_client_api-1.2.0.tar.gz (37.0 kB view details)

Uploaded Source

Built Distribution

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

esource_client_api-1.2.0-py3-none-any.whl (29.7 kB view details)

Uploaded Python 3

File details

Details for the file esource_client_api-1.2.0.tar.gz.

File metadata

  • Download URL: esource_client_api-1.2.0.tar.gz
  • Upload date:
  • Size: 37.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for esource_client_api-1.2.0.tar.gz
Algorithm Hash digest
SHA256 f2c94ff1dd8912d9b0a7c806eb6a0431f5bc8c47319c1df3b42fc60357b1d1a9
MD5 78cfaac806cac80de1eac19636414539
BLAKE2b-256 c4c1bf532243f1a356ac49f012c5a9526d7b0edc8da67e2705daf8fe5e8a3746

See more details on using hashes here.

Provenance

The following attestation bundles were made for esource_client_api-1.2.0.tar.gz:

Publisher: publish.yml on Eppop-bet/client-api-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file esource_client_api-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for esource_client_api-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d69707837d4fc715c29d152091f0f606eeab7923471afa231afd278826357b5
MD5 a4cf6d58ec6e35b0bb590fcf31ae4bb8
BLAKE2b-256 6f1e71fd418637e110251c22051b379c6d25573e5f3e21d3f9aba2eed7e8a6cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for esource_client_api-1.2.0-py3-none-any.whl:

Publisher: publish.yml on Eppop-bet/client-api-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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