Retrieve Earnings - POST
To get the Earnings corresponding to a user's account, you need to make a POST
request to the endpoint
POST https://api.palenca.com/v1/accounts/:account_id/earnings/search
Earnings data is standardized across gig platforms, the data is returned in reverse-chronological order.
Results are paginated due to the large number of earnings associated with an account, manipulate the items_per_page
and page
parameters in conjunction with the total_items
response body field to fetch all available earnings.
- JavaScript
- Python
- curl
const axios = require('axios')
const data = JSON.stringify({
"start_date": "2022-12-31",
"end_date": "2022-01-01",
"options": {
"items_per_page": 50,
"page": 1
}
});
const config = {
method: 'post',
url: 'https://api.palenca.com/v1/accounts/:account_id/earnings/search',
headers: {
'x-api-key': 'private_api_key',
'Content-Type': 'application/json'
},
data: data
};
(async () => {
try {
const {data} = await axios(config)
console.info(JSON.stringify(response.data))
} catch (error) {
console.error(error)
}
})()
import requests
url = 'https://api.palenca.com/v1/accounts/:account_id/earnings/search'
payload = {
"start_date": "2022-12-31",
"end_date": "2022-01-01",
"options": {
"items_per_page": 50,
"page": 1
}
}
headers = {
'x-api-key': 'private_api_key',
'Content-Type': 'application/json'
}
response = requests.request('POST', url, headers=headers, json=payload)
curl --location --request POST 'https://api.palenca.com/v1/accounts/:account_id/earnings/search'
--header 'x-api-key: private_api_key' \
--header 'Content-Type: application/json' \
--data-raw '{
"start_date": "2022-12-31",
"end_date": "2022-01-01",
"options": {
"items_per_page": 50,
"page": 1
}
}'
Returns a JSON structured like this:
{
"success": true,
"error": null,
"data": {
"account_id": "c1f8ae4b-ee24-4478-a9be-5f25d7d65b75",
"earnings": [
{
"amount":109.0,
"currency":"MXN",
"earnings_date":"2021-10-01",
"cash_amount": null,
"count_trips": null
},
{
"amount":108.0,
"currency":"MXN",
"earning_date":"2021-09-01",
"cash_amount": null,
"count_trips": null
},
{
"amount":107.0,
"currency":"MXN",
"earning_date":"2021-08-01",
"cash_amount": null,
"count_trips": null
},
...
],
},
"pagination": {
"page": 1,
"items_per_page": 50,
"total_items": 200,
"total_pages": 4
}
}
Query params
Parameter | Description | Type | Required | Example |
---|---|---|---|---|
account_id | The ID of the account | uuid | True | 054d0a9d-38ec-40cb-a31c-09b483242e4a |
Payload
Parameter | Description | Type | Required | Example |
---|---|---|---|---|
start_date | The latest date for which data should be returned. Dates should be formatted as YYYY-MM-DD | string | True | 2022-01-01 |
end_date | The earliest date for which data should be returned. Dates should be formatted as YYYY-MM-DD | string | True | 2021-01-01 |
options | An optional object to be used with the request | obj | False | { items_per_page: 10, page: 1 } |
Options payload
Parameter | Description | Type | Maximum |
---|---|---|---|
items_per_page | The number of earnings to fetch. The default value is 100. | int | 150 |
page | The page to retrieve with length items_per_page | int |