Skip navigation

Using Postman and the API to Estimated and Actual time per Project

A customer that uses Postman and the Intervals API asked how to:

1) List clients
2) List projects per client
3) Extract a measure of estimate verses actual hours per project.

They were able to complete steps 1 and 2 and retrieve estimated hours but weren’t sure how to get the actuals. We walked them through it, and decided to share the process.

To get estimated hours

Use the projectworktype endpoint with the projectid:

https://api.myintervals.com/projectworktype/?projectid=XXXX

Then sum all of the “esttime” values returned. If you are billing for your time you will have exclude unbillable time entries (billable=t only)

To get actual hours

Use the time endpoint with the projectid:

https://api.myintervals.com/time/?projectid=XXXX

Then sum all of the “time” values.

Here’s some code to add up all of the time entries. Place it in the tests tab and enable the console window. When running the query it should display the totals in the log:

let body = JSON.parse(responseBody)
let entries = _.map(body.time, (entry) => entry.time);
function sumEntries(total, num) {
return parseFloat(total) + parseFloat(num)
}

console.log('total', entries.reduce(sumEntries));

For summing up estimates you can run:

let body = JSON.parse(responseBody)
let entries = _.map(body.projectworktype, (entry) => entry.esttime);
function sumEntries(total, num) {
return parseFloat(total) + parseFloat(num)
}

console.log('total', entries.reduce(sumEntries));

If you run into any trouble or have questions about the API, please contact our support team. We are happy to help.

| Updated

Don't have an Intervals account? Start your own unlimited trial.

No credit card required. No software to install. Cancel any time.

Try it Free