Unofficial .NET API client for the weather API available at weatherapi.com.
About The Project • How To Use • Examples • Credits
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.
They provide following data through our API:
- Real-time weather
- 10 day weather forecast
- Astronomy
- Time zone
- Location data
- Search or Autocomplete API
- Historical weather
You need an API key to be able to authenticate with the API. You can either sign up for, or log in to WeatherAPI to get your API key.
WeatherAPIClient
accepts two constructor parameters: your API key, and a custom base URI for the API. A valid API key must be provided, but specifying a base URI is optional.
string apiKey = "your API key";
WeatherAPIClient weatherApiClient = new WeatherAPIClient(apiKey);
API routes are separated out into category classes, referred to as operations, within the client. These classes contain all routes associated with the category, as well as overflow methods providing different request configurations.
Where required, or where available, you'll have the option to provide a request object to the method. The type of request object required is determined by the method you are trying to invoke, but all request objects adopt a fluent API style configuration layout, for example:
RequestEntity request = new RequestEntity()
.WithCityName("Paris")
.WithLanguage("fr");
Different request objects exist to provide extra configuration for the category of request you're trying to make. For example, you can request air quality data with the realtime routes:
RealtimeRequestEntity request = new RealtimeRequestEntity()
.WithCityName("Paris")
.WithLanguage("fr")
.WithAirQualityData(true);
Check out the samples
folder in the repository this repository was forked from, by clicking here.
- Credit to @lewisbennett for all code. I have made this repository so I can create a NuGet package with correctly working Moon and Sun set and rise times.