General

Authentication

AccuWeather APIs use API key-based authentication to secure access to weather data. Every request to the API must include a valid API key in the Authorization header.

Get your API key

Your API key is available in your account dashboard.

  1. Sign up for a free AccuWeather developer account or sign in if you already have an account.
  2. Navigate to your subscriptions page.
  3. Copy your API key from the dashboard.

Your API key is unique to your account and should be kept secure. Do not share it publicly or commit it to version control.

Make authenticated requests

Include your API key in the Authorization header using the bearer token format:

const url = "https://dataservice.accuweather.com/currentconditions/v1/349727"; const response = await fetch(url, { headers: { "Authorization": "Bearer YOUR_API_KEY", "Accept-Encoding": "gzip", }, }); const data: Record<string, unknown>[] = await response.json();

This example retrieves current weather conditions for New York City (location key 349727).

Response format

Successful requests return JSON data with weather information. Unauthorized requests return a 401 status code.

JSONCode
{ "type": "https://httpproblems.com/http-status/401", "title": "Unauthorized", "status": 401, "instance": "/currentconditions/v1/349727", "trace": { "timestamp": "2025-07-26T08:00:13.887Z", "requestId": "f88dc27c-wmf1-4982-be8d-cc7b0f2a2b41", "buildId": "10a5efeb-jjf6-4971-89a5-51cfd7026e0f" }, "Code": "Unauthorized", "Message": "API authorization failed", "Reference": "https://dataservice.accuweather.com/currentconditions/v1/349727" }

Authentication best practices

Secure API keys

  • Store API keys as environment variables.
  • Never hardcode keys in client-side applications.
  • Use server-side proxies for client applications.
  • If you think your API key has been compromised, contact AccuWeather support immediately.

Request headers

  • Always include Accept-Encoding: gzip,deflate for compression.
  • Use HTTPS endpoints exclusively. Unsecure HTTP is not supported.
  • Include proper error handling for authentication failures.

Troubleshoot

IssueSolution
401 UnauthorizedVerify your API key is correct and active
403 ForbiddenCheck your subscription limits in Subscriptions
Rate limit exceededImplement caching and respect the expires header

What next?

Now that you understand authentication, explore our APIs:

Last modified on