Skip to main content

An unofficial Python API Wrapper for the Revolut Business API

Project description

PyRevolut: A Revolut Business API Wrapper

codecov PyPI Package latest release Supported versions License PyPI Package download count (per month) Black code style Ruff code quality GitHub Workflow Status

pyrevolut is an un-official wrapper around the Revolut Business API.

Installation

pip install pyrevolut

Usage

Basic Usage

from pyrevolut.client import Client

CREDS_JSON_LOC = "path/to/creds.json"

client = Client(
    creds_loc=CREDS_JSON_LOC,
    sandbox=True,
)

# Initialize the client
client.open()

# List all accounts for the authenticated user
accounts = client.Accounts.get_all_accounts()

# Close the client
client.close()

# You can also use the client as a context manager
with Client(
    creds_loc=CREDS_JSON_LOC,
    sandbox=True
) as client:
    accounts = client.Accounts.get_all_accounts()

Advanced Usage

It is possible to use the client library asynchronously by using the AsyncClient object.

import asyncio
from pyrevolut.client import AsyncClient

CREDS_JSON_LOC = "path/to/creds.json"

client = AsyncClient(
    creds_loc=CREDS_JSON_LOC,
    sandbox=True,
)

# Run without context manager
async def run():
    await client.open() 
    accounts = await client.Accounts.get_all_accounts()
    await client.close() 
    return accounts

# Run with context manager
async def run_context_manager():
    async with client:
        accounts = await client.Accounts.get_all_accounts() 
    return accounts

# List all accounts for the authenticated user
accounts = asyncio.run(run())
accounts_context_manager = asyncio.run(run_context_manager())

Authentication

In order to make use of the Revolut Business API, you will need to go through several steps to authenticate your application. The basic guide can be found here. We have provided a simple CLI tool to help you generate the necessary credentials. This tool follows the steps outlined in the guide.

pyrevolut auth-manual

or equivalently

python -m pyrevolut auth-manual

Upon completion, you will have a .json file that you can use to authenticate your application.

Alternatively, in the event that you already have all your credential information stored, you can simply create a .json file with the following structure:

{
    "certificate": {
        "public": "public-certificate-base64-encoded",
        "private": "private-key-base64-encoded",
        "expiration_dt": "2500-01-01T00:00:00Z"
    },
    "client_assert_jwt": {
        "jwt": "client-assertion-jwt",
        "expiration_dt": "2500-01-01T00:00:00Z"
    },
    "tokens": {
        "access_token": "access-token",
        "refresh_token": "refresh-token",
        "token_type": "bearer",
        "access_token_expiration_dt": "2020-01-01T17:22:42.934699Z",
        "refresh_token_expiration_dt": "2500-01-01T00:00:00Z"
    }
}

API Support Status

The wrapper currently supports the following APIs:

  • Accounts
    • Retrieve all accounts
    • Retrieve an account
    • Retrieve account's full bank details
  • Cards (Live only)
    • Retrieve a list of cards
    • Create a card
    • Retrieve card details
    • Update card details
    • Terminate a card
    • Freeze a card
    • Unfreeze a card
    • Retrieve sensitive card details
  • Counterparties
    • Retrieve a list of counterparties
    • Retrieve a counterparty
    • Delete a counterparty
    • Create a counterparty (Personal)
    • Create a counterparty (Business)
    • Validate an account name (CoP)
  • Foreign exchange
    • Get an exchange rate
    • Exchange money
  • Payment drafts
    • Retrieve all payments drafts
    • Create a payment draft
    • Retrieve a payment draft
    • Delete a payment draft
  • Payout links
    • Retrieve a list of payout links
    • Retrieve a payout link
    • Create a payout link
    • Cancel a payout link
  • Simulations (Sandbox only)
    • Simulate a transfer state update
    • Simulate an account top-up
  • Team members (Live only)
    • Retrieve a list of team members
    • Invite a new memebr to your business
    • Retrieve team roles
  • Transactions
    • Retrieve a list of transactions
    • Retrieve a transaction
  • Transfers
    • Move money between your accounts
    • Create a transfer to another account
    • Get transfer reasons
  • Webhooks (v2)
    • Create a new webhook
    • Retrieve a list of webhooks
    • Retrieve a webhook
    • Update a webhook
    • Delete a webhook
    • Rotate a webhook signing secret
    • Retrieve a list of failed webhook events
    • Verify a webhook signature

Contributing

In order to facilitate a streamlined development process, we have a few guidelines that we would like to follow. Please refer to the CONTRIBUTING.md file for more information.

License

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

Disclaimer: pyrevolut is an un-official API wrapper. It is in no way endorsed by or affiliated with Revolut or any associated organization. Make sure to read and understand the terms of service of the underlying API before using this package. The authors accept no responsiblity for any damage that might stem from use of this package.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyrevolut-0.7.1.tar.gz (71.4 kB view details)

Uploaded Source

Built Distribution

pyrevolut-0.7.1-py3-none-any.whl (164.1 kB view details)

Uploaded Python 3

File details

Details for the file pyrevolut-0.7.1.tar.gz.

File metadata

  • Download URL: pyrevolut-0.7.1.tar.gz
  • Upload date:
  • Size: 71.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.9 Linux/6.5.0-1021-azure

File hashes

Hashes for pyrevolut-0.7.1.tar.gz
Algorithm Hash digest
SHA256 8463338e3c9e4e205c443c5be87150ac33ae9bc78f395cb527f994aa0f619d1e
MD5 0cdc89582b08b1f3736f97e42f07a2af
BLAKE2b-256 fea18c6a85c3a2630e9ddd0278675bc877ab1dda092acf875489596fac0af8e1

See more details on using hashes here.

File details

Details for the file pyrevolut-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: pyrevolut-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 164.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.9 Linux/6.5.0-1021-azure

File hashes

Hashes for pyrevolut-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f0cd2b792afd94b650ea0ac9c6daffb5f20e19550a633f745e76e911e4bdcb12
MD5 0073ee39575f0d1b980175f0232b57f9
BLAKE2b-256 278435d57518b1bd3738ba1c69ed7e996b533276c262cad1f236186f037c3bcf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page