Get all purchases

All purchases can be retrieved in the Neon dashboard, via the transactions page. Alternatively, you can use the Purchases API to get all available purchases and paginate data the way you need to.

To do this, you can call GET /purchases any desired filter and specifying the amount of records you want to retrieve (ranging from 1-100 and defaulted to 10 if not present in the request):

curl --request GET \
     --url 'https://api.neonpay.com/purchases?limit=10' \
     --header 'X-API-KEY: <your API key>' \
     --header 'accept: application/json'

The available filters are startDate, endDate, startingAfterand endingBefore. Which you can use to filter either by date range, or using an object ID to define pagination.

Filtering by dates would require to pass in startDateand/or endDateto define a valid date range. Please note that startDateis an inclusive date, and endDateis exclusive. If no endDateis defined, it'll always be defaulted to the actual date:

curl --request GET \
     --url 'https://api.neonpay.com/purchases?startDate=<date>&endDate=<date>' \
     --header 'X-API-KEY: <your API key>' \
     --header 'accept: application/json'

Finally, you can filter using an object ID that defines your place in the list, if multiple pages were found. For instance, if you make a request and receive 10 objects, ending with obj_foo, your subsequent call can include startingAfter=obj_foo in order to fetch the next page of the list starting off the specified ID. Same thing if you want to retrieve the previous page, you can do this by passing endgingBefore=obj_foogiven that obj_foowill be the starting ID of the list:

curl --request GET \
     --url 'https://api.neonpay.com/purchases?startingAfter=<UUID>' \
     --header 'X-API-KEY: <your API key>' \
     --header 'accept: application/json'

Or:

curl --request GET \
     --url 'https://api.neonpay.com/purchases?endingBefore=<UUID>' \
     --header 'X-API-KEY: <your API key>' \
     --header 'accept: application/json'

Note that if you pass in both startingAfterand endingBeforesimultaneously, startingAfterwill take precedence and will be the only filter applied. You can still mix date range filters with either startingAfteror endingBefore.