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)
- Sports (
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file esource_client_api-1.1.1.tar.gz.
File metadata
- Download URL: esource_client_api-1.1.1.tar.gz
- Upload date:
- Size: 30.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ea2436d9eb900fa642cf3d7746979decd37fc80b1fa0c6f69482d8f572be97d
|
|
| MD5 |
02e9b3b680608e52f65ba77d52abcd0c
|
|
| BLAKE2b-256 |
948d989347a2a50bfc92c6f2ec0d05ccddf75c2892c5877b580948b27b5a221f
|
Provenance
The following attestation bundles were made for esource_client_api-1.1.1.tar.gz:
Publisher:
publish.yml on Eppop-bet/client-api-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
esource_client_api-1.1.1.tar.gz -
Subject digest:
5ea2436d9eb900fa642cf3d7746979decd37fc80b1fa0c6f69482d8f572be97d - Sigstore transparency entry: 202174181
- Sigstore integration time:
-
Permalink:
Eppop-bet/client-api-sdk@4ca0f12dcbc014e4dafc29035a52592d0adde715 -
Branch / Tag:
refs/tags/v1.1.1 - Owner: https://github.com/Eppop-bet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4ca0f12dcbc014e4dafc29035a52592d0adde715 -
Trigger Event:
release
-
Statement type:
File details
Details for the file esource_client_api-1.1.1-py3-none-any.whl.
File metadata
- Download URL: esource_client_api-1.1.1-py3-none-any.whl
- Upload date:
- Size: 28.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df20e59cfe4e7e63543697c10a0e844e36fec6f10bff8fcba9e6b9814ddd243f
|
|
| MD5 |
58a2403b427c060aa5dea91846113be2
|
|
| BLAKE2b-256 |
4b19ba4ba7b1822a403381d3355cef7973ca6e430d45a25b65b56f4e1c04973a
|
Provenance
The following attestation bundles were made for esource_client_api-1.1.1-py3-none-any.whl:
Publisher:
publish.yml on Eppop-bet/client-api-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
esource_client_api-1.1.1-py3-none-any.whl -
Subject digest:
df20e59cfe4e7e63543697c10a0e844e36fec6f10bff8fcba9e6b9814ddd243f - Sigstore transparency entry: 202174183
- Sigstore integration time:
-
Permalink:
Eppop-bet/client-api-sdk@4ca0f12dcbc014e4dafc29035a52592d0adde715 -
Branch / Tag:
refs/tags/v1.1.1 - Owner: https://github.com/Eppop-bet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4ca0f12dcbc014e4dafc29035a52592d0adde715 -
Trigger Event:
release
-
Statement type: