API Access Key & Authentication
The first step to using the API is to authenticate with your weatherstack account's unique API access key, which can be found in your account dashboard after registration. To authenticate with the API, simply use the base URL below and pass your API access key to the API's access_key parameter.
Example API Request:
https://api.apilayer.net/weatherstack/current?access_key=YOUR_ACCESS_KEY&query=New%20YorkKeep it safe: Please ensure that you keep your API access key private and do not expose it in any publicly available part of your application. If you ever need to reset your key, simply visit your account dashboard to do so.
256-bit HTTPS Encryption
Users can connect to the Weatherstack using industry-standard SSL (HTTPS) by attaching an s to the HTTP protocol as shown in the example API request below.
Available on: All Plans
Example API Request:
https://api.apilayer.net/weatherstack/current?access_key=YOUR_ACCESS_KEY&query=New%20YorkAPI Error Codes
Whenever an API request fails, the Weatherstack API will return an error object in lightweight JSON format. Each error object contains an error code, an error type, and an info object containing details about the error that occurred. Below, you will find an example error and a list of common API errors.
Example API Error:
{
"success": false,
"error": {
"code": 104,
"type": "usage_limit_reached",
"info": "Your monthly API request volume has been reached. Please upgrade your plan."
}
}Common API Errors:
| Code | Type | Info |
|---|---|---|
404 | 404_not_found | User requested a resource which does not exist. |
101 | unauthorized | User did not supply an access key / invalid access key |
429 | too_many_requests | User has reached his subscription's monthly request allowance. |
601 | missing_query | Please specify a valid location identifier using the query parameter. |
603 | historical_queries_not_supported_on_plan | Your current subscription plan does not support historical weather data. Please upgrade your account to use this feature. |
604 | bulk_queries_not_supported_on_plan | Your current subscription plan does not support bulk queries. Please upgrade your account to use this feature. |
605 | invalid_language | You have specified an invalid language code. [Required format: 2-letter ISO Code] Also returned for language=en: leave language out for English. |
606 | invalid_unit | You have specified an invalid unit. Please try again or refer to our API documentation. |
607 | invalid_interval | An invalid interval value was specified. |
608 | invalid_forecast_days | An invalid forecast days value was specified. |
609 | forecast_days_not_supported_on_plan | Your current subscription plan does not support weather forecast data. Please upgrade your account to use this feature. |
611 | invalid_historical_date | An invalid historical date was specified. |
612 | invalid_historical_time_frame | An invalid historical time frame was specified. |
613 | historical_time_frame_too_long | The specified historical time frame is too long. (Maximum: 60 days) |
614 | missing_historical_date | An invalid historical date was specified. |
615 | request_failed | API request has failed. |
616 | missing_latitude | Missing latitude value. |
617 | missing_longitude | Missing longitude value. |
618 | invalid_latitude_type | An invalid latitude value was specified. |
619 | invalid_longitude_type | An invalid longitude value was specified. |
620 | missing_historical_date_start | Missing historical start date value. |
621 | invalid_tide | An invalid tide value was specified. |
622 | invalid_historical_date_start | An invalid historical start date value was specified. |
623 | invalid_historical_date_end | An invalid historical end date value was specified. |
624 | invalid_historical_date_range | An invalid date range was specified. |