Authentication overview

BreezoMeter Pollen, part of the broader BreezoMeter environmental data platform, employs API key authentication to secure access to its various data endpoints. This method is standard for many web APIs, providing a straightforward way for applications to identify themselves and gain authorized access to resources. When a developer registers for a BreezoMeter account, a unique API key is generated and assigned. This key serves as the primary credential for all API interactions, ensuring that requests originate from a legitimate source and adhere to usage policies, such as rate limits and subscription tiers.

The API key functions as a token that clients include in their requests, typically as a query parameter or an HTTP header. BreezoMeter's servers then validate this key against their records. A valid key grants access to the requested data, while an invalid or missing key results in an authentication failure, preventing unauthorized data retrieval. This mechanism is crucial for maintaining the integrity and security of the BreezoMeter Pollen API, protecting both the data provider and the API consumers from misuse.

For detailed information on specific API endpoints and their expected parameters, developers should consult the official BreezoMeter API Reference documentation.

Supported authentication methods

BreezoMeter Pollen primarily supports API key authentication. This method is widely adopted for its simplicity and effectiveness in managing access to web services. While other authentication schemes like OAuth 2.0 or mutual TLS exist, BreezoMeter's focus on API keys streamlines the integration process for developers seeking to access pollen and air quality data.

The following table outlines the key characteristics of BreezoMeter's primary authentication method:

Method When to Use Security Level
API Key All API requests to access BreezoMeter Pollen and other BreezoMeter APIs. Suitable for server-side applications, mobile apps, and single-page applications where the key can be securely stored or proxied. Moderate. Relies on the secrecy of the key. Requires HTTPS for secure transmission. Susceptible to leakage if not handled carefully.

API keys are typically long, alphanumeric strings. Their security depends heavily on how they are stored and transmitted. BreezoMeter mandates the use of HTTPS for all API communications, which encrypts data in transit, protecting the API key from interception during transmission. For a broader understanding of API key security, the Google Cloud API keys documentation provides general best practices.

Getting your credentials

To obtain an API key for BreezoMeter Pollen, developers must first register for a BreezoMeter account. The process typically involves signing up on the official BreezoMeter website and navigating to the developer dashboard or account settings section.

  1. Sign Up for an Account: Visit the BreezoMeter homepage and locate the sign-up or free trial option. Complete the registration form with the required information.
  2. Access the Dashboard: Once registered and logged in, you will typically be directed to your developer dashboard. This dashboard is the central hub for managing your account, subscriptions, and API keys.
  3. Locate API Key Section: Within the dashboard, look for a section explicitly labeled "API Keys," "Credentials," or "Developer Settings."
  4. Generate/Retrieve Key: Your API key should be displayed in this section. If it's your first time, a key might be automatically generated for you. Some platforms allow you to generate multiple keys for different applications or environments, and to revoke existing keys.

It is critical to treat your API key as sensitive information. Do not embed it directly into front-end client-side code that could be publicly accessible, and avoid committing it to version control systems like Git. If you suspect your API key has been compromised, you should immediately revoke it from your BreezoMeter dashboard and generate a new one.

Authenticated request example

Once you have obtained your API key, you can include it in your API requests to BreezoMeter Pollen. The key is typically passed as a query parameter named key. The following examples demonstrate how to make an authenticated request using cURL, Python, and JavaScript.

cURL Example

This cURL command demonstrates a basic request to a hypothetical BreezoMeter Pollen endpoint, replacing YOUR_API_KEY with your actual key.

curl "https://api.breezometer.com/pollen/v2/current?lat=34.052235&lon=-118.243683&key=YOUR_API_KEY"

Python Example

Using the requests library in Python, you can construct an authenticated request as follows:

import requests

api_key = "YOUR_API_KEY"
latitude = 34.052235
longitude = -118.243683

url = f"https://api.breezometer.com/pollen/v2/current?lat={latitude}&lon={longitude}&key={api_key}"

try:
    response = requests.get(url)
    response.raise_for_status()  # Raise an HTTPError for bad responses (4xx or 5xx)
    data = response.json()
    print(data)
except requests.exceptions.RequestException as e:
    print(f"An error occurred: {e}")

JavaScript Example (Node.js with node-fetch)

For a server-side JavaScript application using Node.js and node-fetch (or similar HTTP client libraries):

const fetch = require('node-fetch');

const apiKey = "YOUR_API_KEY";
const latitude = 34.052235;
const longitude = -118.243683;

const url = `https://api.breezometer.com/pollen/v2/current?lat=${latitude}&lon=${longitude}&key=${apiKey}`;

async function getPollenData() {
  try {
    const response = await fetch(url);
    if (!response.ok) {
      throw new Error(`HTTP error! Status: ${response.status}`);
    }
    const data = await response.json();
    console.log(data);
  } catch (error) {
    console.error("Error fetching pollen data:", error);
  }
}

pollenData();

These examples illustrate the fundamental principle: your API key is appended to the request URL as a query parameter. Always ensure that you are using https:// in your URLs to encrypt the transmission of your API key.

Security best practices

Securing your BreezoMeter Pollen API key is paramount to protect your account from unauthorized usage and potential service interruptions. Adhering to security best practices minimizes risks associated with credential exposure.

1. Keep API Keys Confidential

  • Never embed directly in client-side code: Do not hardcode your API key into JavaScript executed in a user's browser, mobile application binaries, or other publicly accessible client-side code. If exposed, anyone can use your key.
  • Use environment variables or configuration management: For server-side applications, store your API key in environment variables, a secure configuration file, or a dedicated secret management service (e.g., AWS Secrets Manager, Google Secret Manager, Azure Key Vault).
  • Avoid committing to version control: Ensure your API keys are not committed to source control repositories (e.g., Git). Use .gitignore rules to exclude configuration files containing keys.

2. Transmit Securely (HTTPS)

  • Always use HTTPS: BreezoMeter APIs should only be accessed via HTTPS. This encrypts the communication channel, protecting your API key and data from eavesdropping during transit. Using HTTP (unencrypted) would expose your key.

3. Implement Server-Side Proxies

  • For client-side applications (web browsers, mobile apps), consider implementing a server-side proxy. Your client application makes requests to your own backend server, which then makes the authenticated request to BreezoMeter using your API key. This prevents the API key from ever being exposed to the client.

4. Restrict API Key Usage (if applicable)

  • While BreezoMeter's API key management primarily focuses on a single key per account, for services that offer key restrictions (e.g., IP address whitelisting, HTTP referrer restrictions), utilize these features. If BreezoMeter were to introduce such features in the future, configuring them would add an extra layer of security, ensuring your key only works from expected origins.

5. Monitor API Usage

  • Regularly monitor your API usage through the BreezoMeter dashboard. Unusual spikes in requests or unexpected usage patterns could indicate a compromised key.

6. Rotate API Keys

  • Periodically rotate your API keys. This involves generating a new key, updating your applications to use the new key, and then revoking the old key. This practice limits the window of exposure for any single key.

7. Error Handling and Logging

  • Implement robust error handling for authentication failures. Avoid logging API keys in plain text in application logs. If an authentication error occurs, log only enough information to diagnose the problem without exposing sensitive credentials.

By following these best practices, developers can significantly enhance the security posture of their applications integrating with BreezoMeter Pollen, protecting both their data and their access credentials.