Skip to main content

Mesta Python Library

pypi

The official Mesta client library. Each method calls one API endpoint. For end-to-end flows such as onboarding a sender or making a payout, follow the guides at https://docs.mesta.xyz.

Table of Contents

Documentation

API reference documentation is available here.

Installation

pip install mesta

Reference

A full reference for this library is available here.

Usage

Instantiate and use the client with the following:

from mesta import Mesta

client = Mesta(
    api_key="<value>",
    api_secret="<x-api-secret>",
)

client.merchants.accept_terms(
    merchant_id="merchantId",
)

Environments

This SDK allows you to configure different environments for API requests.

from mesta import Mesta
from mesta.environment import MestaEnvironment

client = Mesta(
    environment=MestaEnvironment.PRODUCTION,
)

Async Client

The SDK also exports an async client so that you can make non-blocking calls to our API. Note that if you are constructing an Async httpx client class to pass into this client, use httpx.AsyncClient() instead of httpx.Client() (e.g. for the httpx_client parameter of this client).

import asyncio

from mesta import AsyncMesta

client = AsyncMesta(
    api_key="<value>",
    api_secret="<x-api-secret>",
)


async def main() -> None:
    await client.merchants.accept_terms(
        merchant_id="merchantId",
    )


asyncio.run(main())

Exception Handling

When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error will be thrown.

from mesta.core.api_error import ApiError

try:
    client.merchants.accept_terms(...)
except ApiError as e:
    print(e.status_code)
    print(e.body)

Advanced

Access Raw Response Data

The SDK provides access to raw response data, including headers, through the .with_raw_response property. The .with_raw_response property returns a "raw" client that can be used to access the .headers and .data attributes.

from mesta import Mesta

client = Mesta(...)
response = client.merchants.with_raw_response.accept_terms(...)
print(response.headers)  # access the response headers
print(response.status_code)  # access the response status code
print(response.data)  # access the underlying object

Retries

The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long as the request is deemed retryable and the number of retry attempts has not grown larger than the configured retry limit (default: 2).

Which status codes are retried depends on the retryStatusCodes generator configuration:

legacy (current default): retries on

  • 408 (Timeout)
  • 409 (Conflict)
  • 429 (Too Many Requests)
  • 5XX (All server errors, including 500)

recommended: retries on

  • 408 (Timeout)
  • 409 (Conflict)
  • 429 (Too Many Requests)
  • 502 (Bad Gateway)
  • 503 (Service Unavailable)
  • 504 (Gateway Timeout)

Use the max_retries request option to configure this behavior.

client.merchants.accept_terms(..., request_options={
    "max_retries": 1
})

Timeouts

The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.

from mesta import Mesta

client = Mesta(..., timeout=20.0)

# Override timeout for a specific method
client.merchants.accept_terms(..., request_options={
    "timeout": 1
})

Custom Client

You can override the httpx client to customize it for your use-case. Some common use-cases include support for proxies and transports.

import httpx
from mesta import Mesta

client = Mesta(
    ...,
    httpx_client=httpx.Client(
        proxy="http://my.test.proxy.example.com",
        transport=httpx.HTTPTransport(local_address="0.0.0.0"),
    ),
)

Retries and writes

The client retries a request up to two times on 408, 429 and 5xx responses, with backoff and jitter. The Mesta API does not accept an idempotency key yet, so a retried write, for example creating an order or a beneficiary, can be processed twice if the first attempt reached the server before it failed. Until idempotency keys are available, disable retries on writes and handle the error in your code:

client.orders.create(..., request_options={"max_retries": 0})

Metadata

Release files for mesta 0.1.1

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

Source distribution (sdist)

Source distribution for mesta 0.1.1
File Size Uploaded Provenance Actions
mesta-0.1.1.tar.gz 266.7 kB With provenance Details for mesta-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mesta 0.1.1
File Interpreter ABI Platform Actions
mesta-0.1.1-py3-none-any.whl Python 3 none any Details for mesta-0.1.1-py3-none-any.whl

Total release size: 902.7 kB

Release files / mesta-0.1.1.tar.gz

Download URL mesta-0.1.1.tar.gz
Size 266.7 kB
Tags Source
SHA-256 checksum
How to use checksums
572e773e62801033c6f8d6149c992bfba9cf913e709805c03236a9a73dccbc29
BLAKE2b-256 checksum
How to use checksums
15b3d72ba11e9af15711279f36ca093d0d0cdf4d3f2a17b8167747cbe1337292
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.

Transparency log

Release files / mesta-0.1.1-py3-none-any.whl

Download URL mesta-0.1.1-py3-none-any.whl
Size 636.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6f55339b2992302d20fca5825f2f65c7f4d500498c5e58b749739f22a34485a4
BLAKE2b-256 checksum
How to use checksums
8eaf3363b009a14e7fbb4b981084c92cf63ee6b41e1a5bb61c1af53de52a8e53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.

Transparency log

Security for mesta 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mesta-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

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