extend-python
Python library for the Extend API
A Python client for the Extend API, providing a simple and intuitive interface for managing virtual cards, transactions, and more.
Features
- Create and manage virtual cards
- Handle recurring card operations
- Track transactions
- Expense management
Documentation
For detailed API documentation, please visit our Stoplight documentation.
Installation
From PyPI
pip install paywithextend
From Source
git clone https://github.com/paywithextend/extend-python.git
cd extend-python
pip install -e .
Quick Start
import asyncio
from extend import ExtendClient
from extend.auth import BasicAuth
async def main():
# Initialize the client
client = ExtendClient(
auth=BasicAuth(
"your-api-key",
"your-api-secret",
)
)
# Get all virtual cards
response = await client.virtual_cards.get_virtual_cards()
print("Virtual Cards:", response["virtualCards"])
# Get all transactions
response = await client.transactions.get_transactions()
print("Transactions:", response["report"]["transactions"])
# Run the async function
asyncio.run(main())
Using Custom Authorization
Both ExtendClient and APIClient accept reusable authorization strategies defined in extend.auth, enabling scenarios like JWT-based access or shared credentials across clients.
from extend import ExtendClient
from extend.auth import BearerAuth
auth = BearerAuth(jwt_token="your-jwt-token")
client = ExtendClient(auth=auth)
If you want to work with the lower-level APIClient directly, you can pass any Authorization implementation:
from extend.auth import BasicAuth
from extend.client import APIClient
api_client = APIClient(auth=BasicAuth("your-api-key", "your-api-secret"))
Environment Variables
The following environment variables are required for integration tests and examples:
EXTEND_API_KEY: Your Extend API keyEXTEND_API_SECRET: Your Extend API secretEXTEND_TEST_RECIPIENT: Email address for test card recipientEXTEND_TEST_CARDHOLDER: Email address for test cardholder
Development Setup
-
Clone the repository:
git clone https://github.com/paywithextend/extend-python.git cd extend-python
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install development dependencies:
pip install -e ".[dev]"
-
Run tests:
# Run all tests pytest # Run only unit tests pytest tests/test_client.py # Run only integration tests pytest tests/test_integration.py
Testing
The project includes both unit tests and integration tests:
- Unit tests (
tests/test_client.py): Test the client's internal logic and validation - Integration tests (
tests/test_integration.py): Test actual API interactions - Example notebook (
notebooks/api_testing.ipynb): Interactive examples
To run integration tests, make sure you have set up the required environment variables.
Contributing
We welcome contributions from the community!
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Extend API Documentation
- httpx for async HTTP requests
Release files for paywithextend 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| paywithextend-2.0.0.tar.gz | 15.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| paywithextend-2.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:39.1 kB
Release files / paywithextend-2.0.0.tar.gz
| Download URL | paywithextend-2.0.0.tar.gz |
|---|---|
| Size | 15.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1d91628f6f3910d5481c636176c01d4b98fc735c5b6bc649c12c4dd26a13db8b
|
|
BLAKE2b-256 checksum How to use checksums |
57ecda65487f7255b3b355d7b044251bf877dee9a723173a522b79c6850be736
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|
Release files / paywithextend-2.0.0-py3-none-any.whl
| Download URL | paywithextend-2.0.0-py3-none-any.whl |
|---|---|
| Size | 23.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8e498b2e87f3b18bfbce607bc79dd5c3c2b3b311834c7c820d16b49c1cfde896
|
|
BLAKE2b-256 checksum How to use checksums |
672c52da68e6dfd604f54f005001e11a18cbebbe2bfc295e47a9b43ccefa6119
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|