Skip to content

kasvith/openweathermap-ballerina

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Open Weather Map API for Ballerina

Build Status GitHub

The Open Weather Maps connector allows you to fetch data from Open Weather Maps based on city name, zip, id etc. It also allows to fetch data over a circle or a box of coordinates.

Sample

Import the libary from kasvith/openweathermaps to your project

import kasvith/openweathermap

Obtain app id from Open Weather Maps

Visit Open Weather Maps and Grab a APPID by registering.

Initializing Client

To initialize client after obtaining APPID you need to select language and metrics. They are defaulted to English and Kelvin(for temperature).

openweathermap:OpenWeatherMapClient owmClient =  new({
	appid: "YOUR_APP_ID"
});

Use client to obtain weather of a city by Name

var result = owmClient->getWeatherByCityName("Colombo");
io:println(result);

Use client to obtain weather of a location

var result = owmClient->getWeatherByCityCoordinates({lat: 10, lon: 10});
io:println(result);

Developer Guide

You need Ballerina 0.990.3 for development