darksky-forecast-api

A java library to access the DarkSky weather forecast API.

License

License

GroupId

GroupId

tk.plogitech
ArtifactId

ArtifactId

darksky-forecast-api
Last Version

Last Version

2.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

darksky-forecast-api
A java library to access the DarkSky weather forecast API.
Source Code Management

Source Code Management

https://github.com/200Puls/darksky-forecast-api.git

Download darksky-forecast-api

How to add to project

<!-- https://jarcasting.com/artifacts/tk.plogitech/darksky-forecast-api/ -->
<dependency>
    <groupId>tk.plogitech</groupId>
    <artifactId>darksky-forecast-api</artifactId>
    <version>2.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/tk.plogitech/darksky-forecast-api/
implementation 'tk.plogitech:darksky-forecast-api:2.1.0'
// https://jarcasting.com/artifacts/tk.plogitech/darksky-forecast-api/
implementation ("tk.plogitech:darksky-forecast-api:2.1.0")
'tk.plogitech:darksky-forecast-api:jar:2.1.0'
<dependency org="tk.plogitech" name="darksky-forecast-api" rev="2.1.0">
  <artifact name="darksky-forecast-api" type="jar" />
</dependency>
@Grapes(
@Grab(group='tk.plogitech', module='darksky-forecast-api', version='2.1.0')
)
libraryDependencies += "tk.plogitech" % "darksky-forecast-api" % "2.1.0"
[tk.plogitech/darksky-forecast-api "2.1.0"]

Dependencies

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

darksky-forecast-api

  • darksky-forecast-api is a Java library to access the darksky.net weather API
  • No dependencies for the the base library
  • You can pipe the response to the JSON framework of choice or use it directly as String, Stream or byte[] (e.g. poxying)
  • For Jackson users there is darksky-forecast-api-jackson to get the Forecast parsed as Java beans. This library includes the base library as dependency.
  • deployed to Maven Central
  • Javadoc available: https://200puls.github.io/darksky-forecast-api/
  • Full Java 9 module support (2.0.2 use 1.3.1 for java 8 sources)

Example usage for base library:

    ForecastRequest request = new ForecastRequestBuilder()
        .key(new APIKey("your-private-key"))
        .location(new GeoCoordinates(new Longitude(13.377704), new Latitude(52.516275))).build();

    DarkSkyClient client = new DarkSkyClient();
    String forecast = client.forecastJsonString(request);

The response can be returned as byte[], String or InputStream. Useful if you want to proxy the API or only save the result.

The API also supports time machine requests and other API parameters:

    ForecastRequest request = new ForecastRequestBuilder()
        .key(new APIKey("your-private-key"))
        .time(Instant.now().minus(5, ChronoUnit.DAYS))
        .language(ForecastRequestBuilder.Language.de)
        .units(ForecastRequestBuilder.Units.us)
        .exclude(ForecastRequestBuilder.Block.minutely)
        .extendHourly()
        .location(new GeoCoordinates(new Longitude(13.377704), new Latitude(52.516275))).build();

    DarkSkyClient client = new DarkSkyClient();
    String forecast = client.forecastJsonString(request);

The Maven dependency is:

      <dependency>
            <groupId>tk.plogitech</groupId>
            <artifactId>darksky-forecast-api</artifactId>
            <version>2.0.2</version>
     </dependency>

Example usage for the Jackson library:

    ForecastRequest request = new ForecastRequestBuilder()
        .key(new APIKey("your-private-key"))
        .location(new GeoCoordinates(new Longitude(13.377704), new Latitude(52.516275))).build();

    DarkSkyJacksonClient client = new DarkSkyJacksonClient();
    Forecast forecast = client.forecast(request);
    System.out.println("forecast " + forecast);
    System.out.println("forecast " + forecast.getCurrently().getTemperature());

The Maven dependency for the Jackson library is:

    <dependency>
            <groupId>tk.plogitech</groupId>
            <artifactId>darksky-forecast-api-jackson</artifactId>
            <version>2.0.2</version>
    </dependency>

It pulls in the base library automatically.

For more information about Request and Response format see: DarkSky documentation.

Versions

Version
2.1.0
2.0.2
2.0.1
2.0.0
1.3.1
1.3.0
1.2.1
1.2.0
1.1.0
1.0.0
0.10
0.9