darksky-forecast-api is a Java library to access the darksky.net weather API
Clone or download
Latest commit 512eeb9 Dec 2, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
darksky-forecast-api-jackson fixed surefire Ecception: Caused by: java.lang.ClassNotFoundException… Oct 30, 2018
darksky-forecast-api Added windGust to DataPoint Nov 30, 2018
docs generated javadoc Mar 6, 2018
.gitignore Adding .idea to .gitignore Oct 27, 2017
LICENSE Create LICENSE Jan 11, 2018
README.md Update README.md Oct 30, 2018

README.md

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

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)
        .exdclude(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>1.3.1</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>1.3.1</version>
    </dependency>

It pulls in the base library automatically.

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