Python API client
See Using the web API for a calculation example and service URLs.
Python client functions for harvesting results from the PyDIET ETC
- class Client(api_url: str | None = None)[source]
Bases:
objectClass for the Python client API.
- Parameters:
api_url (str, optional) -- API root URL (defaults to "api_path" setting).
Examples
>>> from .client import Client >>> client = Client("https://etc.example/api") >>> client.api_url 'https://etc.example/api'
- query(query: ETCQueryModel, timeout: float = 10.0) ETCResponseModel[source]
Query the ETC API.
- Parameters:
query (ETCQueryModel) -- Validated ETC query. Its
instrumentfield selects the endpoint; the remaining non-null fields are sent as query parameters.timeout (float, optional) -- HTTP timeout in seconds.
- Returns:
response (ETCResponseModel) -- Validated ETC response.
- Raises:
RuntimeError -- If the request fails, the server returns an error response, the response is not JSON, or its JSON does not match the response model.