mode-client is a typed Python client for the Mode API.
mode-client requires Python version 3.8 or higher.
pip install mode-client
import mode_client
client = mode_client.ModeClient("workspace", "token", "password")
print(client.space.list())
The following objects and methods are implemented:
Object | Methods |
---|---|
account (user/organization) |
get(account) -> Account |
space (collection) |
get(space) -> Space list([filter]) -> List[Space] create(name, description) -> Space update(space, [name], [description]) -> Space delete(space) |
report | get(report) -> Report list(space) -> List[Report] update(report, [name], [description], [space_token]) -> Report delete(report) archive(report) -> Report unarchive(report) -> Report sync(report, [commit_message) -> Report |
report_run | get(report, run) -> ReportRun list(report) -> ReportRuns clone(report, run) -> ReportRun create(report, parameters) -> ReportRun |
query | get(report, query) -> Query list(report) -> List[Query] create(report, raw_query, data_source_id, name) update(report, query, [raw_query], [data_source_id], [name]) -> Query delete(report, query) |
query_run | get(report, run, query_run) -> QueryRun list(report, run) -> List[QueryRun] |
If there's a particular object or method you'd like to see, please open a feature request.
Your Mode workspace is the first part of your Mode URL (https://app.mode.com/organizations/).
To obtain a Mode token and password, follow the instructions here.
No, mode-client supports a subset of the Mode API most commonly used for auditing Mode workspaces. If you'd like to see an object or method supported, please open a feature request.
Mode throttles clients to ~1 request/second.
If you're running into this error use time.sleep
to slow down your requests.
mode-client uses the typing.Literal type which was introduced in Python 3.8.
mode-client is typed to enable explicit discovery of the methods for each object and their type signatures in the API. This enables editor autocompletion for both code and data in line with modern Python best practices.
The data returned from the Mode API is also validated using Pydantic to ensure it is typed correctly.
Does mode-client support Mode's Discovery API?
No, mode-client captures the Mode workspace state in real time. Mode's Discovery API is updated once a day which means the workspace state is always somewhat stale.