Creating API Keys

This article is related to the PurpleAir API. If you are unfamiliar with it, check out our API Landing Page to get started.

This article will go over how to create API keys and navigate the API portal.

You will need a Google account to sign in (doesn’t need to be an “@gmail.com” email address). You can learn more here: Sign in to your Google Account with another email address – Google Account Help

If you want to use the PurpleAir API, you can create your own API keys here: https://develop.purpleair.com/dashboards/keys.

Please review our article about the API Online Dashboard.


Create API Keys

  • After signing in, click “API Keys” on the top bar.
     
    Screenshot 2024-04-01 at 4.14.42 PM
     
  • Then click the “+ API Key” button in the top right corner of the screen.
     
    Screenshot 2024-04-01 at 4.21.42 PM
     
  • You will see an auto-populated project name, which you can rename anytime. You can have several projects and API keys. If you already have multiple projects, be sure to select the appropriate project.
  • Select “Read” for the “Type,” select “Enabled” under “Status,” and leave the fields “Label,” “Host restrictions,” and “Referer restrictions” blank.
     
    Screenshot 2024-04-01 at 4.18.15 PM
     
  • Click “Create.”
  • To create a “Write” key, repeat the process but select “Write” under “Type.”

When creating a new key, you will have the option to create a “Read” or “Write” key. Typically, a Read key will be used to pull data and a Write key will be used to update information on the API, such as creating a group.


Manage Projects

  • On the top bar, click on “Projects.” Here you can edit and add projects, view each project’s usage, and archive projects.
  • To add a project, click “+ Project” in the top right-hand corner of the page. Choose a project name, and click “Create.”
  • To edit a project name, click the three dots to the right of the project name and select “Edit Project.”
  • To archive a project, do the same as above and select “archive.”
  • To check usage, click on the project name.
     


Manage Users

  • Select “Users” on the top bar. Here you can edit the name of a user.

Manage Organizations

  • Select “Organization” on the top bar. Here you can edit the organization’s name and view the organization’s usage.
  • The “Purchase Points” button will allow you to add points to your account. Points are used to make API calls.

Learn More

PurpleAir API
API Use Guidelines
Making calls with the PurpleAir API

1 Like

My website’s name is www dot softwarejim dot com, so for Host Restriction that is what I typed in. My website is hosted on Hostinger dot com, so I tried that as well when softwarejim dot com did not work. Hostinger dot com also did not work. The error description that I got from using the API is “The provided API key is restricted to certain hosts. Neither ‘https://www.softwarejim.com/’, ‘2601:18f:101:b590:f41f:2680:d18d:7074’ or ‘2601:18f:101:b590:f41f:2680:d18d:7074’ have access.”

I’m wondering what I’m doing wrong? I also tried just “softwarejim dot com”

I just realized the issue. The JavaScript runs locally on the person’s system, so their system (ip address) is the one being sent.

If I want to restrict it to softwarejim.com, then I should use a CGI script that runs on the server instead of JavaScript that runs on the user’s system.