Skip to main content

Integration SDK for Mesh API Services

Project description


parent: API Integration SDKs title: Python layout: page

Python SDKs for Mesh APIs

CI Status

This directory is the Python Monorepo for all official Mesh API client SDKs.

Quick Start for API Consumers

This guide is for developers who want to use these SDKs in their own applications.

1. Installation

Install the desired SDK integration library from PyPI using pip:

pip install meshtrade

2. Example Usage

Here is a basic example of how to use SDK clients:

import asyncio
from meshtrade.account.v1 import AccountService
from meshtrade.iam.v1 import as IAMService

# NOTE: ensure that MESH_API_KEY="your-secret-api-key" is set

async def main():
    # Instantiate the client for the Account v1 service
    account_client = AccountService()

    # Call an RPC method
    try:
        response = await account_client.get(number="1000111")
        print("Successfully retrieved account:", response.account)
    except Exception as e:
        print(f"An error occurred: {e}")
    
    # You can similarly use other clients
    iam_client = IAMService()
    # ... use iam_client ...

if __name__ == "__main__":
    asyncio.run(main())

For more detailed information on each SDK, please see their individual READMEs:

Repository Structure

This directory is a workspace within a larger polyglot monorepo. It manages versioned Python packages for each integration SDK.

└── python
    ├── README.md               <-- You are HERE
    ├── pyproject.toml          <-- SDK workspace configuration
    ├── requirements-dev.txt    <-- SDK Workspace development requirements
    ├── tox.ini                 <-- Task automation configuration
    ├── src
    │   └── meshtrade
    │       ├── __init__.py
    │       └── account         <-- Defines the mesh account api service
    │           └── vX          <-- Defines the mesh account vX api SDK
    │               ├── __init__.py
    │               ├── account_pb2.py
    │               └── README.md
    └── tests
        ├── integration
        └── unit

Developer Guide

This guide is for developers contributing to these SDKs. It explains how to set up the local development environment for this Python monorepo.

1. Prerequisites:

  • Python 3.8+
  • The venv module (usually included with Python)

2. Environment Setup

All commands should be run from within this python/ directory.

Create and activate a single shared virtual environment for the workspace:

python3 -m venv .venv
source .venv/bin/activate

Your terminal prompt should now be prefixed with (.venv), indicating the environment is active.

Tip: If you are in an IDE that supports python you can point your IDE to the interpreter in this environment relative to the source of the repository: ./python/.venv/bin/python. e.g. with VS code:

'cmd + shift + p' > 'Python: Select Interpreter' > 'Enter interpreter path...' > './python/.venv/bin/python'

3. Install Dependencies

This project uses pip-tools to manage dependencies for a reproducible development environment. The top-level pyproject.toml is the source of truth for our direct dependencies, and requirements-dev.txt is the "lock file" that guarantees identical setups for everyone.

A) For a new setup (e.g. after a git pull):

Install the locked dependencies from requirements-dev.txt:

pip install -r requirements-dev.txt

This synchronises the local virtual environment to match the exact versions in the lock file.

Once this is complete you are set up to begin programming in the sdk source code in: ./python/src/mesh.

Next to make the SDK discoverable locally for tests do:

pip install -e .

B) After a manual change to pyproject.toml (e.g. to install a new workspace level dependency or bump its version):

If changes are made in the pyproject.toml then the lockfile must be regenerated:

# Step 1: Re-compile the dependencies to update the lock file
pip-compile --extra=dev --output-file=requirements-dev.txt pyproject.toml

# Step 2: Synchronise the local virtual environment again with the newly updated lock file
pip install -r requirements-dev.txt

4. Run Common Development Tasks

Tox is used as the as the main command runner for all common tasks like linting, testing, and building.

Tasks can be run from the command line (within the active virtual environment) as follows:

  • The linter:
tox -e lint
  • The unit tests:
tox -e unit-tests
  • The integration tests:
MESH_API_KEY="your-secret-api-key" tox -e integration-tests
  • All checks (linting and unit tests):
tox

5. Building and Publishing Packages

  • Build all packages: The build task in tox will create the distributable wheel (.whl) and sdist (.tar.gz) files for all packages and place them in their respective dist/ folders.
tox -e build
  • Publish to PyPi: The twine tool is used to securely upload the built packages to PyPI. This is done as part of the official release process.
twine upload ./dist/*

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

meshtrade-0.0.4.tar.gz (29.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

meshtrade-0.0.4-py3-none-any.whl (74.9 kB view details)

Uploaded Python 3

File details

Details for the file meshtrade-0.0.4.tar.gz.

File metadata

  • Download URL: meshtrade-0.0.4.tar.gz
  • Upload date:
  • Size: 29.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for meshtrade-0.0.4.tar.gz
Algorithm Hash digest
SHA256 461e88ee346891889b49e43ba0896d407c7414724fdfbd0a63cce065a40bc24e
MD5 12f58b53f6757bb835cfdefb1df94bef
BLAKE2b-256 fd31ee5e62d76ddc9737fe0f3db606e7985eaf4537ee1e6762e3d2fbfcd4a6f3

See more details on using hashes here.

File details

Details for the file meshtrade-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: meshtrade-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 74.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for meshtrade-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 572619729de1417b8c2dad4fd836a43bc8eb454059db24234105ba9f79cccfdf
MD5 b6da0285fa01d25df805f009864d9b2e
BLAKE2b-256 7e1639f35702d64730c59389dfba1074e2ba3d630c47ed4faf28048432202eac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page