{"id":15993924,"url":"https://github.com/knutwalker/forecast-io-scala","last_synced_at":"2025-10-21T03:30:38.094Z","repository":{"id":13130041,"uuid":"15812074","full_name":"knutwalker/forecast-io-scala","owner":"knutwalker","description":"Scala wrapper library for the v2 Forecast API provided by The Dark Sky Company, LLC. Based on https://github.com/MartinSeeler/forecast-io-wrapper","archived":true,"fork":false,"pushed_at":"2014-01-16T21:56:10.000Z","size":504,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-28T23:38:52.737Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/knutwalker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-10T22:45:46.000Z","updated_at":"2024-10-14T14:07:01.000Z","dependencies_parsed_at":"2022-09-16T04:31:04.055Z","dependency_job_id":null,"html_url":"https://github.com/knutwalker/forecast-io-scala","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knutwalker%2Fforecast-io-scala","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knutwalker%2Fforecast-io-scala/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knutwalker%2Fforecast-io-scala/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knutwalker%2Fforecast-io-scala/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knutwalker","download_url":"https://codeload.github.com/knutwalker/forecast-io-scala/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237429395,"owners_count":19308783,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-08T07:03:18.425Z","updated_at":"2025-10-21T03:30:37.791Z","avatar_url":"https://github.com/knutwalker.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"forecast-io-scala\n=================\n\nhttp://blog.knutwalker.de/forecast-io-scala/\n\nScala wrapper library for the v2 Forecast API provided by The Dark Sky Company, LLC.\n\n\u003e Based on https://github.com/MartinSeeler/forecast-io-wrapper\n\nThe Scala wrapper runs on top of [Akka](http://akka.io).\n\n## About\n\nThe Forecast API lets you query for most locations on the globe, and returns:\n\n- Current conditions\n- Minute-by-minute forecasts out to 1 hour (where available)\n- Hour-by-hour forecasts out to 48 hours\n- Day-by-day forecasts out to 7 days\n\n\n## Usage\n\n### Samples\n\nA simple request for the current temperature:\n```scala\n// specify your API key\nval apiKey = \"replace-with-your-key\"\nval forecastIO = ForecastIO(apiKey)\n\n// coordinates for Dresden, Germany\nval latitude = 51.0504\nval longitude = 13.7373\n\n// For asynchronous execution\nimport ForecastIO.executionContext\n\n// retrieve the current forecast\nval forecast = forecastIO(latitude, longitude)\n\n// deal with the result when it is available\nforecast.foreach { result =\u003e\n  println(s\"Current temperature is ${result.currently.map(_.temperature)}\")\n  println(s\"Apparent temperature is ${result.currently.map(_.apparentTemperature)\")\n}\n```\n\n`ForecastIo.apply` simply returns a `Future[Forecast]`.\n`Forecast` and other nested POJOs are all case classes, so you can pattern match all the way through:\n```scala\n// specify your API key\nval apiKey = \"replace-with-your-key\"\nval forecastIO = ForecastIO(apiKey)\n\n// coordinates for Dresden, Germany\nval latitude = 51.0504\nval longitude = 13.7373\n\n// For asynchronous execution\nimport ForecastIO.executionContext\n\n// retrieve the current forecast\nval forecast = forecastIO(latitude, longitude)\n\n// deal with the result when it is available\nforecast onComplete {\n\n  case Success(Forecast(_, _, timezone, _, Some(HourlyDataPoint(_, _, temperature, _, _, _, _, _)), _, _, Some(DailyDataBlock(_, _, Vector(DailyDataPoint(_, sunset), _*))))) =\u003e\n\n    println(s\"It is $temperature degrees in $timezone and the sun sets at $sunset\")\n}\n```\n\n### Java API\n\n`forecast-io-scala` also tries to provide a proper Java API, similar to [`forecast-io-wrapper`](https://github.com/MartinSeeler/forecast-io-wrapper)s.\n\n```java\n// specify your API key\nfinal String apiKey = \"replace-with-your-key\";\nfinal ForecastIO forecastIO = new ForecastIO(apiKey);\n\n// coordinates for Dresden, Germany\nfinal double latitude = 51.0504d;\nfinal double longitude = 13.7373d;\n\n// retrieve the current forecast\nfinal Forecast forecast = forecastIO.getForecast(latitude, longitude);\n\nSystem.out.println(\"Current temperature is \" + forecast.getCurrently().getTemperature());\nSystem.out.println(\"Apparent temperature is \" + forecast.getCurrently().getApparentTemperature());\n```\n\nThat is teh traditional blocking API. In addition to that, `forecast-io-scala` also provides an asynchronous API for Java\n\n```java\n// specify your API key\nfinal String apiKey = \"replace-with-your-key\";\nfinal ForecastIO forecastIO = new ForecastIO(apiKey);\n\n// coordinates for Dresden, Germany\nfinal double latitude = 51.0504d;\nfinal double longitude = 13.7373d;\n\n// retrieve the current forecast\nforecastIO.asyncForecast(latitude, longitude, new Callback\u003cForecast\u003e() {\n    @Override\n    public void onSuccess(Forecast result) {\n\n        System.out.println(\"Current temperature is \" + result.getCurrently().getTemperature());\n        System.out.println(\"Apparent temperature is \" + result.getCurrently().getApparentTemperature());\n    }\n\n    @Override\n    public void onFailure(Throwable t) {}\n});\n```\n\n\n### Shutdown\n\n`forecast-io-scala` runs on top of [Akka](http://akka.io) and thus, needs to be shutdown properly.\nYou can do so beu calling either the static or the instance method `shutdown()` on `ForecastIO`\n\nIf omit the shutdown, your JVM will not terminate and you have to kill it abruptly.\n\n\n## Development\n\nYou'll only need [sbt](http://www.scala-sbt.org/) and a JDK 7.\nScala, Akka, Spray and other dependencies are downloaded during the build process.\n\n\n### Fatjar\n\n`forecast-io-scala` features a fatjar, that prints some simple information about some place.\nYou can build the jar with `sbt assembly` and use it like so:\n```bash\njava -jar -Dforecast.apikey=\"your-api-key-here\" target/scala-2.10/forecast-io-scala-0.1.0.jar 13.37 42\n```\n\n### Scaladoc\n\nScaladoc is available at http://blog.knutwalker.de/forecast-io-scala/current/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknutwalker%2Fforecast-io-scala","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknutwalker%2Fforecast-io-scala","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknutwalker%2Fforecast-io-scala/lists"}