---
updatedAt: 2025-06-04T20:41:24.000Z
agentTools:
  projectIndex: https://docs.tomorrow.io/llms.txt
---

# Plot Weather Forecast Trends using Node

```node Node
const fetch = require('node-fetch');
const queryString = require('query-string');
const plotlib = require("nodeplotlib");

// get your key from app.tomorrow.io/development/keys
const apikey = "add your API key here"

// pick the location, as a latlong pair
let location = "new york";

// choose the unit system, either metric or imperial
const units = "imperial";

// set the timesteps, like "1m", "1h" and/or "1d"
const timesteps = ["1d"];

// create the query string with the relevant parameters
const weatherForecastParams =  queryString.stringify({
    apikey,
    location,
    units,
    timesteps
}, {arrayFormat: "comma"});

// set the url and fetch options
const getWeatherForecastUrl = "https://api.tomorrow.io/v4/weather/forecast";
const options = {method: 'GET', headers: {accept: 'application/json'}};

async function plotTemperatureForecastTrends() {
  try {
    // request the weather forecast data
    const weatherForecastRes = await fetch(
      `${getWeatherForecastUrl}?${weatherForecastParams}`,
      options
    );
    
    // extract and format the temperature data
    const weatherForecastData = await weatherForecastRes.json();
    const dailyWeatherForecastData = weatherForecastData?.timelines?.daily;
    const temperaturePlots = convertRawDataIntoTempPlots(dailyWeatherForecastData);
    
    // plot the temperature data
    const layout = {
      showlegend: true,
      title: "Temperature Trends in New York Over the Next 5 Days",
      xaxis: {
        title: "Date",
        type: "date",
      },
      yaxis: {
        title: "Temperature (°F)",
        type: "linear",
      },
    };
    plotlib.plot(temperaturePlots, layout);
    
  } catch (e) {
    
    console.error("error:" + e);
    
  }
}

function convertRawDataIntoTempPlots(rawData) {
  const maxTemperatures = [];
  const minTemperatures = [];
  const avgTemperatures = [];
  const timeStamps = [];
	
  // aggregate the data per day into arrays of data
  rawData.forEach((d) => {
    timeStamps.push(d.time);
    maxTemperatures.push(d.values.temperatureMax);
    minTemperatures.push(d.values.temperatureMin);
    avgTemperatures.push(d.values.temperatureAvg);
  });

  return [
    {
      x: timeStamps,
      y: maxTemperatures,
      type: "line",
      name: "Max Temp",
    },
    {
      x: timeStamps,
      y: minTemperatures,
      type: "line",
      name: "Min Temp",
    },
    {
      x: timeStamps,
      y: avgTemperatures,
      type: "line",
      name: "Avg Temp",
    },
  ];
}

plotTemperatureForecastTrends();


```

```json Response Example
// example weather forecast response
{
  "timelines": {
    "daily": [
      {
        "time": "2023-06-06T00:00:00Z",
        "values": {
          "cloudBaseAvg": 0.76,
          "cloudBaseMax": 2.67,
          "cloudBaseMin": 0,
          "cloudCeilingAvg": 0.14,
          "cloudCeilingMax": 1.06,
          "cloudCeilingMin": 0,
          "cloudCoverAvg": 39.09,
          "cloudCoverMax": 100,
          "cloudCoverMin": 0,
          "dewPointAvg": 45.28,
          "dewPointMax": 51.58,
          "dewPointMin": 41.68,
          "evapotranspirationAvg": 0.01,
          "evapotranspirationMax": 0.025,
          "evapotranspirationMin": 0.002,
          "evapotranspirationSum": 0.234,
          "freezingRainIntensityAvg": 0,
          "freezingRainIntensityMax": 0,
          "freezingRainIntensityMin": 0,
          "humidityAvg": 45.44,
          "humidityMax": 64.36,
          "humidityMin": 29.27,
          "iceAccumulationAvg": 0,
          "iceAccumulationLweAvg": 0,
          "iceAccumulationLweMax": 0,
          "iceAccumulationLweMin": 0,
          "iceAccumulationLweSum": 0,
          "iceAccumulationMax": 0,
          "iceAccumulationMin": 0,
          "iceAccumulationSum": 0,
          "moonriseTime": "2023-06-06T02:33:52Z",
          "moonsetTime": "2023-06-06T11:23:59Z",
          "precipitationProbabilityAvg": 0,
          "precipitationProbabilityMax": 0,
          "precipitationProbabilityMin": 0,
          "pressureSurfaceLevelAvg": 29.68,
          "pressureSurfaceLevelMax": 29.76,
          "pressureSurfaceLevelMin": 29.55,
          "rainAccumulationAvg": 0,
          "rainAccumulationLweAvg": 0,
          "rainAccumulationLweMax": 0,
          "rainAccumulationLweMin": 0,
          "rainAccumulationMax": 0,
          "rainAccumulationMin": 0,
          "rainAccumulationSum": 0,
          "rainIntensityAvg": 0,
          "rainIntensityMax": 0,
          "rainIntensityMin": 0,
          "sleetAccumulationAvg": 0,
          "sleetAccumulationLweAvg": 0,
          "sleetAccumulationLweMax": 0,
          "sleetAccumulationLweMin": 0,
          "sleetAccumulationLweSum": 0,
          "sleetAccumulationMax": 0,
          "sleetAccumulationMin": 0,
          "sleetIntensityAvg": 0,
          "sleetIntensityMax": 0,
          "sleetIntensityMin": 0,
          "snowAccumulationAvg": 0,
          "snowAccumulationLweAvg": 0,
          "snowAccumulationLweMax": 0,
          "snowAccumulationLweMin": 0,
          "snowAccumulationLweSum": 0,
          "snowAccumulationMax": 0,
          "snowAccumulationMin": 0,
          "snowAccumulationSum": 0,
          "snowDepthAvg": 0,
          "snowDepthMax": 0,
          "snowDepthMin": 0,
          "snowDepthSum": 0,
          "snowIntensityAvg": 0,
          "snowIntensityMax": 0,
          "snowIntensityMin": 0,
          "sunriseTime": "2023-06-05T09:39:00Z",
          "sunsetTime": "2023-06-06T00:09:00Z",
          "temperatureApparentAvg": 68.54,
          "temperatureApparentMax": 78.71,
          "temperatureApparentMin": 56.71,
          "temperatureAvg": 68.54,
          "temperatureMax": 78.71,
          "temperatureMin": 56.71,
          "uvHealthConcernAvg": 0,
          "uvHealthConcernMax": 1,
          "uvHealthConcernMin": 0,
          "uvIndexAvg": 1,
          "uvIndexMax": 2,
          "uvIndexMin": 0,
          "visibilityAvg": 9.01,
          "visibilityMax": 9.94,
          "visibilityMin": 4.57,
          "weatherCodeMax": 1100,
          "weatherCodeMin": 1100,
          "windDirectionAvg": 262.84,
          "windGustAvg": 14.7,
          "windGustMax": 28.23,
          "windGustMin": 3.78,
          "windSpeedAvg": 7.81,
          "windSpeedMax": 14.51,
          "windSpeedMin": 0.42
        }
      },
      {
        "time": "2023-06-07T00:00:00Z",
        "values": {
          "cloudBaseAvg": 0.59,
          "cloudBaseMax": 4.78,
          "cloudBaseMin": 0,
          "cloudCeilingAvg": 0,
          "cloudCeilingMax": 0,
          "cloudCeilingMin": 0,
          "cloudCoverAvg": 26.21,
          "cloudCoverMax": 100,
          "cloudCoverMin": 0,
          "dewPointAvg": 46.01,
          "dewPointMax": 49.45,
          "dewPointMin": 43.25,
          "evapotranspirationAvg": 0.009,
          "evapotranspirationMax": 0.023,
          "evapotranspirationMin": 0.002,
          "evapotranspirationSum": 0.219,
          "freezingRainIntensityAvg": 0,
          "freezingRainIntensityMax": 0,
          "freezingRainIntensityMin": 0,
          "humidityAvg": 55,
          "humidityMax": 76.75,
          "humidityMin": 35.34,
          "iceAccumulationAvg": 0,
          "iceAccumulationLweAvg": 0,
          "iceAccumulationLweMax": 0,
          "iceAccumulationLweMin": 0,
          "iceAccumulationLweSum": 0,
          "iceAccumulationMax": 0,
          "iceAccumulationMin": 0,
          "iceAccumulationSum": 0,
          "moonriseTime": "2023-06-07T03:27:45Z",
          "moonsetTime": "2023-06-07T12:38:53Z",
          "precipitationProbabilityAvg": 0,
          "precipitationProbabilityMax": 0,
          "precipitationProbabilityMin": 0,
          "pressureSurfaceLevelAvg": 29.63,
          "pressureSurfaceLevelMax": 29.66,
          "pressureSurfaceLevelMin": 29.59,
          "rainAccumulationAvg": 0,
          "rainAccumulationLweAvg": 0,
          "rainAccumulationLweMax": 0,
          "rainAccumulationLweMin": 0,
          "rainAccumulationMax": 0,
          "rainAccumulationMin": 0,
          "rainAccumulationSum": 0,
          "rainIntensityAvg": 0,
          "rainIntensityMax": 0,
          "rainIntensityMin": 0,
          "sleetAccumulationAvg": 0,
          "sleetAccumulationLweAvg": 0,
          "sleetAccumulationLweMax": 0,
          "sleetAccumulationLweMin": 0,
          "sleetAccumulationLweSum": 0,
          "sleetAccumulationMax": 0,
          "sleetAccumulationMin": 0,
          "sleetIntensityAvg": 0,
          "sleetIntensityMax": 0,
          "sleetIntensityMin": 0,
          "snowAccumulationAvg": 0,
          "snowAccumulationLweAvg": 0,
          "snowAccumulationLweMax": 0,
          "snowAccumulationLweMin": 0,
          "snowAccumulationLweSum": 0,
          "snowAccumulationMax": 0,
          "snowAccumulationMin": 0,
          "snowAccumulationSum": 0,
          "snowDepthAvg": 0,
          "snowDepthMax": 0,
          "snowDepthMin": 0,
          "snowDepthSum": 0,
          "snowIntensityAvg": 0,
          "snowIntensityMax": 0,
          "snowIntensityMin": 0,
          "sunriseTime": "2023-06-06T09:39:00Z",
          "sunsetTime": "2023-06-07T00:10:00Z",
          "temperatureApparentAvg": 64.23,
          "temperatureApparentMax": 73.18,
          "temperatureApparentMin": 52.51,
          "temperatureAvg": 64.23,
          "temperatureMax": 73.18,
          "temperatureMin": 52.51,
          "uvHealthConcernAvg": 0,
          "uvHealthConcernMax": 1,
          "uvHealthConcernMin": 0,
          "uvIndexAvg": 1,
          "uvIndexMax": 3,
          "uvIndexMin": 0,
          "visibilityAvg": 9.32,
          "visibilityMax": 9.94,
          "visibilityMin": 4.62,
          "weatherCodeMax": 1000,
          "weatherCodeMin": 1000,
          "windDirectionAvg": 282.87,
          "windGustAvg": 13.08,
          "windGustMax": 20.73,
          "windGustMin": 5.32,
          "windSpeedAvg": 8.16,
          "windSpeedMax": 10.77,
          "windSpeedMin": 5.1
        }
      },
      {
        "time": "2023-06-08T00:00:00Z",
        "values": {
          "cloudBaseAvg": 0.76,
          "cloudBaseMax": 2.71,
          "cloudBaseMin": 0,
          "cloudCeilingAvg": 0.38,
          "cloudCeilingMax": 3.55,
          "cloudCeilingMin": 0,
          "cloudCoverAvg": 22.92,
          "cloudCoverMax": 91.41,
          "cloudCoverMin": 0,
          "dewPointAvg": 48.83,
          "dewPointMax": 54.34,
          "dewPointMin": 44.23,
          "evapotranspirationAvg": 0.009,
          "evapotranspirationMax": 0.023,
          "evapotranspirationMin": 0.001,
          "evapotranspirationSum": 0.208,
          "freezingRainIntensityAvg": 0,
          "freezingRainIntensityMax": 0,
          "freezingRainIntensityMin": 0,
          "humidityAvg": 60.53,
          "humidityMax": 81.96,
          "humidityMin": 38.27,
          "iceAccumulationAvg": 0,
          "iceAccumulationLweAvg": 0,
          "iceAccumulationLweMax": 0,
          "iceAccumulationLweMin": 0,
          "iceAccumulationLweSum": 0,
          "iceAccumulationMax": 0,
          "iceAccumulationMin": 0,
          "iceAccumulationSum": 0,
          "moonriseTime": "2023-06-08T04:11:16Z",
          "moonsetTime": "2023-06-08T13:57:39Z",
          "precipitationProbabilityAvg": 0.2,
          "precipitationProbabilityMax": 5,
          "precipitationProbabilityMin": 0,
          "pressureSurfaceLevelAvg": 29.66,
          "pressureSurfaceLevelMax": 29.7,
          "pressureSurfaceLevelMin": 29.62,
          "rainAccumulationAvg": 0,
          "rainAccumulationLweAvg": 0,
          "rainAccumulationLweMax": 0,
          "rainAccumulationLweMin": 0,
          "rainAccumulationMax": 0,
          "rainAccumulationMin": 0,
          "rainAccumulationSum": 0,
          "rainIntensityAvg": 0,
          "rainIntensityMax": 0,
          "rainIntensityMin": 0,
          "sleetAccumulationAvg": 0,
          "sleetAccumulationLweAvg": 0,
          "sleetAccumulationLweMax": 0,
          "sleetAccumulationLweMin": 0,
          "sleetAccumulationLweSum": 0,
          "sleetAccumulationMax": 0,
          "sleetAccumulationMin": 0,
          "sleetIntensityAvg": 0,
          "sleetIntensityMax": 0,
          "sleetIntensityMin": 0,
          "snowAccumulationAvg": 0,
          "snowAccumulationLweAvg": 0,
          "snowAccumulationLweMax": 0,
          "snowAccumulationLweMin": 0,
          "snowAccumulationLweSum": 0,
          "snowAccumulationMax": 0,
          "snowAccumulationMin": 0,
          "snowAccumulationSum": 0,
          "snowIntensityAvg": 0,
          "snowIntensityMax": 0,
          "snowIntensityMin": 0,
          "sunriseTime": "2023-06-07T09:39:00Z",
          "sunsetTime": "2023-06-08T00:10:00Z",
          "temperatureApparentAvg": 63.37,
          "temperatureApparentMax": 70.86,
          "temperatureApparentMin": 54.46,
          "temperatureAvg": 63.37,
          "temperatureMax": 70.86,
          "temperatureMin": 54.46,
          "uvHealthConcernAvg": 0,
          "uvHealthConcernMax": 1,
          "uvHealthConcernMin": 0,
          "uvIndexAvg": 1,
          "uvIndexMax": 4,
          "uvIndexMin": 0,
          "visibilityAvg": 9.94,
          "visibilityMax": 9.94,
          "visibilityMin": 9.94,
          "weatherCodeMax": 1000,
          "weatherCodeMin": 1000,
          "windDirectionAvg": 97.94,
          "windGustAvg": 14.32,
          "windGustMax": 22.66,
          "windGustMin": 7.82,
          "windSpeedAvg": 7.81,
          "windSpeedMax": 13.68,
          "windSpeedMin": 4.01
        }
      },
      {
        "time": "2023-06-09T00:00:00Z",
        "values": {
          "cloudBaseAvg": 1.11,
          "cloudBaseMax": 2.64,
          "cloudBaseMin": 0,
          "cloudCeilingAvg": 0.98,
          "cloudCeilingMax": 2.49,
          "cloudCeilingMin": 0,
          "cloudCoverAvg": 54.42,
          "cloudCoverMax": 100,
          "cloudCoverMin": 0,
          "dewPointAvg": 47.42,
          "dewPointMax": 55.32,
          "dewPointMin": 38.83,
          "evapotranspirationAvg": 0.006,
          "evapotranspirationMax": 0.019,
          "evapotranspirationMin": 0.001,
          "evapotranspirationSum": 0.135,
          "freezingRainIntensityAvg": 0,
          "freezingRainIntensityMax": 0,
          "freezingRainIntensityMin": 0,
          "humidityAvg": 63.09,
          "humidityMax": 88.98,
          "humidityMin": 34.08,
          "iceAccumulationAvg": 0,
          "iceAccumulationLweAvg": 0,
          "iceAccumulationLweMax": 0,
          "iceAccumulationLweMin": 0,
          "iceAccumulationLweSum": 0,
          "iceAccumulationMax": 0,
          "iceAccumulationMin": 0,
          "iceAccumulationSum": 0,
          "moonriseTime": "2023-06-09T04:47:14Z",
          "moonsetTime": "2023-06-09T15:14:52Z",
          "precipitationProbabilityAvg": 0,
          "precipitationProbabilityMax": 0,
          "precipitationProbabilityMin": 0,
          "pressureSurfaceLevelAvg": 29.71,
          "pressureSurfaceLevelMax": 29.75,
          "pressureSurfaceLevelMin": 29.66,
          "rainAccumulationAvg": 0,
          "rainAccumulationLweAvg": 0,
          "rainAccumulationLweMax": 0,
          "rainAccumulationLweMin": 0,
          "rainAccumulationMax": 0,
          "rainAccumulationMin": 0,
          "rainAccumulationSum": 0,
          "rainIntensityAvg": 0,
          "rainIntensityMax": 0,
          "rainIntensityMin": 0,
          "sleetAccumulationAvg": 0,
          "sleetAccumulationLweAvg": 0,
          "sleetAccumulationLweMax": 0,
          "sleetAccumulationLweMin": 0,
          "sleetAccumulationLweSum": 0,
          "sleetAccumulationMax": 0,
          "sleetAccumulationMin": 0,
          "sleetIntensityAvg": 0,
          "sleetIntensityMax": 0,
          "sleetIntensityMin": 0,
          "snowAccumulationAvg": 0,
          "snowAccumulationLweAvg": 0,
          "snowAccumulationLweMax": 0,
          "snowAccumulationLweMin": 0,
          "snowAccumulationLweSum": 0,
          "snowAccumulationMax": 0,
          "snowAccumulationMin": 0,
          "snowAccumulationSum": 0,
          "snowIntensityAvg": 0,
          "snowIntensityMax": 0,
          "snowIntensityMin": 0,
          "sunriseTime": "2023-06-08T09:39:00Z",
          "sunsetTime": "2023-06-09T00:11:00Z",
          "temperatureApparentAvg": 61.78,
          "temperatureApparentMax": 68.45,
          "temperatureApparentMin": 54.33,
          "temperatureAvg": 61.78,
          "temperatureMax": 68.45,
          "temperatureMin": 54.33,
          "uvHealthConcernAvg": 0,
          "uvHealthConcernMax": 1,
          "uvHealthConcernMin": 0,
          "uvIndexAvg": 1,
          "uvIndexMax": 4,
          "uvIndexMin": 0,
          "visibilityAvg": 12.17,
          "visibilityMax": 15,
          "visibilityMin": 9.94,
          "weatherCodeMax": 1001,
          "weatherCodeMin": 1001,
          "windDirectionAvg": 159.62,
          "windGustAvg": 8.56,
          "windGustMax": 10.92,
          "windGustMin": 3.14,
          "windSpeedAvg": 5.21,
          "windSpeedMax": 6.82,
          "windSpeedMin": 1.56
        }
      },
      {
        "time": "2023-06-10T00:00:00Z",
        "values": {
          "cloudBaseAvg": 1.28,
          "cloudBaseMax": 1.51,
          "cloudBaseMin": 1.05,
          "cloudCeilingAvg": 0.54,
          "cloudCeilingMax": 2.23,
          "cloudCeilingMin": 0,
          "cloudCoverAvg": 62.07,
          "cloudCoverMax": 100,
          "cloudCoverMin": 11.12,
          "dewPointAvg": 45.93,
          "dewPointMax": 47.51,
          "dewPointMin": 44.82,
          "evapotranspirationAvg": 0.007,
          "evapotranspirationMax": 0.023,
          "evapotranspirationMin": 0.002,
          "evapotranspirationSum": 0.172,
          "freezingRainIntensityAvg": 0,
          "freezingRainIntensityMax": 0,
          "freezingRainIntensityMin": 0,
          "humidityAvg": 51.5,
          "humidityMax": 69.28,
          "humidityMin": 35.65,
          "iceAccumulationAvg": 0,
          "iceAccumulationLweAvg": 0,
          "iceAccumulationLweMax": 0,
          "iceAccumulationLweMin": 0,
          "iceAccumulationLweSum": 0,
          "iceAccumulationMax": 0,
          "iceAccumulationMin": 0,
          "iceAccumulationSum": 0,
          "moonriseTime": "2023-06-10T05:16:39Z",
          "moonsetTime": "2023-06-10T16:30:59Z",
          "precipitationProbabilityAvg": 0.4,
          "precipitationProbabilityMax": 5,
          "precipitationProbabilityMin": 0,
          "pressureSurfaceLevelAvg": 29.74,
          "pressureSurfaceLevelMax": 29.78,
          "pressureSurfaceLevelMin": 29.69,
          "rainAccumulationAvg": 0,
          "rainAccumulationLweAvg": 0,
          "rainAccumulationLweMax": 0,
          "rainAccumulationLweMin": 0,
          "rainAccumulationMax": 0,
          "rainAccumulationMin": 0,
          "rainAccumulationSum": 0,
          "rainIntensityAvg": 0,
          "rainIntensityMax": 0,
          "rainIntensityMin": 0,
          "sleetAccumulationAvg": 0,
          "sleetAccumulationLweAvg": 0,
          "sleetAccumulationLweMax": 0,
          "sleetAccumulationLweMin": 0,
          "sleetAccumulationLweSum": 0,
          "sleetAccumulationMax": 0,
          "sleetAccumulationMin": 0,
          "sleetIntensityAvg": 0,
          "sleetIntensityMax": 0,
          "sleetIntensityMin": 0,
          "snowAccumulationAvg": 0,
          "snowAccumulationLweAvg": 0,
          "snowAccumulationLweMax": 0,
          "snowAccumulationLweMin": 0,
          "snowAccumulationLweSum": 0,
          "snowAccumulationMax": 0,
          "snowAccumulationMin": 0,
          "snowAccumulationSum": 0,
          "snowIntensityAvg": 0,
          "snowIntensityMax": 0,
          "snowIntensityMin": 0,
          "sunriseTime": "2023-06-09T09:39:00Z",
          "sunsetTime": "2023-06-10T00:11:00Z",
          "temperatureApparentAvg": 65.17,
          "temperatureApparentMax": 74.47,
          "temperatureApparentMin": 56.01,
          "temperatureAvg": 65.17,
          "temperatureMax": 74.47,
          "temperatureMin": 56.01,
          "uvHealthConcernAvg": 0,
          "uvHealthConcernMax": 0,
          "uvHealthConcernMin": 0,
          "uvIndexAvg": 0,
          "uvIndexMax": 1,
          "uvIndexMin": 0,
          "visibilityAvg": 14.97,
          "visibilityMax": 15,
          "visibilityMin": 14.36,
          "weatherCodeMax": 1101,
          "weatherCodeMin": 1101,
          "windDirectionAvg": 302.52,
          "windGustAvg": 16.26,
          "windGustMax": 22.02,
          "windGustMin": 7.12,
          "windSpeedAvg": 9.19,
          "windSpeedMax": 12.76,
          "windSpeedMin": 5.66
        }
      }
    ]
  },
  "location": {
    "lat": 40.71272659301758,
    "lon": -74.00601196289062,
    "name": "City of New York, New York, United States",
    "type": "administrative"
  }
}
```

# Introduction



**With our Weather Forecast endpoint you can retrieve forecast data by minute, hour, and/or day for any location with just a single API call**

The response values for each time set (`minutely`, `hourly`, and `daily`) will vary according to the relevance. For example, the values per minute and per hour will include a temperature for each minute/hour, whereas the values per day will include the maximum, minimum, and average temperatures for each day.

In this guide, we'll walk you through retrieving daily forecast data for New York with a GET call. After retrieving the data, we will extract the relevant maximum, minimum, and average temperatures for each day and plot them in a graph to visualize temperatures trends over the next 5 days.

# Install and import relevant packages

<!-- node@1-3 -->

To plot the data you can use a 3rd party library. In this guide we will use nodeplotlib.

# Get your key

<!-- node@5-6 -->

Before we begin, make sure to [signup to our platform](https://www.tomorrow.io/weather-api/) and, once logged in, [grab your key](https://app.tomorrow.io/development/keys).

# Pick the location

<!-- node@8-9 -->

In this type of call, we support multiple location types:

- Latitude and Longitude (Decimal degree) `location=42.3478, -71.0466`
- City name `location=new york`
- US zip `location=10001`
- UK postcode `location=SW1`
- Canada postal code `location=G2J`

You can change these per query dynamically, though we chose to only get the weather data for New York.

# Choose the unit system

<!-- node@11-12 -->

You can select either the imperial or metric unit system. This applies to all of the fields in the query. The default unit value is metric, however in the US the common system is imperial consisting of units such as the inch, the mile, and the pound - so that's our choice.

The Weather Forecast response payload is lean, flat, and language-agnostic by-design, containing only the raw field values as numbers, enums, or [ISO-8601 timestamps](https://docs.tomorrow.io/reference/api-formats#date-and-time). This allows our developers to use it on mobile devices and translate the [field units' representative strings](https://docs.tomorrow.io/reference/weather-data-layers#field-descriptors) to the language of their choice.

# Set the timesteps

<!-- node@14-15 -->

The Weather Forecast endpoint allows you to request multiple timesteps with one call.

Any of the following values are supported to choose the interval for which the data is provided: `1m`, `1h`, and `1d`.

The minute-by-minute forecasts will provide data per minute for the next 60 minutes, the hourly forecasts will provide data per hour for the next 120 hours, and the daily forecasts will provide data per day for the next 5 days.

The default timestep value is all 3 options, but in this recipe we'll get just the daily data. You can change this field to get multiple timesteps at once and update it dynamically according to your specific needs.

# Request the weather forecast data

<!-- node@17-27,31-34 -->

Send the call to fetch the Weather Forecast data with the relevant parameters in a query string.

The only required parameter is the location, any other unset parameter will use the default value.

# Extract and format the relevant data from the response

<!-- node@37-40,61-95 -->

In this guide we will extract the `daily` data, and specifically the `temperatureMax`, `temperatureMin`, and `temperatureAvg`, from each day's data set. We will then format the data to be plotted on a graph, grouping all values from the same data field together in an array and creating plot objects with the group time stamps as the x-axis and the grouped data field data as the y-axis.

Remember, these fields will not exist on the by minute and hour timesets, so if you prefer to look at those temperature trends on those scales, you would refer to the `temperature` field instead.

There are also many other interesting data fields returned from the Weather Forecast API. You can find the full list [here](https://docs.tomorrow.io/reference/data-layers-core#data-fields).

# Plot the data on a graph and visualize the results

<!-- node@42-55 -->

Use the plotting library to plot the formatted data and visualize the results.