https://github.com/sepppenner/openweathermapapi
OpenWeatherMapAPI
https://github.com/sepppenner/openweathermapapi
Last synced: 8 days ago
JSON representation
OpenWeatherMapAPI
- Host: GitHub
- URL: https://github.com/sepppenner/openweathermapapi
- Owner: SeppPenner
- Created: 2019-07-31T07:01:16.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-22T14:07:12.000Z (about 7 years ago)
- Last Synced: 2025-02-24T03:30:51.187Z (over 1 year ago)
- Language: C#
- Size: 1.72 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OpenWeatherMapAPI for free servises
My release of openweathermap api for net framework 4.6.1
-----
# Download dll https://eliseevtech.ru/files/openweathermap/OpenWeatherMapApi.dll
Now avalible on nuget
Install-Package ET.OpenWeatherMap -Version 0.0.1
# Usage
First - get your api key from openweathermap.org
Next add OpenWeatherMapApi.dll to your project
## Create api class:
OpenWeatherMap(YOU_API_KEY);
or
OpenWeatherMap(YOU_API_KEY, UNITS, LANG)
> UNITS can be: OpenWeatherMap.Units.imperial, OpenWeatherMap.Units.metric, OpenWeatherMap.Units.kelvin
> LANG can be: "ru", "us" , "pl", "zh_cn" and other, you can find it on openweathermap.org
example(there is not work random key, change it on your key!):
OpenWeatherMap weather = new OpenWeatherMap("d312d32131d314fcd4214d124d14");
//or
OpenWeatherMap weather = new OpenWeatherMap("d312d32131d314fcd4214d124d14", OpenWeatherMap.Units.metric, "ru");
## Get current weather
var moscowCurrent = weather.Current("Moscow"); //cache data
Console.WriteLine(@"{0} : {1} {2} C°", moscowCurrent.name ,moscowCurrent.weather.First().description , moscowCurrent.main.temp);
## Get forecast weather
string cityName = "London";
foreach (var list in weather.Forecast(cityName).list)
{
// (*) new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(list.dt) it is convert unixtime to datetime
Console.WriteLine( @"{0} {1} : {2}C°, {3}", cityName, new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(list.dt), list.main.temp , list.weather.First().description);
}
## Additionally functions
GenerateRequestLink(RequestType requestType, string _location) - return you http request link
RequestType can be = OpenWeatherMap.RequestType.current , OpenWeatherMap.RequestType.forecast
example:
GenerateRequestLink(OpenWeatherMap.RequestType.current,"Moscow"));