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.

Getting Your API Key

Your API key is available in your account dashboard:

  1. Sign up for a free AccuWeather developer account if you haven't already
  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.

Making Authenticated Requests

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

Curl Example

TerminalCode
curl -H "Authorization: Bearer YOUR_API_KEY" \ -H "Accept-Encoding: gzip,deflate" \ "https://dataservice.accuweather.com/currentconditions/v1/349727"

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 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

Troubleshooting

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's Next?

Now that you understand authentication, explore our APIs:

Last modified on