Features

Wrapper easy to use libraries

Are you looking for the easiest way to implement weather data in your app or service? Our wrapper libraries below will make it quick and easy to do so. Please note that we cannot provide support for the API wrappers.

API libraries available:

Python API library

The basic functionality of this library only needs requests and pytz modules. You can install it using pip3 command.

Python weather API library on Github

Example:

from datetime import datetime, timedelta
from pymeteosource.api import Meteosource
from pymeteosource.types import tiers, sections, langs, units

# Change this to your actual API key
YOUR_API_KEY = 'abcdefghijklmnopqrstuvwxyz0123456789ABCD'
# Change this to your actual tier
YOUR_TIER = tiers.FLEXI

# Initialize the main Meteosource object
meteosource = Meteosource(YOUR_API_KEY, YOUR_TIER)

# Get the forecast for given point
forecast = meteosource.get_point_forecast(
    lat=37.7775,  # Latitude of the point
    lon=-122.416389,  # Longitude of the point
    place_id=None,  # You can specify place_id instead of lat+lon
    sections=[sections.CURRENT, sections.HOURLY],  # Defaults to '("current", "hourly")'
    tz='US/Pacific',  # Defaults to 'UTC', regardless of the point location
    lang=langs.ENGLISH,  # Defaults to 'en'
    units=units.US  # Defaults to 'auto'
)

# Forecast for lat: 37.7775, lon: -122.416389
print(forecast)

JavaScript library

To use meteosource_js install it using npm install meteosource or include metesource.js and datetime luxon library into your script.

JavaScript weather API library on GitHub

Example:

<script src="https://www.meteosource.com/js/libs/meteosource.js">
<script src="https://cdn.jsdelivr.net/npm/luxon@2.4.0/build/global/luxon.min.js">

// Change this to your actual API key
let apiKey = 'YOU_API_KEY'
// Change this to your actual tier
let tier = 'flexi'

let m = new meteosource.Meteosource(apiKey, tier)

let forecast = await m.getPointForecast({
    lat: 37.7775,  // Latitude of the point
    lon: -122.416389,  // Longitude of the point
    placeId: null,  // You can specify place_id instead of lat+lon
    sections: ["current", "hourly"],  // is converted to "current,hourly"
    tz: 'US/Pacific',
    lang: 'en',
    units: 'us',  // Defaults to 'auto'
})

// NOTE: The command above works in an async/wait context only
// (async function, Node.JS REPL)
// elsewhere you run:
//m.getPointForecast({...}).then(forecast => console.log(forecast))

PHP library

Install meteosource_php library using composer require meteosource/meteosource_php.

PHP weather API library on GitHub

Example:

<?php
// Change this to your actual API key
const YOUR_API_KEY = 'abcdefghijklmnopqrstuvwxyz0123456789ABCD';
// Change this to your actual tier
const YOUR_TIER = 'flexi';

// Initialize the main Meteosource object
$meteosource = new Meteosource\Meteosource(YOUR_API_KEY, YOUR_TIER);

// Get the forecast for given point
$forecast = $meteosource->getPointForecast(
    null,  // You can specify place_id instead of lat+lon
    37.7775,  // Latitude of the point
    -122.416389,  // Longitude of the point
    ['current', 'hourly'],  // Defaults to '("current", "hourly")'
    'US/Pacific',  // Defaults to 'UTC', regardless of the point location
    'en',  // Defaults to 'en'
    'auto'  // Defaults to 'auto'
);

echo $forecast;  // <?Forecast for lat: 37.7775, lon: -122.416389>

C++ library

To use meteosource_cpp, you only need to copy all *.cpp and *.h files from src folder into your project. Then you can #include "Meteosource.h" and fetch the weather data you need.

C++ weather API library on GitHub

Example:

#include <iostream>
#include <jsoncpp/json/json.h>
#include <memory>

#include "Meteosource.h"


int main()
{
    // Change this to your actual API key
    const std::string api_key = "YOUR-API-KEY";
    // Change this to your actual tier
    const std::string tier = "free";
    Meteosource m = Meteosource(api_key, tier);

    const std::string place_id = "london";
    const std::string sections = "all";
    const std::string timezone = "UTC";
    const std::string language = "en";
    const std::string units = "auto";
    auto res = m.get_point_forecast(place_id, sections, timezone, language, units);
    if (!res)
    {
        return -1;
    }

    if (res->current)
    {
        std::cout << "Current weather: " << res->current->summary << std::endl << std::endl;
    }

    if (res->minutely)
    {
        std::cout << "Minutely summary: " << res->minutely->summary << std::endl << std::endl;
        std::cout << "Precipitation for next 5 minutes: " << res->minutely->summary << std::endl << std::endl;

        for (int i = 0; i < 5; ++i)
            std::cout << "  " << res->minutely->data[i]->date << ": precipitation " << res->minutely->data[i]->precipitation << std::endl;
        std::cout << std::endl;
    }

    if (res->hourly.size() > 0)
    {
        std::cout << "Weather for next 5 hours:" << std::endl;
        for (int i = 0; i < 5; ++i)
            std::cout << "  " << res->hourly[i]->date << ": temperature " << res->hourly[i]->temperature << ", wind speed: " << res->hourly[i]->wind_speed << std::endl;
        std::cout << std::endl;
    }

    if (res->daily.size() > 0)
    {
        std::cout << "Daily Weather for next 5 days:" << std::endl;
        for (int i = 0; i < 5; ++i)
            std::cout << "  " << res->daily[i]->day << ": all day weather: '" << res->daily[i]->all_day->weather << "', sunrise: " << res->daily[i]->astro->sun_rise << std::endl;
        std::cout << std::endl;
    }

    return 0;
}

Postman Collection

Use Postman Collection directly by clicking the Run in Postman button or visit GitHub repository for more info.