Skip to content

Repository files navigation

extend-python

Python library for the Extend API

Python VersionLicense: MITCode style: blackDocumentation

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

importasynciofromextendimportExtendClientfromextend.authimportBasicAuthasyncdefmain():
# Initialize the clientclient=ExtendClient(
auth=BasicAuth(
"your-api-key",
"your-api-secret",
)
)
# Get all virtual cardsresponse=awaitclient.virtual_cards.get_virtual_cards()
print("Virtual Cards:", response["virtualCards"])
# Get all transactionsresponse=awaitclient.transactions.get_transactions()
print("Transactions:", response["report"]["transactions"])
# Run the async functionasyncio.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.

fromextendimportExtendClientfromextend.authimportBearerAuthauth=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:

fromextend.authimportBasicAuthfromextend.clientimportAPIClientapi_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 key
  • EXTEND_API_SECRET: Your Extend API secret
  • EXTEND_TEST_RECIPIENT: Email address for test card recipient
  • EXTEND_TEST_CARDHOLDER: Email address for test cardholder

Development Setup

  1. Clone the repository:

    git clone https://github.com/paywithextend/extend-python.git
    cd extend-python
  2. Create and activate a virtual environment:

    python -m venv venv
    source venv/bin/activate # On Windows: venv\Scripts\activate
  3. Install development dependencies:

    pip install -e ".[dev]"
  4. 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!

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

About

Python library for the Extend API

Topics

Resources

Contributing

Stars

14 stars

Watchers

10 watching

Forks

Releases

Packages

Used by

Contributors

Languages