gcore package provides typed access to the full Gcore REST API from Python 3.9+. Both synchronous (Gcore) and asynchronous (AsyncGcore) clients are included, powered by httpx. All request parameters are typed as TypedDict; all responses are Pydantic models with editor autocomplete.
Package: gcore on PyPI · Source: gcore-python on GitHub
Requirements
Python 3.9 or higher.Install
Initialize the client
The SDK constructor reads three environment variables automatically — no arguments needed:GCORE_CLOUD_PROJECT_ID and GCORE_CLOUD_REGION_ID set, Cloud API methods use them automatically — no project ID or region ID is passed to individual calls:
.env file and load them with python-dotenv.
First call
These calls verify authentication, list projects, and find active regions with VM support:Method naming pattern
SDK methods map directly to API endpoints. The resource path in the URL becomes a chain of attributes on the client:
The API reference code samples show the exact SDK method for every endpoint.
Polling task completion
Cloud API write operations return a task ID instead of the created resource directly. Use_and_poll convenience methods where available - they submit the request and block until the resource is ready:
_and_poll is not available for a resource, use tasks.poll() directly as an alternative:
Pagination
List methods return auto-paginating iterators. The SDK fetches additional pages automatically as the iterator is consumed:Error handling
All errors inherit fromgcore.APIError:
Retries and timeouts
The client retries connection errors, 408, 409, 429, and 5xx errors twice by default with exponential backoff. The default timeout is 2 minutes.Async usage
UseAsyncGcore for concurrent operations or when integrating with async frameworks such as FastAPI or aiohttp. All method signatures are identical to Gcore - add await and use async with:
asyncio.gather(). The example below creates three networks in parallel instead of sequentially:
aiohttp as the HTTP backend: