List Transactions

Learn how to retrieve information about transactions.

Overview

In this lesson, we’ll learn how to get a list of all transactions as well as how to get the details of a specific transaction.

Endpoints

Get all transactions

We can get a list of all transactions by making a GET request to the {BASE_URL}/transactions endpoint. This endpoint allows us to filter the visibility of the response fields, if necessary. This endpoint also supports pagination, which allows us to retrieve a specific range of resources from a complete and sorted list of the returned resources.

Note: This endpoint only retrieves transactions that have either a “PENDING” or “COMPLETION” status. It also only provides transactions conducted within the last 30 days. In case we want to retrieve transactions conducted outside this period, we must specify the optional query parameters, start_date and end_date.

Get transaction details

We can get details of a single transaction by making a GET request to the {BASE_URL}/transactions/{token} endpoint. The path parameter, {token}, refers to the token of the transaction that we want to retrieve. This endpoint allows us to filter the visibility of the response fields, if necessary.

Note: This endpoint doesn’t provide transactions in real-time. A transaction can take anywhere between 30 seconds and 4 hours to appear.

Request parameters

Parameter

Type

Category

Description

token

string

required

Token of the transaction we want to retrieve

Note: This is a path parameter to get a single transaction.

count


integer

optional

Number of transactions to retrieve

Allowable values: 1–10

Note: This is a query parameter to get all transactions.

fields

string

optional

Comma-separated list of fields we want to retrieve

Note: This is a query parameter. All fields will be returned if this parameter is not supplied with a value.

sort_by

string

optional

Sorts and filters by the given value

Note: By default, the sorting is done in ascending order. To sort in descending order, add a hyphen (-) to the field name. This is a query parameter to get all transactions.

start_index

integer

optional

Sort order index of the first object in the array of returned resources

Note: This is a query parameter to get all transactions.

start_date


string

optional

Start date and time to filter transactions

Format: yyyy-MM-dd or yyyy-MM-ddTHH:mm:ss.SS

Note: This is a query parameter to get all transactions.

end_date

string

optional

End date and time to filter transactions

Format: yyyy-MM-dd or yyyy-MM-ddTHH:mm:ss.SS

Note: This is a query parameter to get all transactions.

type

string

optional

Comma-separated list of transaction types we want to retrieve

Note: All transaction types are returned if this parameter is not supplied. This is a query parameter to get all transactions.

user_token

string

optional

Unique token of the user

Note: This is a query parameter to get all transactions.

business_token

string

optional

Unique token of the business

Note: This is a query parameter to get all transactions.

acting_user_token

string

optional

Unique token of the acting user.

Note: This is a query parameter to get all transactions. It’s the same as the user_token in this case.

card_token

string

optional

Unique token of the card

Note: This is a query parameter to get all transactions.

state

string

optional

Comma-separated list of transaction statuses we want to retrieve

Allowable values: PENDING, CLEARED, COMPLETION, DECLINED, ERROR, ALL

Note: This is a query parameter to get all transactions.

version

string

optional

Version of the API used for the request

Allowable values: v1, v2, v3

Note: This is a query parameter.

verbose


boolean

optional

True to return additional information for diagnostic purposes, otherwise False

Note: This is a query parameter.

You may append any of the optional query parameters given in the table above to the url in line 1 to fine-tune your search. Please refer to this course’s appendix for a list of transaction types.

Click the “Run” button in the code widget below to get a list of all transactions.

Sample codes

Press + to interact
url = '{{BASE_URL}}transactions'
response = requests.get(url, headers=headers)
printResponse(response)

Line 1: We have the value for token, which is a required path parameter. We stored this value in the previous lesson.

Note: You can change it to get any transaction of your choice. You can also append any of the optional query parameters given in the table above to the url in line 3 to fine-tune your search.

Click the “Run” button in the code widget below to see the output.

Press + to interact
token = '{{TRANSACTION_TOKEN}}'
url = '{{BASE_URL}}transactions/' + token
response = requests.get(url, headers=headers)
printResponse(response)

Output

When the code is executed successfully, the output of the first block of code displays the requested number of transactions with all of the requested data fields. It also displays the total amount as well as other information.

For the second block of code, the output displays the complete transaction object that corresponds to the given token with all of the requested data fields.

In case of failure, an appropriate error message is displayed.