### Constructing Historical Weather API URL (Text) Source: https://www.visualcrossing.com/resources/documentation/weather-api/building-and-running-your-first-weather-api-query This example demonstrates the construction of a historical weather API query URL by appending location, date range, and API key to the base endpoint. It requires the base URL, location, start date, end date, and an API key. ```text https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/Paris/2020-1-1/2020-2-1?key=1234567890 ``` -------------------------------- ### Evapotranspiration Elements Example Source: https://www.visualcrossing.com/resources/documentation/weather-data/weather-data-documentation This example shows how to retrieve reference evapotranspiration (ET0) data, calculated using the Penman-Monteith method. This is crucial for understanding water loss from soil and plants. ```text &elements=datetime,et0 ``` -------------------------------- ### Soil Moisture Elements Example Source: https://www.visualcrossing.com/resources/documentation/weather-data/weather-data-documentation This example demonstrates how to request both volumetric and depth-based soil moisture data at various soil depths. It's useful for irrigation management and hydrological studies. ```text &elements=datetime,soilmoisture01,soilmoisture04,soilmoisture10,soilmoisture20,soilmoisturevol01,soilmoisturevol04,soilmoisturevol10,soilmoisturevol20 ``` -------------------------------- ### Wet Bulb and Delta T Elements Example Source: https://www.visualcrossing.com/resources/documentation/weather-data/weather-data-documentation This example demonstrates how to obtain wet-bulb temperature and delta T (the difference between dry-bulb and wet-bulb temperatures). These metrics are important for human comfort, heat stress, and industrial processes. ```text &elements=datetime,temp,tempwet,deltat ``` -------------------------------- ### Soil Temperature Elements Example Source: https://www.visualcrossing.com/resources/documentation/weather-data/weather-data-documentation This example illustrates how to query soil temperature data at different depths using the Visual Crossing Weather API. It includes the datetime and various soil temperature elements. ```text &elements=datetime,temp,soiltemp01,soiltemp04,soiltemp10,soiltemp20 ``` -------------------------------- ### Air Quality Elements Example Source: https://www.visualcrossing.com/resources/documentation/weather-data/weather-data-documentation This example demonstrates how to request air quality data, including AQI indices and particulate matter concentrations, using the Visual Crossing Weather API. It specifies the desired elements and their temporal resolution. ```text &elements=datetime,pm1,pm2p5,pm10,o3,no2,so2,co,aqius,aqieur ``` -------------------------------- ### Example JSON Reflectivity Data Source: https://www.visualcrossing.com/resources/documentation/weather-data/how-to-include-weather-radar-data-in-weather-datasets Example output of JSON data including current conditions, showing precip, precipremote, and reflectivity values. ```JSON { ... "currentConditions": { "datetime": "13:00:00", "precip": 0.012, "precipremote": 0, "reflectivity": 30.75, } ... } ``` -------------------------------- ### Fetch Weather Data - Go Source: https://www.visualcrossing.com/resources/documentation/weather-api/visual-crossing-weather-api-libraries Shows how to initialize a weather instance with an API key and URL, fetch weather data for a given location and date range, and print the retrieved weather data structure. ```go weatherInstance, err := weather.NewWeather("https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline", "Your API Key") weather.FetchWeatherData("38.95,-95.664", "2024-01-01", '2024-01-12', include='hours') weather.PrintStruct(weatherInstance.GetWeatherData(), "") ``` -------------------------------- ### GET /timeline/{location}/{startDate}/{period} Source: https://www.visualcrossing.com/resources/documentation/weather-api/using-the-time-period-parameter-to-specify-dynamic-dates-for-weather-api-requests This endpoint allows combining a fixed start date with a dynamic period to define the end date of the query. This is useful for creating queries that start on a specific historical date and extend into the future for a dynamic number of days. ```APIDOC ## GET /timeline/{location}/{startDate}/{period} ### Description Combines a fixed start date with a dynamic period to define the end date of the query. This allows for queries starting on a specific historical date and extending into the future for a dynamic number of days. ### Method GET ### Endpoint `https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/{location}/{startDate}/{period}` ### Parameters #### Path Parameters - **location** (string) - Required - The location for which to retrieve weather data (e.g., `London,UK`). - **startDate** (string) - Required - The fixed start date for the query in `YYYY-MM-DD` format (e.g., `2022-02-01`). - **period** (string) - Required - The dynamic time period defining the end date of the query (e.g., `next5days`). #### Query Parameters - **unitGroup** (string) - Optional - The unit group for the data (e.g., `us`, `metric`). - **key** (string) - Required - Your unique API key. ### Request Example ``` https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/London,UK/2022-02-01/next5days?unitGroup=us&key=YOUR_API_KEY ``` ### Response #### Success Response (200) - **weather** (array) - An array of weather data objects for each day/hour within the specified period. - **location** (object) - Information about the queried location. #### Response Example ```json { "weather": [ { "date": "2022-02-01", "tempmax": 9.5, "tempmin": 3.1, "conditions": "Rainy" }, { "date": "2022-02-02", "tempmax": 10.2, "tempmin": 4.0, "conditions": "Partly cloudy" } // ... more weather data ], "location": { "name": "London, UK", "latitude": 51.5074, "longitude": -0.1278 } } ``` ``` -------------------------------- ### Retrieve Historical Forecast Data with forecastBasisDay Source: https://www.visualcrossing.com/resources/documentation/weather-data/how-to-query-weather-forecasts-from-the-past-historical-forecasts This API call retrieves historical forecast data, using the `forecastBasisDay` parameter to specify the forecast day relative to the query's start date. For example, a `forecastBasisDay` of 0 is equivalent to using the `forecastBasisDate` set to the query's start date. This parameter allows for quick retrieval of forecasts from a specific number of days prior. ```HTTP https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/London,UK/2023-05-01/2023-05-15?unitGroup=us&key=YOUR_API_KEY&include=days**&forecastBasisDay=0** ``` -------------------------------- ### Query API Overview Source: https://www.visualcrossing.com/resources/documentation/weather-data/getting-started-with-weather-data-services Overview of the Query API functionality, which allows users to build and execute data queries through a URL builder interface. ```APIDOC ## Query API ### Description The Query API allows users to construct and execute data queries. It functions as a Query Builder for both URL and API users, offering options to generate queries and view raw data results. ### Key Features: - **Documentation Buttons**: Provide links to API documentation for building and utilizing queries. - **Base Query**: Generates an HTTPS query string for GET, POST, and ODATA scenarios, which can be copied and used in various web-enabled systems. - **Open Query in New Window**: Allows users to preview raw data results in a new browser tab. - **More Query Options**: Exposes advanced options such as unit selection and data format (CSV/JSON). - **API Key**: For paid users, an API key can be used for automated, authenticated queries without needing to log in. - **Session Token**: Users without API privileges can use base queries with a temporary session token for data access. ``` -------------------------------- ### Combine Dynamic Periods: Last 7 Days and Next 5 Days Source: https://www.visualcrossing.com/resources/documentation/weather-api/using-the-time-period-parameter-to-specify-dynamic-dates-for-weather-api-requests This example shows how to combine two dynamic time periods: 'last7days' for the start date and 'next5days' for the end date. This creates a query that spans past and future dates relative to the current date. The first period defines the start, and the second defines the end. ```http https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/London,UK/last7days/next5days?unitGroup=us&key=YOUR_API_KEY ``` -------------------------------- ### GET /timeline/location/startDate/endDate Source: https://www.visualcrossing.com/resources/documentation/weather-api/how-to-replace-the-dark-sky-api Retrieve weather data for a specified date range (start and end dates) for a given location. This can include a mix of historical, standard forecast, and statistical forecast data. ```APIDIDOC ## GET /timeline/location/startDate/endDate ### Description Retrieve weather data for a specified date range (start and end dates) for a given location. This can include a mix of historical, standard forecast, and statistical forecast data. ### Method GET ### Endpoint `https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline///?key=` ### Parameters #### Query Parameters - **key** (string) - Required - Your Visual Crossing API key. #### Path Parameters - **location** (string) - Required - The location for which to retrieve weather data (e.g., "Washington,DC"). - **startDate** (string) - Required - The start date of the range in `YYYY-MM-DD` format. - **endDate** (string) - Required - The end date of the range in `YYYY-MM-DD` format. ### Request Example ``` https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/Washington,DC/2022-7-1/2022-7-31?key= ``` ### Response #### Success Response (200) - **days** (array) - An array containing weather data for each day within the specified range. Each element in the array represents a day's summary and may include an `hours` array with hourly details. - **location** (string) - The requested location. - **querySummary** (object) - Summary of the query performed. #### Response Example ```json { "days": [ { "datetime": "2022-07-01", "tempmax": 88.0, "tempmin": 72.0, "temp": 80.0, "humidity": 55.0, "windspeed": 12.0, "precip": 0.0, "hours": [ { "datetime": "2022-07-01T00:00:00", "temp": 75.0, "humidity": 65.0, "windspeed": 9.0, "precip": 0.0 } ] }, { "datetime": "2022-07-02", "tempmax": 87.0, "tempmin": 71.0, "temp": 79.0, "humidity": 58.0, "windspeed": 11.0, "precip": 0.05, "hours": [ { "datetime": "2022-07-02T00:00:00", "temp": 74.0, "humidity": 68.0, "windspeed": 9.5, "precip": 0.0 } ] } // ... more days up to 2022-07-31 ], "location": "Washington,DC", "querySummary": { "distance": 1.0, "latitude": 38.895, "longitude": -77.036, "resolvedAddress": "Washington, District of Columbia, United States", "address": "Washington,DC" } } ``` ``` -------------------------------- ### Authentication and Access Source: https://www.visualcrossing.com/resources/documentation/weather-data/getting-started-with-weather-data-services Details on how to authenticate API requests using API keys for paid users and the limitations of session-based access for users without API privileges. ```APIDOC ## Authentication and Access ### Description This section details the authentication methods for accessing the Visual Crossing Weather Data API, including the use of API keys for paid subscribers and session-based access for others. ### API Key Authentication - **For Paid Users**: Users with a subscription that supports API usage can obtain an API key from the API Query window. - **Usage**: Include the API key in your automated queries to authenticate automatically, eliminating the need for session-based downloads that require login. ### Session-Based Access - **For Users without API Privileges**: You can copy the Base query text, which embeds a session token instead of an API key. - **Limitations**: This method provides access for a limited, expiring time frame (typically less than 10 minutes, subject to change). - **Embedded Information**: The copied URL contains all query information but uses a session token for authentication. ``` -------------------------------- ### Heating Degree Days Request Source: https://www.visualcrossing.com/resources/documentation/weather-api/degree-day-weather-api This example demonstrates how to request heating degree days. The `degreeDayInverse` parameter is set to `true` for heating degree day calculation. Explicit start and end dates can be set to define the heating season across a year boundary. ```APIDOC ## GET /VisualCrossingWebServices/rest/services/timeline/{location}/last30days ### Description Requests timeline weather data, specifically including heating degree days. ### Method GET ### Endpoint `https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/{location}/last30days` ### Parameters #### Query Parameters - **unitGroup** (string) - Optional - Specifies the unit group (e.g., `us`). - **key** (string) - Required - Your VisualCrossing API key. - **include** (string) - Optional - Elements to include in the response (e.g., `days`). - **elements** (string) - Optional - Specific elements to retrieve (e.g., `datetime,tempmax,tempmin,degreedays,accdegreedays`). - **degreeDayTempBase** (number) - Optional - The base temperature for degree day calculation (default is 50F). - **degreeDayInverse** (boolean) - Optional - Set to `true` to calculate heating degree days. ### Request Example ``` https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/London,UK/last30days?unitGroup=us&key=YOUR_API_KEY&include=days&elements=datetime,tempmax,tempmin,degreedays,accdegreedays°reeDayTempBase=50°reeDayInverse=true ``` ### Response #### Success Response (200) - **days** (array) - An array of day objects, each containing degree day information. - **degreedays** (number) - Calculated degree days for the day. - **accdegreedays** (number) - Accumulated degree days up to the given day. #### Response Example ```json { "latitude" : 38.9697, "longitude" : -77.385, "resolvedAddress" : "Reston, VA, United States", "address" : " Reston,VA", "timezone" : "America/New_York", "tzoffset" : -5, "description":"Cooling down with a chance of rain on Friday.", "days" : [ { "datetime":"2020-11-12", "degreedays":37, "accdegreedays":37, ... } // ... more day objects ] // ... other response fields } ``` ``` -------------------------------- ### Go: Import Packages and Define API Constants Source: https://www.visualcrossing.com/resources/documentation/weather-api/how-to-load-weather-data-using-googles-go-language This snippet sets up the necessary Go packages for making HTTP requests and handling JSON. It also defines constants for the API key and the base endpoint URL for the Visual Crossing Weather API. ```go package main import ( "encoding/json" "fmt" "log" "time" "github.com/go-resty/resty/v2" ) const apiKey = "YOUR_API_KEY" const apiEndpoint = "https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/" ``` -------------------------------- ### GET /timeline/{location}/{period1}/{period2} Source: https://www.visualcrossing.com/resources/documentation/weather-api/using-the-time-period-parameter-to-specify-dynamic-dates-for-weather-api-requests This endpoint allows combining two dynamic periods to define a date range that spans both past and future relative to the current date. The first period determines the start date, and the second period determines the end date. ```APIDOC ## GET /timeline/{location}/{period1}/{period2} ### Description Retrieves weather data by combining two dynamic periods, defining a date range that spans past and future relative to the current date. The first period sets the start date, and the second sets the end date. ### Method GET ### Endpoint `https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/{location}/{period1}/{period2}` ### Parameters #### Path Parameters - **location** (string) - Required - The location for which to retrieve weather data (e.g., `London,UK`). - **period1** (string) - Required - The first dynamic time period, defining the start date of the query (e.g., `last7days`). - **period2** (string) - Required - The second dynamic time period, defining the end date of the query (e.g., `next5days`). #### Query Parameters - **unitGroup** (string) - Optional - The unit group for the data (e.g., `us`, `metric`). - **key** (string) - Required - Your unique API key. ### Request Example ``` https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/London,UK/last7days/next5days?unitGroup=us&key=YOUR_API_KEY ``` ### Response #### Success Response (200) - **weather** (array) - An array of weather data objects for each day/hour within the specified period. - **location** (object) - Information about the queried location. #### Response Example ```json { "weather": [ { "date": "2023-03-13", "tempmax": 12.1, "tempmin": 5.5, "conditions": "Cloudy" }, { "date": "2023-03-14", "tempmax": 13.0, "tempmin": 6.0, "conditions": "Partly cloudy" } // ... more weather data ], "location": { "name": "London, UK", "latitude": 51.5074, "longitude": -0.1278 } } ``` ``` -------------------------------- ### Fetch Weather Data - Java Source: https://www.visualcrossing.com/resources/documentation/weather-api/visual-crossing-weather-api-libraries Provides an example of initializing a WeatherData object, fetching daily weather data for a specified location and date range, and then printing the datetime, max temperature, min temperature, and humidity. ```java // create weather API object with API key WeatherData weatherData = new WeatherData("YOUR_API_KEY"); // fetch weather data with location, from date, to date params. weatherData.fetchWeatherData("38.96%2C-96.02","2020-7-10","2020-7-12","us","events",""); // get daily weather data array list ArrayList weatherDailyData = weatherData.getWeatherDailyData(); if (weatherDailyData != null) { for (WeatherDailyData dailyData : weatherDailyData) { // print max temperature System.out.println(dailyData.getDatetime() + "," + dailyData.getTempMax()); // print min temperature System.out.println(dailyData.getDatetime() + "," + dailyData.getTempMin()); // print humidity System.out.println(dailyData.getDatetime() + "," + dailyData.getHumidity()); } } ``` -------------------------------- ### GET /timeline/{location}/{period} Source: https://www.visualcrossing.com/resources/documentation/weather-api/using-the-time-period-parameter-to-specify-dynamic-dates-for-weather-api-requests This endpoint allows you to retrieve weather data for a specified location using dynamic time periods. The 'period' parameter replaces the need for explicit start and end date parameters, calculating them automatically based on predefined dynamic periods. ```APIDOC ## GET /timeline/{location}/{period} ### Description Retrieves weather data for a specified location using dynamic time periods. The `period` parameter automatically calculates start and end dates. ### Method GET ### Endpoint `https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/{location}/{period}` ### Parameters #### Path Parameters - **location** (string) - Required - The location for which to retrieve weather data (e.g., `London,UK`). - **period** (string) - Required - The dynamic time period for the data request. Must be one of the available time periods (e.g., `next5days`, `last7days`, `today`). #### Query Parameters - **unitGroup** (string) - Optional - The unit group for the data (e.g., `us`, `metric`). - **key** (string) - Required - Your unique API key. ### Request Example ``` https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/London,UK/next5days?unitGroup=us&key=YOUR_API_KEY ``` ### Response #### Success Response (200) - **weather** (array) - An array of weather data objects for each day/hour within the specified period. - **location** (object) - Information about the queried location. - **latitude** (number) - The latitude of the location. - **longitude** (number) - The longitude of the location. #### Response Example ```json { "weather": [ { "date": "2023-03-20", "tempmax": 15.5, "tempmin": 8.2, "conditions": "Partly cloudy" } // ... more weather data ], "location": { "name": "London, UK", "latitude": 51.5074, "longitude": -0.1278 }, "latitude": 51.5074, "longitude": -0.1278 } ``` ``` -------------------------------- ### Daily Weather Forecast Data for all US ZIP Codes Source: https://www.visualcrossing.com/resources/documentation/weather-data/how-to-download-the-weather-forecast-for-all-us-zip-codes This endpoint allows you to download the daily weather forecast data for all US ZIP Codes. It requires a valid API key and offers a 15-day forecast. ```APIDOC ## GET /VisualCrossingWebServices/rest/services/bulkdata/zips ### Description Downloads the daily weather forecast data for all US ZIP Codes. ### Method GET ### Endpoint `https://bulk.visualcrossing.com/VisualCrossingWebServices/rest/services/bulkdata/zips?version=forecast&key=YOUR_API_KEY` ### Parameters #### Query Parameters - **version** (string) - Required - Specifies the data version. Use 'forecast' for the 15-day daily forecast. - **key** (string) - Required - Your Visual Crossing API key. ### Request Example ``` https://bulk.visualcrossing.com/VisualCrossingWebServices/rest/services/bulkdata/zips?version=forecast&key=YOUR_API_KEY ``` ### Response #### Success Response (200) Returns a CSV file containing daily weather forecast data for all US ZIP Codes. #### Response Example (CSV format data will be returned here) ``` -------------------------------- ### Request Weather Data for Next 5 Days Source: https://www.visualcrossing.com/resources/documentation/weather-api/using-the-time-period-parameter-to-specify-dynamic-dates-for-weather-api-requests This example demonstrates how to request weather data for the next 5 days using the 'next5days' time period parameter. This parameter replaces the need for explicit start and end date times. The request is made to the Weather API timeline service. ```http https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/London,UK/next5days?unitGroup=us&key=YOUR_API_KEY ``` -------------------------------- ### Combine Fixed and Dynamic Periods: Specific Date and Next 5 Days Source: https://www.visualcrossing.com/resources/documentation/weather-api/using-the-time-period-parameter-to-specify-dynamic-dates-for-weather-api-requests This example illustrates combining a fixed date ('2022-02-01') with a dynamic period ('next5days'). The fixed date serves as the start date, and the dynamic period defines the end date, allowing for queries that bridge specific historical points with future forecasts. ```http https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/London,UK/2022-02-01/next5days?unitGroup=us&key=YOUR_API_KEY ``` -------------------------------- ### Fetch Weather Data using Go Source: https://www.visualcrossing.com/resources/documentation/weather-api/how-to-load-weather-data-using-googles-go-language This section details how to fetch weather data from the Visual Crossing Timeline API using Go. It includes a sample code that utilizes the `net/http` package and the `encoding/json` library for parsing responses. The example demonstrates setting query parameters for location, date range, and API key. ```APIDOC ## GET /VisualCrossingWebServices/rest/services/timeline/ ### Description Fetches weather data for a specified location and date range from the Visual Crossing Timeline API. ### Method GET ### Endpoint `https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/` ### Parameters #### Query Parameters - **key** (string) - Required - Your Visual Crossing API key. - **location** (string) - Required - The location for which to fetch weather data (e.g., "New York, NY"). - **startDate** (string) - Required - The start date for the weather data in YYYY-MM-DD format. - **endDate** (string) - Required - The end date for the weather data in YYYY-MM-DD format. ### Request Example ```go package main import ( "encoding/json" "fmt" "log" "time" "github.com/go-resty/resty/v2" ) const apiKey = "YOUR_API_KEY" const apiEndpoint = "https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/" type WeatherResponse struct { Days []struct { Date string `json:"datetimeStr"` Temperature float64 Precipitation float64 // Add more fields as needed } `json:"days"` } func main() { location := "New York, NY" startDate := time.Now().Format("2006-01-01") endDate := time.Now().Format("2006-01-03") client := resty.New() resp, err := client.R(). SetQueryParam("key", apiKey). SetQueryParam("location", location). SetQueryParam("startDate", startDate). SetQueryParam("endDate", endDate). SetHeader("Content-Type", "application/json"). Get(apiEndpoint) if err != nil { log.Fatalf("Error making request: %v", err) } if resp.StatusCode() != 200 { log.Fatalf("Error: %v", resp) } var weatherData WeatherResponse err = json.Unmarshal(resp.Body(), &weatherData) if err != nil { log.Fatalf("Error decoding JSON response: %v", err) } // Print weather data fmt.Printf("Weather for %s from %s to %s:\n", location, startDate, endDate) for _, day := range weatherData.Days { fmt.Printf("Date: %s, Temperature: %.2f°C, Precipitation: %.2fmm\n", day.Date, day.Temperature, day.Precipitation) } } ``` ### Response #### Success Response (200) - **days** (array) - An array of daily weather data objects. - **datetimeStr** (string) - The date of the weather record. - **temperature** (float64) - The average temperature for the day. - **precipitation** (float64) - The total precipitation for the day. #### Response Example ```json { "days": [ { "datetimeStr": "2006-01-01", "temperature": 5.5, "precipitation": 0.2 }, { "datetimeStr": "2006-01-02", "temperature": 6.1, "precipitation": 0.0 }, { "datetimeStr": "2006-01-03", "temperature": 4.9, "precipitation": 1.5 } ] } ``` ``` -------------------------------- ### Fetch Weather Data - C++ Source: https://www.visualcrossing.com/resources/documentation/weather-api/visual-crossing-weather-api-libraries Illustrates creating a WeatherData object, fetching weather data using location and date parameters, and processing the daily weather data to output date, max temperature, min temperature, and humidity. ```cpp // create weather API object with API key WeatherData weatherData("YOUR_API_KEY"); // fetch weather data with location, from date, to date params. weatherData.fetchWeatherData("38.96%2C-96.02", "2020-7-10", "2020-7-12", "us", "events", ""); // daily weather data array list vector weatherDailyData = weatherData.getWeatherDailyData(); for (WeatherDailyData dailyData : weatherDailyData) { tm date = dailyData.getDatetime(); // Date convertion from tm object int y = date.tm_year + 1900; int m = date.tm_mon + 1; int d = date.tm_mday; // print max temperature cout << y << "-" << m << "-" << d << "," << dailyData.getTempMax() << endl; // print min temperature cout << y << "-" << m << "-" << d << "," << dailyData.getTempMin() << endl; // print humidity cout << y << "-" << m << "-" << d << "," << dailyData.getHumidity() << endl; } ``` -------------------------------- ### Example CSV Precipitation Data Source: https://www.visualcrossing.com/resources/documentation/weather-data/how-to-include-weather-radar-data-in-weather-datasets Example output of CSV-formatted precipitation data, showing datetime, station-based precip, and radar-based precipremote values. ```CSV datetime,precip,precipremote ... 2025-02-16T05:00:00,0.037,0.039 2025-02-16T06:00:00,0.048,0.039 2025-02-16T07:00:00,0.049,0.039 ... ``` -------------------------------- ### Go: Make API Request and Handle Initial Response Source: https://www.visualcrossing.com/resources/documentation/weather-api/how-to-load-weather-data-using-googles-go-language This Go code initializes the main function, sets location and date parameters, creates a Resty HTTP client, and makes a GET request to the Visual Crossing API. It includes basic error handling for the request and response status. ```go func main() { location := "New York, NY" startDate := time.Now().Format("2006-01-01") endDate := time.Now().Format("2006-01-03") client := resty.New() resp, err := client.R(). SetQueryParam("key", apiKey). SetQueryParam("location", location). SetQueryParam("startDate", startDate). SetQueryParam("endDate", endDate). SetHeader("Content-Type", "application/json"). Get(apiEndpoint) if err != nil { log.Fatalf("Error making request: %v", err) } if resp.StatusCode() != 200 { log.Fatalf("Error: %v", resp) } ```