We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I am trying to run APIs on a processing sketch to use them as input for data visualization. Got the same error at two open APIs. The error is the following:
Couldn't create a reader for http:// api.openweathermap.org/data/2.5/weather?lat=35&lon=139&APPID=f77c...
FATAL EXCEPTION: Animation Thread
Process: processing.test.jsonprocessingtutorial, PID: 25803
The url + API key string is working, I have tested it.. Seems to be a connection problem, how can I troubleshoot it?
The sketch loads a JSON and then displays a parameter as a test, float "wind". It seems to go wrong at loading the JSON..
The code of my sketch is the following:
String API_Key = "f77c...";
String url = "http://" + "api.openweathermap.org/data/2.5/weather?lat=35&lon=139";
//specific url with coordinates for specific city
void setup() {
size(480, 360);
loadData();
}
void loadData(){
JSONObject json = loadJSONObject(url+"&APPID="+API_Key);
JSONObject windData = json.getJSONObject("wind");
float speed = windData.getFloat("speed");
println (speed);
}
Answers
Hmm... Your posted sketch code has worked for me w/o any hassles. 8-|
Anyways, I've decided to remake it based on a previous p5.js sketch I already had: O:-)
http://Bl.ocks.org/GoSubRoutine/5fbc03e019c53254a2ba7e7fd3318b45
I have checked the code again and it is correct. Asked some help from someone else, apparently I had not marked "Internet Permission" in my Processing Sketch..
Thanks for the feedback!
@nvwingh It is not a good idea to publish your API key in public forums.
@koogs or @quark might be kind enough to remove it from your posts for you.
Kf
Done
@kfrajer, thank you for alerting me to this! I will make sure I hide the key in the future. Do you recommend using a Keystore Provider for this? @koogs, thank you for removal.. Best regards
Personally, I will just avoid posting the actual key and then provide detail information about your issue.
Kf
a quick google for that api will show you hundreds of other people's keys. it's probably ok with something like this (the keys are free and read only, the only downside would be rate limiting). if you were using, say, aws where people can run up large amounts of real money by using your key, then i'd worry.
ok, thanks