Why does Darksky API doesnt allow to extract temperature info for few coordinates ?

#install.packages("darksky")
library(darksky)
library(tidyverse)

# current verison
packageVersion("darksky")

Sys.setenv("DARKSKY_API_KEY" = # Secret API Key
             )
Sys.getenv("DARKSKY_API_KEY")

#This coordinates works 
now <- get_current_forecast(43.2672, -70.8617)
print(now)

now$daily$time 
# time in UTC 

# Trying to extract temperature info for London ...got HTTP 403 error
seq(as.Date("2000-01-01"), as.Date("2001-01-01"), "day") %>% 
  map(~get_forecast_for(51.5074, 0.1278, .x)) %>% 
  map_df("daily") %>% 
  ggplot(aes(x=time, y=temperature)) +
  geom_line()
# HTTP 403 error

HTTP 403 error is "access forbidden", which could reflect an invalid API key (try with different coordinates) or a misconfiguration on their end (server daemon lacks read permissions for some resource required to return the data).

1 Like

Ok, So, does it mean, It is not possible to extract all cities vai DarkSky ?

In that case, can you please suggest a way to extract such info ? e.g. from 2000 - 2019 snow data ?

  1. Run the tests from documentation
library(darksky)
library(testthat)

date()
test_dir("tests/")
  1. Confirm your API key and check its required location

The API wrapper functions in this package all rely on a Dark Sky API key residing in the environment variable \code{DARKSKY_API_KEY}. The easiest way to accomplish this is to set it in the \code{.Renviron} file in your home directory.

  1. Check to see if you are within any limit on API calls
print(sprintf("You have used %s API calls.", then$`x-forecast-api-calls`))
  1. Run the example
seq(Sys.Date()-10, Sys.Date(), "1 day") %>% 
  map(~get_forecast_for(43.2672, -70.8617, .x)) %>% 
  map_df("hourly") %>% 
  ggplot(aes(x=time, y=temperature)) +
  geom_line()

Actually, I ran the example.
But how can we run for London.

Great! That means we just need to work on the syntax. Let's eliminate the possibility that they are having some problem with London in their data base by re-running the example with

51.5074, 0.1278

Thanks, actually my API calls were over yesterday. I was wondering using this API
https://github.com/hrbrmstr/darksky, If we can get to know about snow details such as snow start date in a particular region and amount (precipAmount). Because in their website, they mentioned snowFall data is available but not sure to extract such info.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.