Forecast.io client library

Provides access to the Forecast.io API

License

License

GroupId

GroupId

ch.rasc
ArtifactId

ArtifactId

forcastio
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

Forecast.io client library
Provides access to the Forecast.io API
Project URL

Project URL

https://github.com/ralscha/forecastio/
Source Code Management

Source Code Management

https://github.com/ralscha/forecastio.git

Download forcastio

How to add to project

<!-- https://jarcasting.com/artifacts/ch.rasc/forcastio/ -->
<dependency>
    <groupId>ch.rasc</groupId>
    <artifactId>forcastio</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/ch.rasc/forcastio/
implementation 'ch.rasc:forcastio:1.0.1'
// https://jarcasting.com/artifacts/ch.rasc/forcastio/
implementation ("ch.rasc:forcastio:1.0.1")
'ch.rasc:forcastio:jar:1.0.1'
<dependency org="ch.rasc" name="forcastio" rev="1.0.1">
  <artifact name="forcastio" type="jar" />
</dependency>
@Grapes(
@Grab(group='ch.rasc', module='forcastio', version='1.0.1')
)
libraryDependencies += "ch.rasc" % "forcastio" % "1.0.1"
[ch.rasc/forcastio "1.0.1"]

Dependencies

compile (3)

Group / Artifact Type Version
com.squareup.okhttp3 : okhttp jar 3.4.1
com.fasterxml.jackson.core : jackson-databind jar 2.8.3
org.immutables : value Optional jar 2.3.2

Project Modules

There are no modules declared in this project.

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

Versions

Version
1.0.1
1.0.0