WeatherAPI.com provides access to weather and geo data via a JSON/XML restful API. It allows developers to create desktop, web and mobile applications using this data very easy.
We provide following data through our API:
- Real-time weather
- 14 day weather forecast
- Historical Weather
- Marine Weather and Tide Data
- Future Weather (Upto 365 days ahead)
- Daily and hourly intervals
- 15 min interval (Enterprise only)
- Astronomy
- Time zone
- Location data
- Sports
- Search or Autocomplete API
- Weather Alerts
- Air Quality Data
- Bulk Request
You need to signup and then you can find your API key under your account, and start using API right away!
Try our weather API by using interactive API Explorer.
We also have SDK for popular framework/languages available on Github for quick integrations.
If you find any features missing or have any suggestions, please contact us.
API access to the data is protected by an API key. If at anytime, you find the API key has become vulnerable, please regenerate the key using Regenerate button next to the API key.
Authentication to the WeatherAPI.com API is provided by passing your API key as request parameter through an API .
key=YOUR API KEY
Building the API client library requires:
- Java 1.7+
- Maven/Gradle
To install the API client library to your local Maven repository, simply execute:
mvn clean install
To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:
mvn clean deploy
Refer to the OSSRH Guide for more information.
Add this dependency to your project's POM:
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-java-client</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
Add this dependency to your project's build file:
compile "io.swagger:swagger-java-client:1.0.0"
At first generate the JAR by executing:
mvn clean package
Then manually install the following JARs:
target/swagger-java-client-1.0.0.jar
target/lib/*.jar
Please follow the installation instruction and execute the following Java code:
import io.swagger.client.*;
import io.swagger.client.auth.*;
import io.swagger.client.model.*;
import io.swagger.client.api.ApisApi;
import java.io.File;
import java.util.*;
public class ApisApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure API key authorization: ApiKeyAuth
ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
ApiKeyAuth.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//ApiKeyAuth.setApiKeyPrefix("Token");
ApisApi apiInstance = new ApisApi();
String q = "q_example"; // String | Pass US Zipcode, UK Postcode, Canada Postalcode, IP address, Latitude/Longitude (decimal degree) or city name. Visit [request parameter section](https://www.weatherapi.com/docs/#intro-request) to learn more.
LocalDate dt = LocalDate.now(); // LocalDate | Date on or after 1st Jan, 2015 in yyyy-MM-dd format
try {
Object result = apiInstance.astronomy(q, dt);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ApisApi#astronomy");
e.printStackTrace();
}
}
}
All URIs are relative to https://api.weatherapi.com/v1
Class | Method | HTTP request | Description |
---|---|---|---|
ApisApi | astronomy | GET /astronomy.json | Astronomy API |
ApisApi | forecastWeather | GET /forecast.json | Forecast API |
ApisApi | futureWeather | GET /future.json | Future API |
ApisApi | historyWeather | GET /history.json | History API |
ApisApi | ipLookup | GET /ip.json | IP Lookup API |
ApisApi | marineWeather | GET /marine.json | Marine Weather API |
ApisApi | realtimeWeather | GET /current.json | Realtime API |
ApisApi | searchAutocompleteWeather | GET /search.json | Search/Autocomplete API |
ApisApi | timeZone | GET /timezone.json | Time Zone API |
- Alerts
- AlertsAlert
- ArrayOfSearch
- Astronomy
- AstronomyAstro
- Current
- CurrentAirQuality
- CurrentCondition
- Error400
- Error401
- Error403
- Forecast
- ForecastAstro
- ForecastCondition
- ForecastDay
- ForecastDayCondition
- ForecastForecastday
- ForecastHour
- Ip
- Location
- Marine
- MarineForecastday
- MarineHour
- Search
Authentication schemes defined for the API:
- Type: API key
- API key parameter name: key
- Location: URL query string
It's recommended to create an instance of ApiClient
per thread in a multithreaded environment to avoid any potential issues.