Coder Social home page Coder Social logo

wunderground.net's Introduction

Weather Underground .Net API Wrapper (Also Weather.com)

This library implements most features of the Wunderground.com Weather API.

http://www.wunderground.com/weather/api/d/docs

NuGet Package:

https://nuget.org/packages/WUnderground.Net

Currently Supported Features:

  • Alerts
  • Almanac
  • Astronomy
  • Conditions
  • Forecast
  • Forecast10day
  • GeoLookup
  • Hourly
  • CurrentHurricane (in progress)

Usage:

string key = "{Your API Key Here}";
WeatherClient client = new WeatherClient(key);

//Gets data by Airport Code
client.GetForecast(QueryType.AirportCode, new QueryOptions() { AirportCode = "DFW" });  

//Gets data by the detected IP address of the calling client
client.GetForecast(QueryType.AutoIp);  

//Gets data by country and city
client.GetForecast(QueryType.GlobalCity, new QueryOptions() { Country = "France", City = "Paris" }); 

//Gets data by GPS coordinates
client.GetForecast(QueryType.GPS, new QueryOptions() { Latitude = "37.776289", Longitude = "-122.395234" });

//Gets data by Weather Underground Link ID
client.GetForecast(QueryType.LinkId, new QueryOptions() { LinkId = "00000.1.16172" }); 

//Gets data from a personal weather station by ID
client.GetForecast(QueryType.PWSId, new QueryOptions() { PWSId = "KMNCHASK10" }); 

//Gets data for a US City
client.GetForecast(QueryType.USCity, new QueryOptions() { City = "Los Angeles", State = "CA" }); 

//Gets data by US Zip Code
client.GetForecast(QueryType.ZipCode, new QueryOptions() { ZipCode = "90210" }); 

//Gets Alerts by US City Asynchronously
await client.GetAlertsAsync(QueryType.USCity, new QueryOptions() { City = "Los Angeles", State = "CA" });

All methods have both Synchronous and Asynchronous versions

Optional Settings:

Optional settings can be used on any method call and multiple settings can be used together

//Gets a forecast in the specifid language
client.GetForecast(QueryType.AutoIp, new QueryOptions() { Language = "FR" };

//Gets a forecast setting the Use Personal Weather Stations for conditions setting (default is true)
client.GetForecast(QueryType.AutoIp, new QueryOptions() { UsePWS = false };

//Gets a forecast setting the Use Weather Underground Best Forecast for forecast
client.GetForecast(QueryType.AutoIp, new QueryOptions() { UseBestFct = false };

WUnderground Optional Settings Documentation

Supported Languages

Best Forecast Documentation

This library is distributed under an MIT license.

wunderground.net's People

Contributors

dknoodle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

wunderground.net's Issues

Hour forecast error converting week day

Hi, I'm getting this error where downloading hour forecast with Language = 'CZ'

JsonSerializationException: Error converting value "Úterý" to type 'System.DayOfWeek'. Path 'hourly_forecast[0].FCTTIME.weekday_name', line 14, position 357.

Consider changing the base url to use HTTPS instead of HTTP

All of the weather underground APIs work via HTTPS calls. It would be nice to have this as the default or to be able to change this at runtime. This is specifically an issue when using the library on a mobile platform such as iOS where calls to non-https endpoints have to be configured explicitly.

Exceptions on any Get call

Hi,

edit Please disregard. It was just windoze being windoze.

I get the following on any of the "Get*" functions. Can you help?

Exception thrown: 'System.ArgumentException' in CreativeGurus.Weather.Wunderground.dll
Exception thrown: 'System.ArgumentException' in mscorlib.dll
Exception thrown: 'System.AggregateException' in mscorlib.dll

Errors using the Language QueryOption

Hi there,

I'm creating an application that I would like to be able to run in a few different languages: primarily "en-US" and "da-DK".
I've set the Language override to Danish in the OnLaunched event:
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "da-DK";

And then I call your api (with the Language queryoption set to "DK"):

var Test = await client.GetForecastAsync(QueryType.GPS, new QueryOptions() { Longitude =_lon.ToString(), Latitude=_lat.ToString(), Language = "DK"});

This throws an exception with the following message:
{[type, querynotfound]}
{[description, No cities match your search query]}

Then I tried to run the call without the Language queryoption, but with the Language override set to Danish:
var Test = await client.GetForecastAsync(QueryType.GPS, new QueryOptions() { Longitude =_lon.ToString(), Latitude=_lat.ToString()});

This still throws an exception with the following message:
{[type, querynotfound]}
{[description, No cities match your search query]}

What am I doing wrong or what did I miss?

Thanks for creating this library, regardless of my above issues, it is a lot easier that translating JSON myself!

Bjarne

"Freeze" when using GetForecastAsync with MVVM Light

Hi there,

I've been converting one of my personal projects to use MVVM Light (VS2017 and Windows Template Studio) and when I use the await-able version of the above call, the app "locks up

This works with the MVVM template:

double _lat = 55.680495;
double _lon = 12.259956;

var _WeatherforeCast = _weatherClient.GetForecast(QueryType.GPS, new QueryOptions() { Language = "DK", Latitude = _lat.ToString(), Longitude = _lon.ToString() });

This doesn't work with the MVVM template (but works with my "normal" code-behind project)

double _lat = 55.680495;
double _lon = 12.259956;

var _WeatherforeCast = await _weatherClient.GetForecastAsync(QueryType.GPS, new QueryOptions() { Language = "DK", Latitude = _lat.ToString(), Longitude = _lon.ToString() });

Any ideas as to what I need to look for?
Thanks,
Bjarne

GetHourly API does not work properly

I Uncommented GetHourly API call in Sample and get Temperature Dewpoint etc zeros.
Then I simply erased new DoubleConverter in JsonConvert.DeserializeObject(response.Content, new BoolConverter()); call and it fixed the issue. Something is wrong with DoubleConverter.
I want to mention that I like this library, and will be happy to see this bug fixed.
I also hope that author will provide:

  1. GetHourlyAsync and GetHourly10DayAsync API, which is simple. In my code i did it with copy/paste
  2. xml interface in parallel to json interface

Astronomy

I'm trying to get moonage but the value is always null. Here is how I'm doing
`
static AstronomyResponse asr1 = new AstronomyResponse();
static WeatherClient client = new WeatherClient(key);
asr1 = await client.GetAstronomyAsync(QueryType.LinkId, new QueryOptions() { LinkId = "00000.49.83671", Language = "BR" });

string moonAge = asr1.MoonPhase.AgeOfMoon;`

Astronomy phaseofMoon

Hi, Thanks for this helpful project, is it possible to add the phaseofMoon to the AstronomyResponse ? Also If possible the hemisphere. Bellow I added the json response to make it easier.

`

{
"response": {
"version": "0.1",
"termsofService": "http://www.wunderground.com/weather/api/d/terms.html",
"features": {
"astronomy": 1
}
},
"moon_phase": {
"percentIlluminated": "2",
"ageOfMoon": "28",
"phaseofMoon": "Waning Crescent",
"hemisphere": "South",
"current_time": {
"hour": "11",
"minute": "48"
},
"sunrise": {
"hour": "6",
"minute": "37"
},
"sunset": {
"hour": "17",
"minute": "37"
},
"moonrise": {
"hour": "5",
"minute": "05"
},
"moonset": {
"hour": "16",
"minute": "53"
}
},
"sun_phase": {
"sunrise": {
"hour": "6",
"minute": "37"
},
"sunset": {
"hour": "17",
"minute": "37"
}
}
}
`

Any plan to support .NET Core?

Is there any plan to support .NET Core? When I try to install with .NET Core, I get:

Package WUnderground.Net 2.0.1 is not compatible with netcoreapp1.1 (.NETCoreApp,Version=v1.1). Package WUnderground.Net 2.0.1 supports: net45 (.NETFramework,Version=v4.5)

Add direct support for .NET Framework 4.5

First of all thank you for a great library. It has saved me a great deal of time. There was, however, one area that prevented me from using your package directly from NuGet.

Only providing a target for .NET Standard, adds a significant number of project dependencies to .NET Framework projects. If you convert your project to be a multi-target framework project, this is easily remedied.

There would be very little change necessary to your code base to accomplish this.

For example, use this:
<TargetFrameworks>net45;netstandard1.1</TargetFrameworks>

Instead of this:
<TargetFramework>netstandard1.1</TargetFramework>

I'd also recommend removing explicit references like <DocumentationFile>bin\Release\netstandard1.1\CreativeGurus.Weather.Wunderground.xml</DocumentationFile> in favor of <GenerateDocumentationFile>true</GenerateDocumentationFile> that can do this automatically.

I also had to add the following block to the project.

  <ItemGroup Condition="'$(TargetFramework)' == 'net45'">
    <Reference Include="System.Net.Http" />
  </ItemGroup>

Once you do this, all targets build successfully at the same time and will be included automatically when building your NuGet package. (please see https://www.nuget.org/packages/Newtonsoft.Json/ as an example of including both .NET Framework and .NET Standard distributions)

Note: You will need to make adjustments to your "Sample" project as well.

Regards,

Ryan Christiansen

Missing planner API method

Any plans to add the planner API method? This seems to be the only API method I see that returns a % (percentage) chance of rain. The chance of property returns several values each with predictions. For instance chance_of = "chanceofprecip"

"chanceofprecip": { "name": "Precipitation", "description": "", "percentage": "1" }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.