Visual Crossing provides a wide array of open-source libraries that simplify the use of our Weather API in nearly every popular programming language. Whether you are a beginner writing your first script or a seasoned developer building enterprise systems, these libraries are designed to help you get started quickly and integrate weather data seamlessly into your applications.
Available Libraries
C#
Integrate weather data into any .NET, Windows Forms, or ASP.NET project with this object-oriented client.
View on GitHub
Example:
// 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”, “”);
// daily weather data array list
List<WeatherDailyData> weatherDailyData = weatherData.WeatherDailyData;
if (weatherDailyData != null)
{
foreach (WeatherDailyData dailyData in weatherDailyData)
{
// print max temperature
Console.WriteLine($”{dailyData.Datetime}, {dailyData.TempMax}”);
// print min temperature
Console.WriteLine($”{dailyData.Datetime}, {dailyData.TempMin}”);
// print humidity
Console.WriteLine($”{dailyData.Datetime}, {dailyData.Humidity}”);
}
}
C++
A powerful native library for integrating Visual Crossing weather data in C++ environments.
View on GitHub
Example:
// 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> 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;
}
Go
This Go client is ideal for efficient server-side weather integrations using the lightweight and fast Go environment.
View on GitHub
Example:
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(), "")
Java
This client works seamlessly in enterprise apps, Spring Boot, or Android development where robust and full-featured weather data is needed.
View on GitHub
Example:
// 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> 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());
}
}
JavaScript
Call the Weather API using standard browser JavaScript and modern fetch()
syntax.”.
View on GitHub
Example:
weather = Weather('Your API Key')
await weather.fetchWeatherData("38.95,-95.664", "2024-01-01", '2024-01-12', 'hours')
weather.getDatetimeEpochAtDatetime('2024-01-02','01:00:00')
weather.getTempAtDatetime('2024-01-02',1)
weather.getPrecipAtDatetime(1,'01:00:00')
print(">>Weather data at a datetime: ", weather.getDataAtDatetime(1,1, ['temp', 'precip', 'humidity']))
Kotlin
A modern API client for Android and other JVM platforms, built in pure Kotlin style.
View on GitHub
Example:
// create weather API object with API key
val 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", "")
// get daily weather data array list
val weatherDailyData: ArrayList<WeatherDailyData>? = weatherData.weatherDailyData
if (weatherDailyData != null) {
for (dailyData in weatherDailyData) {
// print max temperature
println(dailyData.datetime.toString() + "," + dailyData.tempmax)
// print min temperature
println(dailyData.datetime.toString() + "," + dailyData.tempmin)
// print humidity
println(dailyData.datetime.toString() + "," + dailyData.humidity)
}
}
MATLAB
Pull weather data directly into MATLAB for analysis, modeling, and visualization.
View on GitHub
Example:
weather = Weather(api_key='Your API Key')
weather.fetch_weather_data("38.95,-95.664", "2024-01-01", '2024-01-12', 'hours')
weather.get_datetimeEpoch_at_datetime('2024-01-02','01:00:00')
weather.get_temp_at_datetime('2024-01-02',1)
weather.get_precip_at_datetime(1,'01:00:00')
print(">>Weather data at a datetime: ", weather.get_data_at_datetime(1,1, {'temp', 'precip', 'humidity'}))
PHP
Use this lightweight script to integrate real-time or historical weather into web apps or reports.
View on GitHub
Example:
<?php
require 'vendor/autoload.php';
use WeatherVisual\WeatherData;
$apiKey = 'YOUR_API_KEY';
$weather = new WeatherData($apiKey);
try {
$data = $weather->fetchWeatherData('Los Angeles, CA', '2024-01-01', '2024-01-07');
print_r($data);
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
?>
Perl
Efficient Perl client for data extraction, automation, or batch weather downloads.
View on GitHub
Python
One of our most popular libraries, perfect for scripting, data science, or Jupyter workflows.
View on GitHub
R
Seamlessly bring weather data into R for statistical modeling and time series analysis.
View on GitHub
Ruby
Add weather capabilities to Ruby scripts or Rails apps with this straightforward integration.
View on GitHub
Example:
require 'weather_visual'
api_key = 'YOUR_API_KEY_HERE'
weather = WeatherVisual::WeatherData.new(api_key)
location = 'New York, NY'
from_date = '2023-01-01'
to_date = '2023-01-07'
data = weather.fetch_weather_data(location, from_date, to_date, 'us', 'hours', ['temp', 'humidity'])
Rust
Take advantage of Rust’s speed and safety while integrating high-resolution weather data.
View on GitHub
Example:
// Create weather API object with API key
let mut weather_data = WeatherData::new("YOUR_API_KEY".to_string());
// Fetch weather data with location, from date, to date params.
weather_data.fetch_weather_data("38.96,-96.02", Some("2020-7-10"), Some("2020-7-12"), Some("us"), Some("events,hours"), Some("")).unwrap();
// Daily weather data array list
if let Some(weather_daily_data) = &weather_data.weather_daily_data() {
for i in 0..weather_daily_data.len() {
let datetime = daily_data.datetime().unwrap();
println!("{:?}, {:?}", datetime, daily_data.temp_max().unwrap());
println!("{:?}, {:?}", datetime, daily_data.temp_min().unwrap());
println!("{:?}, {:?}", datetime, daily_data.humidity().unwrap());
}
}
Scala
Ideal for functional and reactive developers who want typed access to our weather data API.
View on GitHub
Example:
// create weather API object with API key
val 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,hours", "")
// get daily weather data array list
val weatherDailyData: ArrayBuffer[WeatherDailyData] = weatherData.getWeatherDailyData
if (weatherDailyData != null) {
for (dailyData <- weatherDailyData) {
// print max temperature
println(s"${dailyData.datetime.get}, ${dailyData.tempmax.get}")
// print min temperature
println(s"${dailyData.datetime.get}, ${dailyData.tempmax.get}")
// print humidity
println(s"${dailyData.datetime.get}, ${dailyData.humidity.get}")
}
}
Swift
Add weather data to native iOS or macOS apps using Swift-native calls.
View on GitHub
Example:
// Create weather API object with API key
let weatherData = WeatherData(apiKey: "YOUR_API_KEY")
// Fetch weather data with location, from date, to date params
weatherData.fetchWeatherData(location: "38.96%2C-96.02", from: "2020-7-10", to: "2020-7-12", unitGroup: "us", include: "events", elements: "")
// Daily weather data array list
let weatherDailyData = weatherData._WeatherDailyData
for dailyData in weatherDailyData {
// Hourly weather data array list
let weatherHourlyData = dailyData._WeatherHourlyData
for hourlyData in weatherHourlyData {
// Print temperature
print("\(hourlyData._Datetime ?? TimeInterval()), \(hourlyData._Temp ?? 0.0)")
// Print humidity
print("\(hourlyData._Datetime ?? TimeInterval()), \(hourlyData._Humidity ?? 0.0)")
}
}
VB (Visual Basic)
Access weather data using Visual Basic for legacy desktop and VBA integrations.
View on GitHub
Example:
' Create weather API object with API key
Dim weatherData As 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,hours", "")
' Daily weather data array list
Dim weatherDailyData As List(Of WeatherDailyData) = weatherData.WeatherDailyData
If weatherDailyData IsNot Nothing Then
For Each dailyData As WeatherDailyData In weatherDailyData
' Print max temperature
Console.WriteLine($"{dailyData.Datetime}, {dailyData.TempMax}")
' Print min temperature
Console.WriteLine($"{dailyData.Datetime}, {dailyData.TempMin}")
' Print humidity
Console.WriteLine($"{dailyData.Datetime}, {dailyData.Humidity}")
Next
End If
Want to Contribute?
Have a favorite language that’s not yet listed? Created your own library or plugin? We’d love to feature it!
Visual Crossing is a community-driven platform, and we welcome your help in expanding our library ecosystem.
If you’ve built a new client, improved an existing one, or want to share a cool integration, reach out to our Support Team, and we’ll help you publish the library and include it on this page.
Every contribution helps make weather data more accessible to developers everywhere and improves the usefulness of the weather data platform that you have come to reply upon.