Miro API client
Project description
Miro Python client
The Miro Python client library offers a comprehensive interface for integrating Miro's REST API capabilities into Python-based applications.
You can use the client to implement back-end functionality in your Miro app, such as:
- OAuth 2.0 authorization
- Programmatic data exchange with an external system
- Data storage in the app backend
The library provides two main components:
- A stateful high-level client (
Miroclass) for handling user interactions, including authorization and token management. - A stateless low-level client (
MiroApiobject) for back-end communications, automation scripts, and operations requiring the OAuth access token. Additionally,MiroApimethods enable retrieving organization information and managing teams and users (available via Enterprise API for users on an Enterprise plan).
Prerequisites
- Python 3.9 or higher.
Installation
To integrate the miro_api package into your project, you can use either pip or poetry as follows:
Using pip:
pip install miro_api
Using poetry:
poetry add miro_api
Configuration
The high-level client (Miro) automatically loads app configuration from the following environment variables:
MIRO_CLIENT_IDMIRO_CLIENT_SECRETMIRO_REDIRECT_URL
Alternatively, these values can be passed directly to the Miro constructor.
Quickstart
To start using the high-level Miro client, import it, and then create a new instance:
import miro_api
miro = miro_api.Miro()
print(miro.auth_url)
Or, initialize it with custom configuration:
import miro_api
miro = miro_api.Miro(
client_id='<your_app_client_id>>',
client_secret='<your_app_client_secret>',
redirect_url='https://example.com/miro/redirect/url',
)
print(miro.auth_url)
To start using the low-level MiroApi client, import it, and then create a new instance:
import miro_api
api = miro_api.MiroApi('<access_token>')
print(api.get_boards())
OAuth authorization
The Miro client provides methods to manage the OAuth authorization flow:
- Check if the current user has authorized the app:
miro.is_authorized. - Redirect for authorization if needed:
miro.auth_url. - Exchange authorization code for an access token:
miro.exchange_code_for_access_token(code). - Make API calls on behalf of the authorized user:
miro.api.get_board(board_id)
Storage
For storing user access and refresh tokens, the client library requires persistent storage. The client automatically refreshes access tokens before making API calls, if they are nearing their expiration time.
By default, persistent storage uses an in-memory dictionary to store state information. Pass storage to the Miro constructor as an option:
miro = miro_api.Miro(
storage=CustomMiroStorage(),
)
To support the client library storage functionality in your app, implement the following get and set interface:
class Storage(ABC):
"""Abstract class used by the stateful client to set and get State."""
@abstractmethod
def set(self, state: Optional[State]) -> None:
pass
@abstractmethod
def get(self) -> Optional[State]:
pass
🚧
For production deployments, we recommend using a custom implementation backed by a database.
Reference
Examples
See an example of implementing a simple server using Flask library in the example directory.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file miro_api-2.2.4.tar.gz.
File metadata
- Download URL: miro_api-2.2.4.tar.gz
- Upload date:
- Size: 185.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebe7bb3d1826c9a78ac12068f7493c0d8e83199559ec7c430c30903c37895873
|
|
| MD5 |
1d705f95e98ce43f50b08a63f466723d
|
|
| BLAKE2b-256 |
b603b0fbea4a0dbfc8465894f9da6203fb2be2d4c8765f4c5afa23d923263f27
|
File details
Details for the file miro_api-2.2.4-py3-none-any.whl.
File metadata
- Download URL: miro_api-2.2.4-py3-none-any.whl
- Upload date:
- Size: 977.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e089abd0e0c1847e4bce2464d8ff83ef3f4a44b78a9b295ab1707dd825661f8
|
|
| MD5 |
5e02ce49562ca741037d1b7342ee6553
|
|
| BLAKE2b-256 |
130bb303657266c1ebbe6e944058461fdc8227d6f1b98ad7213936395cf9d473
|