[ANSWERED] WeatherAPI.com Integration
-
Trying to get weather data into Isadora. How can I get the API info into Isadora. I did the API tutorial from https://www.dusxproductions.co... and that worked great but I don't know how to move to get values such as
"condition": { "text": "Partly cloudy" from the weather.api into the msg from the TCP In Watcher - Text in Isadora. Want to have weather data drive the visuals to trigger rain and clouds, etc.
-
@cjsass-0 said:
weather.api
Hi,
I had a quick look at the specifications for WeatherAPI.com. However, it requires a subscription to access the API. Instead I have accessed the free Archive.org API to demonstrate the use of the Get URL Text and JSON Parser. These are significantly more straight forward when working with API data in my experience.
Best Wishes,
Russell -
@cjsass-0 said:
and that worked great
Does this mean you were able to connect to the Weather API and receive a return message? If you were, then it would be very helpful to see the full returned text. If it is JSON, the JSON actors should allow you to access the different elements, if not, you may need to parse the text with a Text Parser, or JavaScript.
Are you using the "msg:string={00-FF}" message parsing string?
-
I tend to pass the response to a JavaScript actor so I can manipulate it while plucking out the values I care about.
The first bit of business is to get the response into JSON object:
const theContents = JSON.parse(arguments[0]);
All done! Now you can use keys or iterate through arrays from the response.
let theCondition = theContents.condition.text; // assuming your sample is from the root
I do not know if there is an efficiency cost associated, but in my use-case, I need JavaScript to do some "thinking" anyway.
I hope this helps!