# Calculating the AQI from the API results

**URL:** <https://community.purpleair.com/t/calculating-the-aqi-from-the-api-results/1241>\
**Category:** API\
**Created:** [July 13, 2022, 9:52pm UTC](https://community.purpleair.com/t/calculating-the-aqi-from-the-api-results/1241 "2022-07-13T21:52:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndyB](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@AndyB](https://community.purpleair.com/u/AndyB)\
**Post date:** [July 13, 2022, 9:52pm UTC](https://community.purpleair.com/t/calculating-the-aqi-from-the-api-results/1241/1 "2022-07-13T21:52:04Z")

</div>

I use PHP. Does anyone have the code needed to calculate the AQI from the results obtained from the API? I would like to match the same number as shown when viewing the [purpleair.com](http://purpleair.com) map.

Thank you.

---

<div class="post-metadata">

**Author:** ![Ethan](https://sea2.discourse-cdn.com/flex020/user_avatar/community.purpleair.com/ethan/32/177_2.png) [@Ethan](https://community.purpleair.com/u/Ethan)\
**Post date:** [July 14, 2022, 3:48pm UTC](https://community.purpleair.com/t/calculating-the-aqi-from-the-api-results/1241/2 "2022-07-14T15:48:23Z")

</div>

Hi @AndyB, we have a post about this which you can read here: [How to Calculate the US EPA PM2.5 AQI](https://community.purpleair.com/t/how-to-calculate-the-us-epa-pm2-5-aqi/877). It is written in JavaScript, but the equation will be the same.
