Transaction Search API
Transaction Search API
Use the Transaction Search API to get the history of transactions for a PayPal account. To use the API on behalf of third parties, you must be part of the PayPal partner network. Reach out to your partner manager for the next steps. To enroll in the partner program, see Partner with PayPal. For more information about the API, see the Transaction Search API Integration Guide.
Note
Note: To use the API on behalf of third parties, you must be part of the PayPal partner network. Reach out to your partner manager for the next steps. To enroll in the partner program, see Partner with PayPal.
- class python_paypal_api.api.Transactions(*args, **kwargs)
Use the /transactions resource to list transactions.
- get_list_transactions(self, **kwargs) ApiResponse
GET /v1/reporting/transactions
Lists transactions. Specify one or more query parameters to filter the transaction that appear in the response.
Note
If you specify one or more optional query parameters, the ending_balance response field is empty.
It takes a maximum of three hours for executed transactions to appear in the list transactions call.
This call lists transaction for the previous three years.
**kwargs:
payment_instrument_type stringFilters the transactions in the response by a payment instrument type. Value is either:CREDITCARD
. Returns a direct credit card transaction with a corresponding value.DEBITCARD
. Returns a debit card transaction with a corresponding value.
If you omit this parameter, the API does not apply this filter.end_date string requiredFilters the transactions in the response by an end date and time, in Internet date and time format. Seconds are required. Fractional seconds are optional. The maximum supported range is 31 days.20
.64
.^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])[T,t]([0-1][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)([.][0-9]+)?([Zz]|[+-][0-9]{2}:[0-9]{2})$
.start_date string requiredFilters the transactions in the response by a start date and time, in Internet date and time format. Seconds are required. Fractional seconds are optional.20
.64
.^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])[T,t]([0-1][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)([.][0-9]+)?([Zz]|[+-][0-9]{2}:[0-9]{2})$
.balance_affecting_records_only stringIndicates whether the response includes only balance-impacting transactions or all transactions.Value is either:Y
. The default. The response includes only balance transactions.N
. The response includes all transactions.
fields stringIndicates which fields appear in the response. Value is a single field or a comma-separated list of fields. Thetransaction_info
value returns only the transaction details in the response. To include all fields in the response, specifyfields=all
. Valid fields are:transaction_info
. The transaction information. Includes the ID of the PayPal account of the payee, the PayPal-generated transaction ID, the PayPal-generated base ID, the PayPal reference ID type, the transaction event code, the date and time when the transaction was initiated and was last updated, the transaction amounts including the PayPal fee, any discounts, insurance, the transaction status, and other information about the transaction.payer_info
. The payer information. Includes the PayPal customer account ID and the payer’s email address, primary phone number, name, country code, address, and whether the payer is verified or unverified.shipping_info
. The shipping information. Includes the recipient’s name, the shipping method for this order, the shipping address for this order, and the secondary address associated with this order.auction_info
. The auction information. Includes the name of the auction site, the auction site URL, the ID of the customer who makes the purchase in the auction, and the date and time when the auction closes.cart_info
. The cart information. Includes an array of item details, whether the item amount or the shipping amount already includes tax, and the ID of the invoice for PayPal-generated invoices.incentive_info
. An array of incentive detail objects. Each object includes the incentive, such as a special offer or coupon, the incentive amount, and the incentive program code that identifies a merchant loyalty or incentive program.store_info
. The store information. Includes the ID of the merchant store and the terminal ID for the checkout stand in the merchant store.
page integerThe zero-relative start index of the entire list of items that are returned in the response. So, the combination ofpage=1
andpage_size=20
returns the first 20 items.1
.2147483647
.page_size integerThe number of items to return in the response. So, the combination ofpage=1
andpage_size=20
returns the first 20 items. The combination ofpage=2
andpage_size=20
returns the next 20 items.1
.500
.store_id stringFilters the transactions in the response by a store ID.terminal_id stringFilters the transactions in the response by a terminal ID.transaction_amount stringFilters the transactions in the response by a gross transaction amount range. Specify the range as<start-range> TO <end-range>
, where<start-range>
is the lower limit of the gross PayPal transaction amount and<end-range>
is the upper limit of the gross transaction amount. Specify the amounts in lower denominations. For example, to search for transactions from $5.00 to $10.05, specify[500 TO 1005]
.Note
The values must be URL encoded.
transaction_currency stringFilters the transactions in the response by a three-character ISO-4217 currency code for the PayPal transaction currency.transaction_id stringFilters the transactions in the response by a PayPal transaction ID. A valid transaction ID is 17 characters long, except for an order ID, which is 19 characters long.Note
A transaction ID is not unique in the reporting system. The response can list two transactions with the same ID. One transaction can be balance affecting while the other is non-balance affecting.
17
.19
.transaction_status stringFilters the transactions in the response by a PayPal transaction status code. Value is:Status code
Description
D
PayPal or merchant rules denied the transaction.
P
The transaction is pending. The transaction was created but waits for another payment process to complete, such as an ACH transaction, before the status changes to
S
.S
The transaction successfully completed without a denial and after any pending statuses.
V
A successful transaction was reversed and funds were refunded to the original sender.
transaction_type stringFilters the transactions in the response by a PayPal transaction event code. See Transaction event codes.- Returns:
ApiResponse
### Example python
from python_paypal_api.api import Transactions from python_paypal_api.base import PaypalApiException import logging from datetime import datetime, timezone def py_get_list_transactions(**kwargs): logger.info("---------------------------------") logger.info("Transactions > py_get_list_transactions({})".format(kwargs)) logger.info("---------------------------------") try: result = Transactions(debug=True).get_list_transactions( **kwargs ) logger.info(result) except PaypalApiException as error: logger.error(error) if __name__ == '__main__': logger = logging.getLogger("test") date_start = datetime(2023, 2, 1, 0, 0, 0, 0, timezone.utc).isoformat() date_end = datetime(2023, 3, 1, 0, 0, 0, 0, timezone.utc).isoformat() py_get_list_transactions( page_size=1, start_date=date_start, end_date=date_end )
### Response JSON
A successful request returns the HTTP 200 OK status code and a JSON response body that lists transactions.
{ 'account_number': '2LBUCGLCSB***', 'end_date': '2023-03-01T00:00:00+0000', 'last_refreshed_datetime': '2023-03-12T01:59:59+0000', 'links': [ { 'href': 'https://api.sandbox.paypal.com/v1/reporting/transactions?start_date=2023-02-01T00%3A00%3A00%2B00%3A00&end_date=2023-03-01T00%3A00%3A00%2B00%3A00&page_size=1&page=19', 'method': 'GET', 'rel': 'last' }, { 'href': 'https://api.sandbox.paypal.com/v1/reporting/transactions?start_date=2023-02-01T00%3A00%3A00%2B00%3A00&end_date=2023-03-01T00%3A00%3A00%2B00%3A00&page_size=1&page=2', 'method': 'GET', 'rel': 'next' }, { 'href': 'https://api.sandbox.paypal.com/v1/reporting/transactions?start_date=2023-02-01T00%3A00%3A00%2B00%3A00&end_date=2023-03-01T00%3A00%3A00%2B00%3A00&page_size=1&page=1', 'method': 'GET', 'rel': 'self' } ], 'page': 1, 'start_date': '2023-02-01T00:00:00+0000', 'total_items': 19, 'total_pages': 19, 'transaction_details': [ { 'transaction_info': { 'available_balance': { 'currency_code': 'EUR', 'value': '165488.69' }, 'custom_field': 'S1121674440646-1563665460', 'ending_balance': { 'currency_code': 'EUR', 'value': '165488.69' }, 'paypal_account_id': 'UYZPMCTQDV***', 'paypal_reference_id': '4G8384171L5786***', 'paypal_reference_id_type': 'TXN', 'protection_eligibility': '02', 'transaction_amount': { 'currency_code': 'EUR', 'value': '-50.00' }, 'transaction_event_code': 'T1110', 'transaction_id': '18670957S08679***', 'transaction_initiation_date': '2023-02-12T11:52:33+0000', 'transaction_status': 'P', 'transaction_updated_date': '2023-02-12T11:52:33+0000' } } ] }
- get_balances(self, **kwargs) ApiResponse
GET /v1/reporting/balances
List all balances. Specify date time to list balances for that time that appear in the response.
Note
It takes a maximum of three hours for balances to appear in the list balances call.
This call lists balances upto the previous three years.
**kwargs:
as_of_time stringList balances in the response at the date time provided, will return the last refreshed balance in the system when not provided.20
.64
.^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])[T,t]([0-1][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)([.][0-9]+)?([Zz]|[+-][0-9]{2}:[0-9]{2})$
.currency_code stringFilters the transactions in the response by a three-character ISO-4217 currency code for the PayPal transaction currency.3
.3
.### Example python
from python_paypal_api.api import Transactions from python_paypal_api.base import PaypalApiException import logging from datetime import datetime, timezone def py_get_balances(**kwargs): logger.info("---------------------------------") logger.info("Transactions > py_get_balances({})".format(kwargs))) logger.info("---------------------------------") try: result = Transactions(debug=True).get_balances( **kwargs ) logger.info(result) except PaypalApiException as error: logger.error(error) if __name__ == '__main__': logger = logging.getLogger("test") date_start = datetime(2023, 2, 1, 0, 0, 0, 0, timezone.utc).isoformat() py_get_balances( as_of_time=date_start, currency_code="USD" )
### Response JSON
A successful request returns the HTTP 200 OK status code and a JSON response body that lists balances.
{ 'account_id': '2LBUCGLCSB***', 'as_of_time': '2023-03-12T01:59:59Z', 'balances': [ { 'available_balance': { 'currency_code': 'USD', 'value': '1304.05' }, 'currency': 'USD', 'total_balance': { 'currency_code': 'USD', 'value': '1304.05' }, 'withheld_balance': { 'currency_code': 'USD', 'value': '0.00' } } ], 'last_refresh_time': '2023-03-12T01:59:59Z' }