Skip to content

Transactions Asynchronous Endpoints

This Transactions endpoint provides asynchronous methods to interact with the transactions of the authenticated user.

Example usage of the Transactions endpoint object:

import asyncio
from pyrevolut.client import AsyncClient

CREDS_JSON_LOC = "path/to/creds.json"

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

async def run():
    async with client:
        transactions = await client.Transactions.get_all_transactions()
        print(transactions)

asyncio.run(run())

EndpointTransactionsAsync

Bases: BaseEndpointAsync

The async Transactions API

Get the details of your transactions.

Note

An incoming or outgoing payment is represented as a transaction.

Source code in pyrevolut/api/transactions/endpoint/asynchronous.py
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
class EndpointTransactionsAsync(BaseEndpointAsync):
    """The async Transactions API

    Get the details of your transactions.

    Note
    ----
    An incoming or outgoing payment is represented as a transaction.
    """

    async def get_all_transactions(
        self,
        from_datetime: datetime | DateTime | str | int | float | None = None,
        to_datetime: datetime | DateTime | str | int | float | None = None,
        account_id: UUID | None = None,
        limit: int | None = None,
        transaction_type: EnumTransactionType | None = None,
        **kwargs,
    ) -> list[dict] | list[RetrieveListOfTransactions.Response]:
        """
        Retrieve the historical transactions based on the provided query criteria.

        The transactions are sorted by the created_at date in reverse chronological order,
        and they're paginated. The maximum number of transactions returned per page is specified by the
        count parameter. To get the next page of results, make a new request and use the created_at date
        from the last item of the previous page as the value for the to parameter.

        Note
        ----
        The API returns a maximum of 1,000 transactions per request.

        Note
        ----
        To be compliant with PSD2 SCA regulations, businesses on the Revolut Business Freelancer
        plans can only access information older than 90 days within 5 minutes of the first authorisation.

        Parameters
        ----------
        from_datetime : datetime | DateTime | str | int | float, optional
            The date and time you retrieve the historical transactions from, including
            this date-time.
            Corresponds to the created_at value of the transaction.
            Provided in ISO 8601 format.

            Used also for pagination. To get back to the previous page of results,
            make a new request and use the created_at date from the first item of the
            current page as the value for the from parameter.
        to_datetime : datetime | DateTime | str | int | float, optional
            The date and time you retrieve the historical transactions to, excluding
            this date-time.
            Corresponds to the created_at value of the transaction.
            Provided in ISO 8601 format.
            The default value is the date and time at which you're calling the endpoint.

            Used also for pagination.
            To get the next page of results, make a new request and use the created_at
            date from the last item of the previous (current) page as the value for the
            to parameter.
        account_id : UUID, optional
            The ID of the account for which you want to retrieve the transactions.
        limit : int, optional
            The maximum number of transactions returned per page.
            To get the next page of results, make a new request and use the created_at
            date from the last item of the previous page as the value for the to parameter.
        transaction_type : EnumTransactionType, optional
            The type of the transaction.

        Returns
        -------
        list[dict] | list[RetrieveListOfTransactions.Response]
            A list of transactions.
        """
        endpoint = RetrieveListOfTransactions
        path = endpoint.ROUTE
        params = endpoint.Params(
            from_=from_datetime,
            to=to_datetime,
            account=account_id,
            count=limit,
            type=transaction_type,
        )

        return await self.client.get(
            path=path,
            response_model=endpoint.Response,
            params=params,
            **kwargs,
        )

    async def get_transaction(
        self,
        transaction_id: UUID | None = None,
        request_id: str | None = None,
        **kwargs,
    ) -> dict | RetrieveTransaction.Response:
        """
        Retrieve the details of a specific transaction.
        The details can include, for example, cardholder details for card payments.

        You can retrieve a transaction with its details either by its transaction ID
        or by the request ID that was provided for this transaction at the time of its
        creation, for example, when you created a payment.

        To retrieve a transaction by its transaction ID, use:

            /transaction/{transaction_id}

        To retrieve a transaction by a request ID provided at transaction creation, use:

            /transaction/{request_id}?id_type=request_id

        Parameters
        ----------
        transaction_id : UUID, optional
            The ID of the transaction.
            Specify either transaction_id or request_id.
        request_id : str, optional
            The request ID of the transaction.
            Specify either transaction_id or request_id.

        Returns
        -------
        dict | RetrieveTransaction.Response
            The details of the transaction.
        """
        assert (
            transaction_id or request_id
        ), "Either transaction_id or request_id must be provided."
        assert not (
            transaction_id and request_id
        ), "Either transaction_id or request_id must be provided, not both."

        endpoint = RetrieveTransaction
        path = endpoint.ROUTE.format(id=transaction_id or request_id)
        params = endpoint.Params(id_type="request_id" if request_id else None)

        return await self.client.get(
            path=path,
            response_model=endpoint.Response,
            params=params,
            **kwargs,
        )

get_all_transactions(from_datetime=None, to_datetime=None, account_id=None, limit=None, transaction_type=None, **kwargs) async

Retrieve the historical transactions based on the provided query criteria.

The transactions are sorted by the created_at date in reverse chronological order, and they're paginated. The maximum number of transactions returned per page is specified by the count parameter. To get the next page of results, make a new request and use the created_at date from the last item of the previous page as the value for the to parameter.

Note

The API returns a maximum of 1,000 transactions per request.

Note

To be compliant with PSD2 SCA regulations, businesses on the Revolut Business Freelancer plans can only access information older than 90 days within 5 minutes of the first authorisation.

Parameters:

Name Type Description Default
from_datetime datetime | DateTime | str | int | float

The date and time you retrieve the historical transactions from, including this date-time. Corresponds to the created_at value of the transaction. Provided in ISO 8601 format.

Used also for pagination. To get back to the previous page of results, make a new request and use the created_at date from the first item of the current page as the value for the from parameter.

None
to_datetime datetime | DateTime | str | int | float

The date and time you retrieve the historical transactions to, excluding this date-time. Corresponds to the created_at value of the transaction. Provided in ISO 8601 format. The default value is the date and time at which you're calling the endpoint.

Used also for pagination. To get the next page of results, make a new request and use the created_at date from the last item of the previous (current) page as the value for the to parameter.

None
account_id UUID

The ID of the account for which you want to retrieve the transactions.

None
limit int

The maximum number of transactions returned per page. To get the next page of results, make a new request and use the created_at date from the last item of the previous page as the value for the to parameter.

None
transaction_type EnumTransactionType

The type of the transaction.

None

Returns:

Type Description
list[dict] | list[Response]

A list of transactions.

Source code in pyrevolut/api/transactions/endpoint/asynchronous.py
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
async def get_all_transactions(
    self,
    from_datetime: datetime | DateTime | str | int | float | None = None,
    to_datetime: datetime | DateTime | str | int | float | None = None,
    account_id: UUID | None = None,
    limit: int | None = None,
    transaction_type: EnumTransactionType | None = None,
    **kwargs,
) -> list[dict] | list[RetrieveListOfTransactions.Response]:
    """
    Retrieve the historical transactions based on the provided query criteria.

    The transactions are sorted by the created_at date in reverse chronological order,
    and they're paginated. The maximum number of transactions returned per page is specified by the
    count parameter. To get the next page of results, make a new request and use the created_at date
    from the last item of the previous page as the value for the to parameter.

    Note
    ----
    The API returns a maximum of 1,000 transactions per request.

    Note
    ----
    To be compliant with PSD2 SCA regulations, businesses on the Revolut Business Freelancer
    plans can only access information older than 90 days within 5 minutes of the first authorisation.

    Parameters
    ----------
    from_datetime : datetime | DateTime | str | int | float, optional
        The date and time you retrieve the historical transactions from, including
        this date-time.
        Corresponds to the created_at value of the transaction.
        Provided in ISO 8601 format.

        Used also for pagination. To get back to the previous page of results,
        make a new request and use the created_at date from the first item of the
        current page as the value for the from parameter.
    to_datetime : datetime | DateTime | str | int | float, optional
        The date and time you retrieve the historical transactions to, excluding
        this date-time.
        Corresponds to the created_at value of the transaction.
        Provided in ISO 8601 format.
        The default value is the date and time at which you're calling the endpoint.

        Used also for pagination.
        To get the next page of results, make a new request and use the created_at
        date from the last item of the previous (current) page as the value for the
        to parameter.
    account_id : UUID, optional
        The ID of the account for which you want to retrieve the transactions.
    limit : int, optional
        The maximum number of transactions returned per page.
        To get the next page of results, make a new request and use the created_at
        date from the last item of the previous page as the value for the to parameter.
    transaction_type : EnumTransactionType, optional
        The type of the transaction.

    Returns
    -------
    list[dict] | list[RetrieveListOfTransactions.Response]
        A list of transactions.
    """
    endpoint = RetrieveListOfTransactions
    path = endpoint.ROUTE
    params = endpoint.Params(
        from_=from_datetime,
        to=to_datetime,
        account=account_id,
        count=limit,
        type=transaction_type,
    )

    return await self.client.get(
        path=path,
        response_model=endpoint.Response,
        params=params,
        **kwargs,
    )

get_transaction(transaction_id=None, request_id=None, **kwargs) async

Retrieve the details of a specific transaction. The details can include, for example, cardholder details for card payments.

You can retrieve a transaction with its details either by its transaction ID or by the request ID that was provided for this transaction at the time of its creation, for example, when you created a payment.

To retrieve a transaction by its transaction ID, use:

/transaction/{transaction_id}

To retrieve a transaction by a request ID provided at transaction creation, use:

/transaction/{request_id}?id_type=request_id

Parameters:

Name Type Description Default
transaction_id UUID

The ID of the transaction. Specify either transaction_id or request_id.

None
request_id str

The request ID of the transaction. Specify either transaction_id or request_id.

None

Returns:

Type Description
dict | Response

The details of the transaction.

Source code in pyrevolut/api/transactions/endpoint/asynchronous.py
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
async def get_transaction(
    self,
    transaction_id: UUID | None = None,
    request_id: str | None = None,
    **kwargs,
) -> dict | RetrieveTransaction.Response:
    """
    Retrieve the details of a specific transaction.
    The details can include, for example, cardholder details for card payments.

    You can retrieve a transaction with its details either by its transaction ID
    or by the request ID that was provided for this transaction at the time of its
    creation, for example, when you created a payment.

    To retrieve a transaction by its transaction ID, use:

        /transaction/{transaction_id}

    To retrieve a transaction by a request ID provided at transaction creation, use:

        /transaction/{request_id}?id_type=request_id

    Parameters
    ----------
    transaction_id : UUID, optional
        The ID of the transaction.
        Specify either transaction_id or request_id.
    request_id : str, optional
        The request ID of the transaction.
        Specify either transaction_id or request_id.

    Returns
    -------
    dict | RetrieveTransaction.Response
        The details of the transaction.
    """
    assert (
        transaction_id or request_id
    ), "Either transaction_id or request_id must be provided."
    assert not (
        transaction_id and request_id
    ), "Either transaction_id or request_id must be provided, not both."

    endpoint = RetrieveTransaction
    path = endpoint.ROUTE.format(id=transaction_id or request_id)
    params = endpoint.Params(id_type="request_id" if request_id else None)

    return await self.client.get(
        path=path,
        response_model=endpoint.Response,
        params=params,
        **kwargs,
    )