Giter Site home page Giter Site logo

darksky's Introduction

Update: support for the Dark Sky API will be ending on March 31st, 2023

darksky

Test Status

Overview

darksky is a Java client library for the Dark Sky API API (former forecast.io).

For more details about the API and for creating an API key go to https://darksky.net/dev/ and sign up for a developer account. The free tier allows an application to send 1,000 API requests per day.

Example: Forecast Request

Create an instance of DsClient

DsClient client = new DsClient("...darksky.net.api.key...");

build a DsForecastRequest

DsForecastRequest request = DsForecastRequest.builder()
        .latitude("46.93011019")
		.longitude("7.5635394")
		.excludeBlock(DsBlock.ALERTS, DsBlock.MINUTELY, DsBlock.HOURLY)
		.unit(DsUnit.SI)
		.build();

call the API

DsResponse response = client.sendForecastRequest(request);

and process the response

for (DsDataPoint dataPoint : response.daily().data()) {
    ZoneId zoneId = ZoneId.of(response.timezone());
    Instant instant = Instant.ofEpochSecond(dataPoint.time());
    ZonedDateTime time = ZonedDateTime.ofInstant(instant, zoneId);

    System.out.print(time);
    System.out.print(": ");
    System.out.println(dataPoint.summary());
}

Example: Time Machine Request

Create an instance of DsClient

DsClient client = new DsClient("...darksky.net.api.key...");

build a DsTimeMachineRequest.

DsTimeMachineRequest request = DsTimeMachineRequest.builder()
        .latitude("46.93011019")
		.longitude("7.5635394")				
		.unit(DsUnit.SI)
		.time(ZonedDateTime.now().minusDays(10).toEpochSecond())
		.build();

call the API

DsResponse response = client.sendTimeMachineRequest(request);

and process the response

for (DsDataPoint dataPoint : response.hourly().data()) {			
    ZoneId zoneId = ZoneId.of(response.timezone());
    Instant instant = Instant.ofEpochSecond(dataPoint.time());
    ZonedDateTime time = ZonedDateTime.ofInstant(instant, zoneId);

    System.out.print(time);
    System.out.print(": ");
    System.out.println(dataPoint);            
}

Maven

	<dependency>
		<groupId>ch.rasc</groupId>
		<artifactId>darksky</artifactId>
		<version>2.0.1</version>
	</dependency>

Changelog

2.0.1 - March 21, 2020

  • Add missing properties to DsAlert and DsDataPoint according to the Dark Sky API documentation.

    • DsAlert.regions
    • DsAlert.severity
    • DsAlert.time
    • DsDataPoint.apparentTemperatureHigh
    • DsDataPoint.apparentTemperatureHighTime
    • DsDataPoint.apparentTemperatureLow
    • DsDataPoint.apparentTemperatureLowTime
    • DsDataPoint.precipIntensityError
    • DsDataPoint.temperatureHigh
    • DsDataPoint.temperatureHighTime
    • DsDataPoint.temperatureLow
    • DsDataPoint.temperatureLowTime
    • DsDataPoint.uvIndex
    • DsDataPoint.uvIndexTime
    • DsDataPoint.windGust
    • DsDataPoint.windGustTime

2.0.0 - October 20, 2016

  • Change package to ch.rasc.darksky (previously: ch.rasc.forecastio)
  • Change class name prefix from Fio* to Ds* (i.e. FioClient -> DsClient)
  • Fix include/exclude handling
  • Add time machine requests

1.0.1 - September 30, 2016

  • Change endpoint from api.forecast.io to api.darksky.net

1.0.0 - July 5, 2016

  • Initial release

License

Code released under the Apache license.

Powered by Dark Sky

darksky's People

Contributors

ralscha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  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.