from coinbase.wallet.client import Client
client = Client(<api_key>, <api_secret>)
number_of_transactions = 5
txs = client.get_transactions(‘45b6794c-xxxx-5bxx-9155-3b47326s8dde’, number_of_transactions)
How can I just pull the latest 5 transactions from this api?
is there a way to filter the transactions also? for example only return buy and sells?
Hello @firlas! Thank you for taking an interest in trying out Coinbase APIs. For the details regarding your concern, we will check on this for you with our team. We will get back to you once we have more information. Keep in touch!
Hello, @firlas! Welcome to the Developer’s Forum! We appreciate your enthusiasm in using our Coinbase Cloud services and we’d be glad to assist you with your concern. First, we want to inform you that we moved your post to Sign In With Coinbase category, since it is the right category for your concern.
With regard to your first question on how to pull the latest 5 transactions from the transactions endpoint, we want to recommend utilizing the pagination . The transactions endpoint returns 25 results because all Sign in with Coinbase GET endpoints which return an object list support cursor based pagination, with pagination information inside a pagination object has a default limit of 25 results per request, but up to 100 are permitted. Since you want to pull only the last 5 transactions in your request, you can specify the limit argument by 5 . You can check this for fetching the first 5 transactions for reference:
Additionally, You may look for more in-depth information about this topic which you may access through this link.
Regarding your second post asking if it is possible to filter the type of transaction when utilizing the transactions endpoint to buy and sell only, the answer is no. The transactions endpoint outputs the overall list of all the Transaction types currently available in the documentation. But you can utilize the list buys and list sells endpoint. These endpoints will list the buys and sells for an account.
We hope this helps. Please feel free to reply back to this thread if you need further assistance.
Thank you for your response, Mamoshi. So in my python code it would look like this:
txs = client.get_transactions("xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx", limit=5)
Hi @firlas! Thanks for letting us know this all worked out.
Have a great day!