Method Python SDK
The `method-python` library is an official Python client for interacting with the Method API. It provides convenient access to the Method platform's financial services, allowing developers to integrate banking and payment functionalities into their applications. Currently at version 2.1.1, the library is actively maintained with regular updates, including both minor feature enhancements and major version releases.
Warnings
- breaking Major version `v2.0.0` was released without explicit breaking changes detailed in the GitHub release notes. As with any major version bump, it is highly recommended to review the project's changelog (if available on the GitHub repository or official documentation) before upgrading to understand potential API changes, deprecations, or behavioral shifts that might affect your existing codebase.
- breaking Version `v1.2.0` mentioned that it 'Addressed breaking change in v1.1.13'. This indicates that breaking changes might have been introduced in `v1.1.13` and subsequently resolved or adapted in `v1.2.0`. Users on versions older than `v1.2.0` should be aware of potential API instability or necessary adjustments if upgrading through this range.
- gotcha API keys and sensitive credentials should never be hardcoded directly into your source code. Exposing API keys can lead to unauthorized access to your Method account and financial data.
- gotcha The `Method` client initialization allows for an optional `base_url` parameter (added in v2.1.0) to override the default Method API endpoint. While useful for testing or custom deployments, ensure you are pointing to the correct and secure Method API endpoint for production environments to avoid unexpected behavior or security issues.
Install
-
pip install method-python
Imports
- Method
from method import Method
Quickstart
import os
from method import Method
# Initialize the Method client with your API key from an environment variable
# It is highly recommended to use environment variables for sensitive data like API keys.
api_key = os.environ.get('METHOD_API_KEY', 'YOUR_API_KEY_HERE')
# Initialize Method client for production environment
# Replace 'YOUR_API_KEY_HERE' with a placeholder or ensure it's loaded from env
method = Method(env='production', api_key=api_key)
# Example: List entities (replace with actual API call based on Method API docs)
try:
# This is a placeholder; consult Method API documentation for actual endpoints
# For instance, if there's a way to list all entities:
# entities = method.entities.list()
# print(f"Found {len(entities)} entities.")
# print(entities)
print("Method client initialized successfully. Consult API docs for specific calls.")
except Exception as e:
print(f"An error occurred: {e}")