Python
Introduction
The Mangopay Python SDK makes working with the Mangopay API easier in a Python environment.
The SDK package is available on Pythony Package Index (PyPI): mangopay4-python-sdk
Caution – Use only the mangopay4 package (late Nov 2025)
Please ensure you use only the package with mangopay4 in the name (this is the package name and has no connection with the SDK version number).
Any other package must not be used. You need to update your package manually.
Since November 25, 2025, Mangopay’s official SDKs are no longer accessible on GitHub (with the exception of PHP for publication reasons).
Prerequisites
To run the Mangopay Python SDK, you’ll need:
- A
ClientIdand an API key – if you don’t have these, contact Sales to get access to the Mangopay Dashboard - Python 3.13 (recommended) down to 3.9 (not recommended) installed:
- pip package manager
- requests library
- blinker library
Getting started
1. Install the SDK
By installing this package with pip3, all dependencies are installed for you:
2. Initialize and configure the SDK
The configuration object of the SDK supports all the following properties:
SDK usage
All endpoints are documented with the related Python SDK method throughout the Mangopay documentation. You should adjust the code examples provided for your usage.
API handler
When creating a new handler, there are multiple settings to specify depending on your needs.
Proxy support
You can use proxies for https, http and ftp protocols:
Storage strategy
There are two storage strategies that can be used for OAuth tokens:
StaticStorageStrategy()saves the token in memory. If no storage strategy is specified, this method is used by default.FileStorageStrategy()saves the token in a temporary file.
Requests timeout
You can set the amount of time in seconds after that the requests will timeout:
Idempotency support
To make a request with idempotency support, add idempotency_key parameter to your function.
For more information, see the Idempotency article.
In order to retrieve the request made using this idempotency:
Pagination
Note - Listing elements
If you do not specify the page and the per_page parameters, only the first 10 elements will be displayed.
For endpoints that support pagination, you can use an object containing the page and per_page keys.
As a result, the output is paginated, and the total number of items and the total number of pages is provided.
For example, with the List all Users endpoint:
Filtering
For endpoints that support filtering, you can use an object containing the filtering parameters.
For example, with the List Transaction for a Wallet endpoint:
Error handling
The SDK provides the APIError class to wrap HTTP errors returned by the API. You can use a Python try block and exception blocks to handle API errors, for example: