Class APIClient
Client to make requests to weather api
Inherited Members
Namespace: WeatherAPI_CSharp
Assembly: WeatherAPI-CSharp.dll
Syntax
public class APIClient
Constructors
| Edit this page View SourceAPIClient(string, bool)
Create APIClient with optional useHttps parameter
Declaration
public APIClient(string apiKey, bool useHttps = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | apiKey | Your API key |
| bool | useHttps |
|
Methods
| Edit this page View SourceGetLocationDataByIpAsync()
Get the location via the IP endpoint
Declaration
public Task<LocationData> GetLocationDataByIpAsync()
Returns
| Type | Description |
|---|---|
| Task<LocationData> | LocationData object containing the location |
GetWeatherCurrentAsync(string, bool)
Get Current weather at query location
Declaration
public Task<Forecast> GetWeatherCurrentAsync(string query, bool getAirData = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | query | Weather location |
| bool | getAirData | Wether or not to get air quality data |
Returns
| Type | Description |
|---|---|
| Task<Forecast> | Forecast object with data from location |
Remarks
Returns default on http error. In this case, Forecast.Valid will be false.
GetWeatherForecastDailyAsync(string, int)
Get weather forecast for the next days amount of days at query location
Declaration
public Task<ForecastDaily[]> GetWeatherForecastDailyAsync(string query, int days = 3)
Parameters
| Type | Name | Description |
|---|---|---|
| string | query | Weather location |
| int | days | Amount of days to get the forecast for |
Returns
| Type | Description |
|---|---|
| Task<ForecastDaily[]> | Array of ForecastDaily classes |
Remarks
Returns default on http error. In this case, ForecastDaily[0].Valid will be false.
GetWeatherForecastHourlyAsync(string, int)
Get weather forecast for the next hours amount of hours at query location
Declaration
public Task<ForecastHourly[]> GetWeatherForecastHourlyAsync(string query, int hours = 24)
Parameters
| Type | Name | Description |
|---|---|---|
| string | query | Weather location |
| int | hours | Amount of hours to get the forecast for |
Returns
| Type | Description |
|---|---|
| Task<ForecastHourly[]> | Array of ForecastHourly classes |
Remarks
Returns default on http error. In this case, ForecastHourly[0].Valid will be false.