Skip to main content

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 (Miro class) for handling user interactions, including authorization and token management.
  • A stateless low-level client (MiroApi object) for back-end communications, automation scripts, and operations requiring the OAuth access token. Additionally, MiroApi methods 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_ID
  • MIRO_CLIENT_SECRET
  • MIRO_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:

  1. Check if the current user has authorized the app: miro.is_authorized.
  2. Redirect for authorization if needed: miro.auth_url.
  3. Exchange authorization code for an access token: miro.exchange_code_for_access_token(code).
  4. 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.

Release files for miro-api 2.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for miro-api 2.2.4
File Size Uploaded
miro_api-2.2.4.tar.gz 185.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for miro-api 2.2.4
File Interpreter ABI Platform
miro_api-2.2.4-py3-none-any.whl Python 3 none any Details

Total release size: 1.2 MB

Release files / miro_api-2.2.4.tar.gz

Download URL miro_api-2.2.4.tar.gz
Size 185.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ebe7bb3d1826c9a78ac12068f7493c0d8e83199559ec7c430c30903c37895873
BLAKE2b-256 checksum
How to use checksums
b603b0fbea4a0dbfc8465894f9da6203fb2be2d4c8765f4c5afa23d923263f27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.21

Release files / miro_api-2.2.4-py3-none-any.whl

Download URL miro_api-2.2.4-py3-none-any.whl
Size 977.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e089abd0e0c1847e4bce2464d8ff83ef3f4a44b78a9b295ab1707dd825661f8
BLAKE2b-256 checksum
How to use checksums
130bb303657266c1ebbe6e944058461fdc8227d6f1b98ad7213936395cf9d473
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.21

Release history Release notifications | RSS feed

This release

2.2.4 This release

2 release files

2.2.3

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.2

2 release files

2.1.1

2 release files

2.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page