Saltar al contenido principal

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.

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)
}
})()

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

ParameterDescriptionTypeRequiredExample
account_idThe ID of the accountuuidTrue054d0a9d-38ec-40cb-a31c-09b483242e4a

Payload

ParameterDescriptionTypeRequiredExample
start_dateThe latest date for which data should be returned. Dates should be formatted as YYYY-MM-DDstringTrue2022-01-01
end_dateThe earliest date for which data should be returned. Dates should be formatted as YYYY-MM-DDstringTrue2021-01-01
optionsAn optional object to be used with the requestobjFalse{ items_per_page: 10, page: 1 }

Options payload

ParameterDescriptionTypeMaximum
items_per_pageThe number of earnings to fetch. The default value is 100.int150
pageThe page to retrieve with length items_per_pageint