class Client:
Constructor: Client(project_name, api_key, client_id, client_secret, ...)
Low-level HTTP client for the DataGraphs REST API.
Handles authentication, pagination, and batched writes.
| Method | __init__ |
Initialise the DataGraphs client. |
| Method | apply |
Create or update datasets so they match the supplied list. |
| Method | apply |
Apply a schema to the project, replacing the currently active domain model. |
| Method | clear |
Delete all data from a dataset, keeping the dataset itself intact. |
| Method | create |
Create a new dataset. |
| Method | delete |
Delete a single entity by class and ID. |
| Method | drop |
Drop a dataset and all its data entirely. |
| Method | get |
Retrieve all entities of a given type. |
| Method | get |
Retrieve all datasets in the project. |
| Method | get |
Retrieve the active schema for the project. |
| Method | put |
Load entities into a dataset. |
| Method | query |
Query the API with filters, facets, sorting, and pagination. |
| Method | set |
Set the wait time between paginated requests. |
| Method | status |
Check the API service status. |
| Method | tear |
Remove all datasets and their data from the project. |
| Method | update |
Update an existing dataset. |
| Constant | AUTH |
Undocumented |
| Constant | DATASETS |
Undocumented |
| Constant | DEFAULT |
Undocumented |
| Constant | DEFAULT |
Undocumented |
| Constant | DEFAULT |
Undocumented |
| Constant | DEFAULT |
Undocumented |
| Constant | HTTP |
Undocumented |
| Constant | HTTP |
Undocumented |
| Constant | HTTP |
Undocumented |
| Constant | HTTP |
Undocumented |
| Constant | HTTP |
Undocumented |
| Constant | HTTP |
Undocumented |
| Constant | MAX |
Undocumented |
| Constant | PROD |
Undocumented |
| Instance Variable | project |
Undocumented |
| Property | wait |
The current wait time in milliseconds between paginated requests. |
| Static Method | _build |
Build a query string from key-value pairs. |
| Method | _assert |
Undocumented |
| Method | _cache |
Return a cache-busting timestamp value. |
| Method | _get |
Undocumented |
| Method | _get |
Undocumented |
| Method | _get |
Undocumented |
| Method | _get |
Undocumented |
| Method | _has |
Undocumented |
| Method | _request |
Execute an HTTP request with automatic auth retry. |
| Instance Variable | _api |
Undocumented |
| Instance Variable | _auth |
Undocumented |
| Instance Variable | _batch |
Undocumented |
| Instance Variable | _client |
Undocumented |
| Instance Variable | _client |
Undocumented |
| Instance Variable | _http |
Undocumented |
| Instance Variable | _service |
Undocumented |
| Instance Variable | _wait |
Undocumented |
| Property | _base |
Undocumented |
str, api_key: str, client_id: str = '', client_secret: str = '', batch_size: int = DEFAULT_BATCH_SIZE, service_url: str = PROD_URL):
¶
Initialise the DataGraphs client.
| Parameters | |
projectstr | Name of the project. |
apistr | API key for authentication. |
clientstr | OAuth client ID (required for write operations). |
clientstr | OAuth client secret (required for write operations). |
batchint | Number of items to process in each batch. |
servicestr | Base URL for the API service. |
Create or update datasets so they match the supplied list.
New datasets are created; existing datasets with changes are updated. Waits for confirmation that all datasets have been applied.
| Parameters | |
datasets:list[ | Datasets to apply. |
timeoutint | Maximum time in milliseconds to wait for the API to confirm all datasets are applied. |
| Raises | |
DatagraphsError | If datasets are not applied within the timeout. |
Apply a schema to the project, replacing the currently active domain model.
| Parameters | |
schema:DatagraphsSchema | The schema to apply. |
Delete all data from a dataset, keeping the dataset itself intact.
| Parameters | |
datasetstr | The slug of the dataset to clear. |
Delete a single entity by class and ID.
| Parameters | |
classstr | The entity class. |
entitystr | The entity identifier. |
str, lang: str = 'all', include_date_fields: bool = False) -> list[ dict[ str, Any]]:
¶
Retrieve all entities of a given type.
Automatically paginates through all results.
| Parameters | |
classstr | The entity class to fetch. |
lang:str | Language code for results (default 'all'). |
includebool | Whether to include system date metadata. |
| Returns | |
list[ | A list of entity dicts. |
Load entities into a dataset.
Automatically batches large payloads according to the configured batch_size.
| Parameters | |
dataset:str | Target dataset slug. |
data:dict[ | A single entity dict or a list of entity dicts. |
| Returns | |
int | The number of entities loaded. |
str = '_all', q: str = '', filters: str = '', facets: str = '', facet_size: int = -1, date_facets: str = '', fields: str = '', embed: str = '', sort: str = '', ids: str = '', lang: str = 'all', page_no: int = -1, page_size: int = -1, previous_page_token: str = '', next_page_token: str = '', include_date_fields: bool = False) -> list[ dict[ str, Any]] | tuple[ list[ dict[ str, Any]], list[ dict[ str, Any]]]:
¶
Query the API with filters, facets, sorting, and pagination.
| Parameters | |
dataset:str | Dataset slug to query (default '_all'). |
q:str | Free-text search query string. |
filters:str | Filter expression (e.g. 'type:Person'). |
facets:str | Comma-separated facet field names. |
facetint | Number of facet values to return (default 10). |
datestr | Date facet specification. |
fields:str | Comma-separated field names to include in results. |
embed:str | Embedding depth for related entities. |
sort:str | Sort expression (e.g. 'label:asc'). |
ids:str | Comma-separated entity IDs to fetch directly. |
lang:str | Language code for results (default 'all'). |
pageint | Page number for offset-based pagination. |
pageint | Number of results per page. |
previousstr | Token for cursor-based backward pagination. |
nextstr | Token for cursor-based forward pagination. |
includebool | Whether to include system date metadata. |
| Returns | |
list[ | A list of result dicts, or a (results, facets) tuple when facets are requested. |
Remove all datasets and their data from the project.
| Parameters | |
dropbool | If True, drops each dataset entirely. If False, only clears the data from each dataset. |
str, page_size: int, lang: str, include_date_fields: bool, next_page_token: str = '', page_no: int = -1) -> str:
¶
Undocumented
str = '_all', q: str = '', filters: str = '', facets: str = '', facet_size: int = -1, date_facets: str = '', fields: str = '', embed: str = '', sort: str = '', ids: str = '', lang: str = 'all', page_no: int = -1, page_size: int = -1, previous_page_token: str = '', next_page_token: str = '', include_date_fields: bool = False) -> str:
¶
Undocumented
HTTP, url: str, _retry_count: int = 0, **kwargs) -> dict[ str, Any] | None:
¶
Execute an HTTP request with automatic auth retry.
| Parameters | |
method:HTTP | The HTTP method to use. |
url:str | The request URL. |
_retryint | Internal retry counter (do not set externally). |
| **kwargs | Additional arguments forwarded to the HTTP client. |
| Returns | |
dict[ | Parsed JSON response for GET requests, or None for mutating requests. |
| Raises | |
AuthenticationError | If authentication fails after max retries. |
DatagraphsError | If the request fails for any other reason. |