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 should make it quick and easy to do so. Please note that we cannot provide support for the API wrappers.

Python

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.PREMIUM

# 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)

C++

C++ weather API library on Github

Example:

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

#include "Meteosource.h"


int main()
{
    const std::string api_key = "YOUR-API-KEY";
    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;
}