'Fetching 1000s of employees with BambooHR API
Summary
The BambooHR API documentation makes no mention of pagination. It's difficult to test with 1000s of records. How can this endpoint be used to fetch 1000s of records? Typically, APIs would return a page number but I don't seem to see one here.
Is there a recommended procedure to handle this to ensure stability?
Sample code
// Endpoint to fetch employee info from
const url = `https://api.bamboohr.com/api/gateway.php/example_subdomain/v1/reports/custom`;
const auth =
"Basic " +
Buffer.from("example_auth:x", "utf-8").toString("base64");
const postRes = await Axios.post(url, {
fields: [
"firstName",
{
headers: {
Accept: "application/json",
Authorization: auth,
},
},
],
});
// Get list of returned employees. How reliable is list here??
const employees = postRes.data.employees || [];
https://documentation.bamboohr.com/reference/request-custom-report-1
Solution 1:[1]
I can't speak specifically for Bamboo, and 'ensure stability' isn't qualified too well... but if each user record is about (for example) 1KB, at a 1000 records that's 1MB. A big string, but should not be an issue for most programming languages or a single HTTP request.
If you're worried about something, why don't you mock the response, increase the number to 10,000 users and keep increasing until you see a problem.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Evert |