## Solar Irradiance API

✔** This is the latest version of the API (v2).**

[Looking for the previous version? You can find the v1 documentation here.](/api/solar-energy-prediction.md)

<!-- block-id: concept -->

## Product concept

**Solar Irradiance** service supplies accurate solar irradiance data for any location on the globe.

Main features of Solar Irradiance API:

- Essential solar irradiation data:  - [Global Horizontal Irradiation (GHI)](/api/solar-radiation/behind-solar-radiation-api.md#introduction)
  - [Direct Normal Irradiation (DNI)](/api/solar-radiation/behind-solar-radiation-api.md#introduction)
  - [Diffuse Horizontal Irradiation (DHI)](/api/solar-radiation/behind-solar-radiation-api.md#introduction)
- All indices are available in [Clear Sky](/api/solar-radiation/behind-solar-radiation-api.md#clearsky) and [Cloudy Sky](/api/solar-radiation/behind-solar-radiation-api.md#cloudysky) models
- Current data and forecast for 15 days ahead
- Historical data is available for 47+ years back (from 1st January 1979)
- Data contains daily aggregation for each requested day with hourly detalization or detalization by specified intervals
- Global coverage

[You can find the previous documentation v1 here](/api/solar-energy-prediction.md#concept)

Data is available in JSON format.

The detailed information about what technologies, algorithms, etc. are behind the Solar Irradiance API can be found [here](/api/solar-radiation/behind-solar-radiation-api.md).

<!-- block-id: how -->

## How to get access

#### Sign up

[Sign up](https://home.openweathermap.org/users/sign_up) to OpenWeather service in case you haven't got your [OpenWeather API key](https://home.openweathermap.org/api_keys) yet.

#### Follow the pricing page

Follow the [pricing page](/price.md#alerts) to learn details about the price.

> Solar Irradiance API is included in the separate subscription only and allows you to pay only for the number of API calls made to this product. Please find more details on the [pricing page](/price.md#alerts).

#### Make an API call

Just make an API call according to the [tech documentation below](/api/solar-irradiance.md#api), remembering to add your key to each call.

<!-- block-id: irradiancedata -->

## Call Solar Irradiance data

In this section you will find how to request historical starting from 1st January 1979, current or forecast for 15 days ahead daily aggregated and accumulated over 1 hour, 15 minutes or 1 day interval solar radiation data for particular geographical location and for specified date.

### How to make an API call

```text
https://api.openweathermap.org/energy/2.0/solar/interval_data?lat={lat}&lon={lon}&date={date}&interval={interval}&appid={API key}
```

| Parameters |  |  |
| --- | --- | --- |
| `lat` | Yes | Latitude, decimal (−90; 90) |
| `lon` | Yes | Longitude, decimal (−180; 180) |
| `date` | Yes | Date in the `YYYY-MM-DD` format for which data is requested. Date available from 1979-01-01 up to +15 days to the current date |
| `appid` | Yes | Your unique API key (you can always find it on your account page under the ["API key" tab](https://home.openweathermap.org/api_keys)) |
| `interval` | optional | The time interval during which the energy is summed up, defines the temporary resolution of solar radiation data. If not specified, the default interval of "1h" (1 hour) will be used. Available values for this parameter include: "15m" (15 minutes), "1h" (1 hour) and "1d" (1 day) |

> If the service detected timezone for your location incorrectly you can specify correct timezone manually by adding `tz` parameter in the ±XX:XX format to API call.
>
> **API call**
>
> `https://api.openweathermap.org/energy/2.0/solar/interval_data?lat={lat}&lon={lon}&date={date}&interval={interval}&tz={tz}&appid=`[`{API key}`](https://home.openweathermap.org/api_keys)
>
> **Example of API call**
>
> `https://api.openweathermap.org/energy/2.0/solar/interval_data?lat=60.45&lon=-38.67&date=2023-03-30&interval=1h&tz=+03:00&appid=`[`{API key}`](https://home.openweathermap.org/api_keys)
>
> Please pay attention that in case timezone is specified time of sunset and sunrise will be returned in accordance with this specified timezone.

### Example of API call

```text
https://api.openweathermap.org/energy/2.0/solar/interval_data?lat=51.509865&lon=-0.118092&date=2023-10-10&interval=1h&appid={API key}
```

<!-- block-id: interval_fields -->

### Fields in API response

- `lat` Latitude of the location,decimal (−90; 90)
- `lon` Longitude of the location,decimal (-180; 180)
- `date` Date specified in the API request in the `YYYY-MM-DD` format (from 1979-01-01 up to +15 days to the current date)
- `interval` Time interval during which the energy is summed up. Determines temporary resolution of solar radiation data. If not specified "1h" interval will be used. Available values : 15m, 1h and 1d.
- `tz` Timezone in the ±XX:XX format
- `sunrise` Date and time of sunrise based on date specified in the API request and timezone authomatically determinated by on latitude and longitute of requested location. If you added timezone parameter into API request, then time of sunrise will be recalculated in accordance with this timezone. For polar areas in midnight sun and polar night periods this parameter is not returned in the response
- `sunset` Date and time of sunset based on date specified in the API request and timezone authomatically determinated by on latitude and longitute of requested location. If you added timezone parameter into API request, then time of sunset will be recalculated in accordance with this timezone. For polar areas in midnight sun and polar night periods this parameter is not returned in the response
- `intervals` Interval detalization of daily aggregated irradiation data for the requested date  - `start` Start of the time interval for which the energy is summed up. Time interval displays hour and minutes of the day for which indexes were aggregated in "hh:mm" format
  - `end` End of the time interval for which the energy is summed up. Time interval displays hour and minutes of the day for which indexes were aggregated in "hh:mm" format
  - `avg_irradiance` Average irradiance per period    - `clear_sky` clear sky model      - `ghi` Clear sky GHI - [Global Horizontal Irradiance](/api/solar-radiation/behind-solar-radiation-api.md#introduction), W/m2
      - `dni` Clear sky DNI - [Direct Normal Irradiance](/api/solar-radiation/behind-solar-radiation-api.md#introduction), W/m2
      - `dhi` Clear sky DHI - [Diffuse Horizontal Irradiance](/api/solar-radiation/behind-solar-radiation-api.md#introduction), W/m2
    - `cloudy_sky` cloudy sky model      - `ghi` Cloudy sky GHI - [Global Horizontal Irradiance](/api/solar-radiation/behind-solar-radiation-api.md#introduction), W/m2
      - `dni` Cloudy sky DNI - [Direct Normal Irradiance](/api/solar-radiation/behind-solar-radiation-api.md#introduction), W/m2
      - `dhi` Cloudy sky DHI - [Diffuse Horizontal Irradiance](/api/solar-radiation/behind-solar-radiation-api.md#introduction), W/m2
  - `max_irradiance` Maximum irradiance per period    - `clear_sky` clear sky model      - `ghi` Clear sky GHI - [Global Horizontal Irradiance](/api/solar-radiation/behind-solar-radiation-api.md#introduction), W/m2
      - `dni` Clear sky DNI - [Direct Normal Irradiance](/api/solar-radiation/behind-solar-radiation-api.md#introduction), W/m2
      - `dhi` Clear sky DHI - [Diffuse Horizontal Irradiance](/api/solar-radiation/behind-solar-radiation-api.md#introduction), W/m2
    - `cloudy_sky` cloudy sky model      - `ghi` Cloudy sky GHI - [Global Horizontal Irradiance](/api/solar-radiation/behind-solar-radiation-api.md#introduction), W/m2
      - `dni` Cloudy sky DNI - [Direct Normal Irradiance](/api/solar-radiation/behind-solar-radiation-api.md#introduction), W/m2
      - `dhi` Cloudy sky DHI - [Diffuse Horizontal Irradiance](/api/solar-radiation/behind-solar-radiation-api.md#introduction), W/m2
  - `irradiation` Irradiation related information    - `clear_sky` clear sky model      - `ghi` Clear sky GHI - [Global Horizontal Irradiation](/api/solar-radiation/behind-solar-radiation-api.md#introduction), Wh/m2
      - `dni` Clear sky DNI - [Direct Normal Irradiation](/api/solar-radiation/behind-solar-radiation-api.md#introduction), Wh/m2
      - `dhi` Clear sky DHI - [Diffuse Horizontal Irradiation](/api/solar-radiation/behind-solar-radiation-api.md#introduction), Wh/m2
    - `cloudy_sky` cloudy sky model      - `ghi` Cloudy sky GHI - [Global Horizontal Irradiation](/api/solar-radiation/behind-solar-radiation-api.md#introduction), Wh/m2
      - `dni` Cloudy sky DNI - [Direct Normal Irradiation](/api/solar-radiation/behind-solar-radiation-api.md#introduction), Wh/m2
      - `dhi` Cloudy sky DHI - [Diffuse Horizontal Irradiation](/api/solar-radiation/behind-solar-radiation-api.md#introduction), Wh/m2

<!-- block-id: bulk -->

## Bulk downloading

You can get the entire available historical solar irradiance archive in CSV and JSON formats:

- [Solar Irradiance History Bulk](/api/solar-irradiance-history-bulks.md) - archive for 47+ years with 15-minutes and 1-hour steps, available from January 1979.
- [Solar Irradiance History Forecast Bulk](/api/solar-irradiance-history-forecast-bulks.md) - archive of previously made 16 days ahead forecasts on solar irradiance data with 1-hour step (15-minutes step by request), available from April, 2017.

You can find prices on the [corresponding page](/price.md#solar_energy).

<!-- block-id: errors -->

## API errors

<!-- block-id: errorstructure -->

### Structure of API errors

In case of incorrected API call you will receive API error response. Error response payload returned for all types of errors with the structure below.

### Example of error response

```json
{
    "code": "400",
    "message": "Invalid date format",
    "parameters": [
        "date"
    ]
}
```

### Fields in error response

- `code` Code of error
- `message` Description of error
- `parameters`(optional) List of request parameters names that are related to this particular error

<!-- block-id: popularerrors -->

### Errors list

Please find more detailed information about some popular errors below.

#### API calls return an error 400

Error 400 - Bad Request. You can get error 400 error if either some mandatory parameters in the request are missing or some of request parameters have incorrect format or values out of allowed range. List of all parameters names that are missing or incorrect will be returned in `parameters`attribute of the `ErrorResponse` object.

#### API calls return an error 401

Error 401 - Unauthorized. You can get 401 error if API token did not providen in the request or in case API token provided in the request does not grant access to this API. You must add API token with granted access to the product to the request before returing it.

#### API calls return an error 404

Error 404 - Not Found. You can get 404 error if data with requested parameters (`lat`, `lon` and `date`) does not exist in service database. You must not retry the same request.

#### API calls return an error 429

Error 429 - Too Many Requests. You can get 429 error if key quata of requests for provided API to this API was exceeded. You may retry request after some time or after extending your key quota.

#### API calls return errors '5xx'

Errors 5xx - Unexpected Error. You can get '5xx' error in case of other internal errors. Error Response code will be `5xx`. Please [contact us](https://home.openweathermap.org/questions) and enclose an example of your API request that receives this error into your email to let us analyze it and find a solution for you promptly. You may retry the request which led to this error.

## Pay as you call

There are no limits on the number of API calls, users pay for a subscription according to the actual use of the product.

### {{price.energy.base}} per API call

Any location | No API call limits | Pay-as-you-call

- [Subscribe](https://home.openweathermap.org/subscriptions/unauth_subscribe/energy/base)

For large-scale projects, we provide a variety of custom packages. Please [get in touch](mailto:info@openweathermap.org) with us with your requirements to learn more.