Giter Site home page Giter Site logo

visualcrossing-api's Introduction

VisualCrossing.net Wrapper

This is a wrapper for the visualcrossing.com API. You need an API key to use it (https://www.visualcrossing.com/weather/weather-data-services#). Please consult the API docs at https://www.visualcrossing.com/resources/documentation/weather-api/timeline-weather-api/.

Example Use

use VisualCrossing::API;
use feature 'say';
    
my $location = "AU419";                # example location (required)
my $date = "2023-05-25";               # example date (optional)
my $key = "ABCDEFGABCDEFGABCDEFGABCD"; # example VisualCrossing API key (required)

## Current Data (limit to current, saves on API cost)
my $weatherApi = VisualCrossing::API->new(
    key      => $key,
    location => $location,
    include  => "current",
);
my $current = $weatherApi->getWeather;

say "current temperature: " . $current->{currentConditions}->{temp};
say "current conditions: " . $current->{currentConditions}->{conditions};

## Historical Data (limit to single day, saves on API cost)
$weatherApi = VisualCrossing::API->new(
    key      => $key,
    location => $location,
    date     => $date,
    date2    => $date,
    include  => "days",
);
my $history = $weatherApi->getWeather;

say "$date temperature: " . $history->{days}[0]->{temp};
say "$date conditions: " . $history->{days}[0]->{conditions};

Key (required)

The "key" string is your VisualCrossing API key. You can get one at https://www.visualcrossing.com/weather-data-editions The free tier allows for 1000 records per day.

Location (required)

The "location" string, can be a location ID, a city name, or a lat/long pair.

If passing a lat/long pair, it can be in the form of "lat,long" (no spaces). It could also be passed as keys "latitude" and "longitude".

Dates (optional)

The "date" string can be a date in the form of "YYYY-MM-DD", "YYYY-MM-DDTHH:MM:SS", UNIX format of seconds since the 1970.

It can also be a period "2020-10-01/2020-12-31". The second date could also be passed in the "date2" key. or a Dynamic period Request like: “last30days”, “today”, “yesterday”, and “lastyear”.

The date is optional, and if not passed, the request will retrieve the forecast at the requested location for the next 15 days.

Build, release

Ensure you have Dist::Zilla installed, and that it is in your path. For example:

cpan install Dist::Zilla
cpan Dist::Zilla Mouse
PATH=$PATH:/opt/homebrew/Cellar/perl/5.36.1/bin

Then run the following commands to build, test, install, clean, and release:

dzil clean
dzil build
dzil test
dzil install
dzil clean
dzil release

To just run the tests:

prove -lr t

Links

Patches/suggestions welcome

Github: https://github.com/duanemay/VisualCrossing-API

Based on the good work of: Martin-Louis Bright https://github.com/mlbright/DarkSky-API

visualcrossing-api's People

Contributors

duanemay avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.