# Climate temperature and rain API

**URL:** <https://discourse.processing.org/t/climate-temperature-and-rain-api/42026>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [May 19, 2023, 12:33am UTC](https://discourse.processing.org/t/climate-temperature-and-rain-api/42026 "2023-05-19T00:33:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![isabela](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/isabela/32/19188_2.png) [@isabela](https://discourse.processing.org/u/isabela)\
**Post date:** [May 19, 2023, 12:33am UTC](https://discourse.processing.org/t/climate-temperature-and-rain-api/42026/1 "2023-05-19T00:33:35Z")

</div>

Hello! I am looking for a simple API for weather forecasts, any suggestions? (also, I am a beginner!)

Thanks,  
Isabela

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [May 19, 2023, 1:01am UTC](https://discourse.processing.org/t/climate-temperature-and-rain-api/42026/2 "2023-05-19T01:01:20Z")

</div>

> [@isabela](#):
>
> simple API for weather forecasts

Hi

> **[p5.js Web Editor](https://editor.p5js.org/titusgloved1/sketches/HJiEyZBkz)**
>
> A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners.

> **[p5.js Web Editor](https://editor.p5js.org/Hepyrian/sketches/LTsOk65c8)**
>
> A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners.

> **[Guides](http://learningprocessing.com/exercises/chp18/exercise-18-17-loadJSON-weather)**

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 20, 2023, 11:02am UTC](https://discourse.processing.org/t/climate-temperature-and-rain-api/42026/3 "2023-05-20T11:02:10Z")

</div>

Hello @isabela,

I was able to generate custom free APIs from this site:

[Free Open-Source Weather API | Open-Meteo.com](https://open-meteo.com/)

Example for _visibility_ and _windspeed_ to get you started:

```auto
// Weather API JSON  
// By: glv
// Date: 2023-5-20
// Ver: 1.0.0

// https://open-meteo.com/en/terms

// Weather data by Open-Meteo.com
// https://open-meteo.com/

JSONObject jsonObj;
JSONArray jsonArr;

String url = "https://api.open-meteo.com/v1/forecast?latitude=52.52&longitude=13.41&hourly=visibility,windspeed_10m&forecast_days=1";

void setup() 
  {
  size(300, 200);
  background(255);
 // https://open-meteo.com/en/terms
  println("Weather data by Open-Meteo.com");
  println("https://open-meteo.com/");
  println();
  
  jsonObj = loadJSONObject(url);
  println(" ***jsonObj keys*** \n", jsonObj.keys());
  println();
  
  JSONObject hourly = jsonObj.getJSONObject("hourly");
  println(" ***hourly keys*** \n", hourly.keys());
  println();
  
  println(" ***hourly*** \n", hourly);
  println();
  
  println(hourly.getJSONArray("time").size());
  printArray(hourly.getJSONArray("time"));
  println();
 
 // https://open-meteo.com/en/terms
 textSize(16);
 fill(255, 0, 0);
 text("Weather data by Open-Meteo.com", 10, 20);
 text("https://open-meteo.com/", 10, 40);
 }

```

> **Console output \< Click to expand!**
>
> ```auto
> Weather data by Open-Meteo.com
> https://open-meteo.com/
> 
> ***jsonObj keys***
> [elevation, hourly_units, generationtime_ms, timezone_abbreviation, timezone, latitude, utc_offset_seconds, hourly, longitude]
> 
> ***hourly keys***
> [visibility, windspeed_10m, time]
> 
> ***hourly***
> {
> "visibility": [
> 24140,
> 24140,
> 24140,
> 24140,
> 24140,
> 24140,
> 24140,
> 24140,
> 24140,
> 24140,
> 24140,
> 24140,
> 24140,
> 24140,
> 24140,
> 24140,
> 24140,
> 24140,
> 24140,
> 24140,
> 24140,
> 24140,
> 24140,
> 24140
> ],
> "windspeed_10m": [
> 8.6,
> 8.4,
> 9.2,
> 9.8,
> 8.6,
> 10.9,
> 10.9,
> 11.6,
> 14.5,
> 16.7,
> 16.2,
> 15.5,
> 16.6,
> 17,
> 17.7,
> 17,
> 17.6,
> 15.9,
> 13.3,
> 10.6,
> 11.4,
> 12,
> 9.9,
> 10.7
> ],
> "time": [
> "2023-05-20T00:00",
> "2023-05-20T01:00",
> "2023-05-20T02:00",
> "2023-05-20T03:00",
> "2023-05-20T04:00",
> "2023-05-20T05:00",
> "2023-05-20T06:00",
> "2023-05-20T07:00",
> "2023-05-20T08:00",
> "2023-05-20T09:00",
> "2023-05-20T10:00",
> "2023-05-20T11:00",
> "2023-05-20T12:00",
> "2023-05-20T13:00",
> "2023-05-20T14:00",
> "2023-05-20T15:00",
> "2023-05-20T16:00",
> "2023-05-20T17:00",
> "2023-05-20T18:00",
> "2023-05-20T19:00",
> "2023-05-20T20:00",
> "2023-05-20T21:00",
> "2023-05-20T22:00",
> "2023-05-20T23:00"
> ]
> }
> 
> 24
> [
> "2023-05-20T00:00",
> "2023-05-20T01:00",
> "2023-05-20T02:00",
> "2023-05-20T03:00",
> "2023-05-20T04:00",
> "2023-05-20T05:00",
> "2023-05-20T06:00",
> "2023-05-20T07:00",
> "2023-05-20T08:00",
> "2023-05-20T09:00",
> "2023-05-20T10:00",
> "2023-05-20T11:00",
> "2023-05-20T12:00",
> "2023-05-20T13:00",
> "2023-05-20T14:00",
> "2023-05-20T15:00",
> "2023-05-20T16:00",
> "2023-05-20T17:00",
> "2023-05-20T18:00",
> "2023-05-20T19:00",
> "2023-05-20T20:00",
> "2023-05-20T21:00",
> "2023-05-20T22:00",
> "2023-05-20T23:00"
> ]
> 
> ```

Resources:

- [https://processing.org/tutorials/data](https://processing.org/tutorials/data)
- [JSONObject / Reference / Processing.org](https://processing.org/reference/JSONObject.html)
- [JSON Javadoc](https://processing.github.io/processing-javadocs/core/processing/data/JSONObject.html)
- [Examples | Learning Processing 2nd Edition](http://learningprocessing.com/examples/) See _Data_ _examples_ and _exercises_

There is a learning curve to all of this and it will take time… take it in steps.

Once you can access and retrieve the data then you can visualize it with additional code.

There rest is up to you and your creativity and imagination!

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/b/5/b581c1c3588e51476d770e50f9b5f0b8d4a1199f.png)

`:)`

---

<div class="post-metadata">

**Author:** ![mcintyre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mcintyre/32/14561_2.png) [@mcintyre](https://discourse.processing.org/u/mcintyre)\
**Post date:** [May 20, 2023, 12:15pm UTC](https://discourse.processing.org/t/climate-temperature-and-rain-api/42026/4 "2023-05-20T12:15:15Z")

</div>

Mind telling us a bit more about the sketch you’d like to create? Happy to help and am curious to know whether you’d like data for a specific location, an entire region, or something else.

---

<div class="post-metadata">

**Author:** ![isabela](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/isabela/32/19188_2.png) [@isabela](https://discourse.processing.org/u/isabela)\
**Post date:** [May 26, 2023, 12:21am UTC](https://discourse.processing.org/t/climate-temperature-and-rain-api/42026/5 "2023-05-26T00:21:17Z")

</div>

Thanks, that helped a lot! 😃  
I was able to run a program with a Brazilian API (where I am from) but I don’t know how I can transform the “printlin” information in graphics on the program (let me know if I made myself clear…)  
Can you help me with that?

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 26, 2023, 5:25pm UTC](https://discourse.processing.org/t/climate-temperature-and-rain-api/42026/6 "2023-05-26T17:25:29Z")

</div>

> [@isabela](#):
>
> I don’t know how I can transform the “printlin” information in graphics on the program

You will first have to extract the data from the JSONArray of interest.

This will extra one of the data elements:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/8/3/83684fea3e726dbcbb8b75f9cb5195023e1136d1.png)

Once you are able to extract the data you can then plot the data or visualize it any way you want.

Try extracting the data in a for loop and plotting points on the screen.

The _time_ may be a challenge but a little research will sort that out.

`:)`
