Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

aranke-archive/mode-client

Repository files navigation

mode-client

mode-client is a typed Python client for the Mode API.


PyPI - Python Version PyPI PyPI - License

GitHub Workflow Status pre-commit.ci status Codecov

Installation

mode-client requires Python version 3.8 or higher.

pip install mode-client

Usage

import mode_client

client = mode_client.ModeClient("workspace", "token", "password")
print(client.space.list())

API

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.

FAQ

How do I find my workspace, token and password?

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.

Does mode-client support the full Mode API?

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.

I'm getting a 429 error. What do I do?

Mode throttles clients to ~1 request/second. If you're running into this error use time.sleep to slow down your requests.

Why doesn't mode-client support Python 3.7?

mode-client uses the typing.Literal type which was introduced in Python 3.8.

What does it mean for mode-client to be typed?

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.