# Retrieve data from an online API

**URL:** <https://forum.inductiveautomation.com/t/retrieve-data-from-an-online-api/10324>\
**Category:** Ignition\
**Created:** [August 10, 2015, 11:56am UTC](https://forum.inductiveautomation.com/t/retrieve-data-from-an-online-api/10324 "2015-08-10T11:56:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![LisaCourant](https://avatars.discourse-cdn.com/v4/letter/l/9dc877/32.png) [@LisaCourant](https://forum.inductiveautomation.com/u/LisaCourant)\
**Post date:** [August 10, 2015, 11:56am UTC](https://forum.inductiveautomation.com/t/retrieve-data-from-an-online-api/10324/1 "2015-08-10T11:56:30Z")

</div>

Good morning,

I would like to insert something in my project that allows me to check the weather of a few places, in real time. So I found an API that does that (it is “Open Weather Map”) and that returns data in JSON, XML or HTML.  
The only thing I want is to get the data returned by the API and display it into my Ignition project. But I don’t get how I can do it : scripting something in Python ? Or maybe there’s a component that can display an HTML page ? That would be great, as Open Weather Map can return an HTML page with everything I want : I just need to display it in a corner of one of my project windows.

Thank you in advance! 🙂

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [August 10, 2015, 1:50pm UTC](https://forum.inductiveautomation.com/t/retrieve-data-from-an-online-api/10324/2 "2015-08-10T13:50:35Z")

</div>

Hi Lisa,  
You can do it in Python using the [system.net.httpGet](https://support.inductiveautomation.com/usermanuals/ignition/index.html?system_net_httpget.htm) and [system.net.httpPost](https://support.inductiveautomation.com/usermanuals/ignition/index.html?system_net_httppost.htm) functions. See the examples in the documentation.

Since you can get it in HTML maybe you could also use the web browser module: [marketplace.inductiveautomation. … oduleId=82](http://marketplace.inductiveautomation.com/moduledetail?2&moduleId=82)

Best,

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [August 10, 2015, 4:39pm UTC](https://forum.inductiveautomation.com/t/retrieve-data-from-an-online-api/10324/3 "2015-08-10T16:39:38Z")

</div>

I control my Christmas lights with openweatherdata sun set time. I created this component as an example of how to interact with the api. Most of the code is on the timer.  
[test1\_weather\_2015-08-10\_1038.proj](https://us1.discourse-cdn.com/inductiveautomation/original/2X/b/bfee7976051790def00977e6d650a9aabdde01be.proj) (14.2 KB)

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [August 10, 2015, 6:24pm UTC](https://forum.inductiveautomation.com/t/retrieve-data-from-an-online-api/10324/4 "2015-08-10T18:24:47Z")

</div>

Hi, Lisa.

As Nick suggested, using system.net.httpGet will retrieve the information for you. There is also [systen.util.jsonDecode](https://support.inductiveautomation.com/usermanuals/ignition/system_util_jsondecode.htm) that will take the json string and objectify it to a dictionary. After that it’s just mining the dictionary for what you want.

The following code will display information for three cities (Morenci is where I grew up. It’s always good to know my parents aren’t getting a tornado…)

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/6/60e9e7de6974c847081df48f1114d10cccdefee7.jpg)  

`response = system.net.httpGet('http://api.openweathermap.org/data/2.5/group?id=5002495,2643743,1850147&units=metric')
json=system.util.jsonDecode(response)
for city in json['list']:
  print city['name']+": ", str(city['main']['temp']), city['weather'][0]['description']`

---

<div class="post-metadata">

**Author:** ![LisaCourant](https://avatars.discourse-cdn.com/v4/letter/l/9dc877/32.png) [@LisaCourant](https://forum.inductiveautomation.com/u/LisaCourant)\
**Post date:** [August 11, 2015, 7:57am UTC](https://forum.inductiveautomation.com/t/retrieve-data-from-an-online-api/10324/5 "2015-08-11T07:57:24Z")

</div>

Hi,  
Thanks a lot for all your answers, that will help me for sure!  
Kyle, I can’t open your project because it seems that my designer version is older than yours. Thank you anyway!  
I will try to use these Python functions then 🙂  
Have a nice day!

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [August 11, 2015, 7:50pm UTC](https://forum.inductiveautomation.com/t/retrieve-data-from-an-online-api/10324/6 "2015-08-11T19:50:20Z")

</div>

Hi Lisa,  
Try restoring on a version that is 7.7.5 or later.
