Show / Hide Table of Contents

Class APIClient

Client to make requests to weather api

Inheritance
object
APIClient
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: WeatherAPI_CSharp
Assembly: WeatherAPI-CSharp.dll
Syntax
public class APIClient

Constructors

| Edit this page View Source

APIClient(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

true: Use https, false: Use http

Methods

| Edit this page View Source

GetLocationDataByIpAsync()

Get the location via the IP endpoint

Declaration
public Task<LocationData> GetLocationDataByIpAsync()
Returns
Type Description
Task<LocationData>

LocationData object containing the location

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX