GithubHelp home page GithubHelp logo

dfconroy / forecastpcl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jcheng31/darkskyapi

0.0 2.0 0.0 542 KB

An unofficial C# Portable Class Library for the Forecast.io weather service.

License: MIT License

C# 100.00%

forecastpcl's Introduction

ForecastPCL

An unofficial C# Portable Class Library for the Forecast.io weather service. Compatible with .NET 4.5, Windows 8/8.1, Windows Phone 8/8.1, Silverlight 5, and Universal Windows Apps.

Installation

NuGet: Install-Package ForecastIOPortable

New in Version 2.3.1

  • Rebuilt the project in Release mode (thanks, @bklabs!)
  • Added missing Precipitation Type field (thanks, @lynnroth!)
  • Additional language support: Greek, Croatian, Ukrainian, and Traditional Chinese.

Quick Start

Current Conditions

using ForecastIOPortable;

...

var client = new ForecastApi("YOUR API KEY HERE");
Forecast result = await client.GetWeatherDataAsync(37.8267, -122.423);

...

Note that the Forecast.io service doesn't always return all fields for each region. In these cases, some properties may be null or zero.

Conditions for a specific date

using ForecastIOPortable;

...

var client = new ForecastApi("YOUR API KEY HERE");

Forecast result = await client.GetTimeMachineWeatherAsync(37.8267, -122.423, DateTimeOffset.Now);

...

The Helpers class contains extension methods to convert a DateTimeOffset to Unix time, and back:

int unixTime = DateTimeOffset.Now.ToUnixTime();

DateTimeOffset date = unixTime.ToDateTimeOffset();

API Usage Information

After making a request for data (be it current or historical), the ForecastApi instance's ApiCallsMade property will contain the number of calls made today, using the given API key. The property will be null if no requests have been made through the particular instance.

Dependencies

    Microsoft.Bcl (≥ 1.1.9)
    Microsoft.Bcl.Async (≥ 1.0.168)
    Microsoft.Bcl.Build (≥ 1.0.14)
    Microsoft.Bcl.Compression (≥ 3.9.81)
    Microsoft.Net.Http (≥ 2.2.22)

Design

This library uses a client-oriented approach, instead of a request-response model: the ForecastApi object is intended to be an abstraction from which weather data (Forecasts) can be obtained.

Forecasts do contain all the fields that can appear in the raw JSON obtained through making a direct request to the web service, but exposes them through more .NET convention-friendly properties: for example, precipIntensityMax is exposed as MaxPrecipitationIntensity. These properties are (as shown here) sometimes more verbose, but were intended to match the style commonly used in .NET projects.

Tests

NUnit is used for some simple integration tests with the actual web service. To run the tests, a valid API key must be added to the app.config file in the ForecastPCL.Test folder.

forecastpcl's People

Contributors

fourtonmantis avatar grendello avatar jcheng31 avatar lynnroth avatar

Watchers

 avatar  avatar

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.