Socket
Socket
Sign inDemoInstall

datapoint-js

Package Overview
Dependencies
1
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    datapoint-js

A JavaScript library for accessing weather data via the [Met Office](http://www.metoffice.gov.uk/)'s open data API known as [DataPoint](http://www.metoffice.gov.uk/datapoint).


Version published
Weekly downloads
3
increased by50%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

DataPoint for JavaScript Build Status

A JavaScript library for accessing weather data via the Met Office's open data API known as DataPoint.

Disclaimer: This module is in no way part of the DataPoint project/service. This module is intended to simplify the use of DataPoint for JavaScript projects. No support for this module is provided by the Met Office and may break as the DataPoint service grows/evolves. The author will make reasonable efforts to keep it up to date and fully featured.

Features

  • List forecast/observation sites
  • Get nearest forecast/observation site from longitude and latitiude
  • Get the following 5 day forecast types for any site
  • Daily (Two timesteps, midday and midnight UTC)
  • 3 hourly (Eight timesteps, every 3 hours starting at midnight UTC)
  • Get hourly observations for the last 48 hours

Installation

Node

npm install datapoint-js

Browser

bower install datapoint-js

Manual

Download the contents of either /src (for node) or /dist/browser (for browser) and include them in your project.

Example Usage

Node

var datapoint = require('datapoint-js')

datapoint.set_key("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")

site = datapoint.get_nearest_forecast_site(-0.124626, 51.500728)

forecast = datapoint.get_forecast_for_site(site.id, "3hourly")

current_timestep = forecast.days[0].timesteps[0]

console.log("Temperature is " + current_timestep.temperature.value + "°" + current_timestep.temperature.units + " in " + site.name)
Output
Temperature is 15°C in London

Browser

<html>
<head>
  <title>Datapoint test</title>
</head>
<body>

  <h1>Weather</h1>
  <p id="weather">Loading...</p>

  <script src="../dist/browser/datapoint.js"></script>
  <script>

    datapoint.set_key("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee");

    site = datapoint.get_nearest_forecast_site(-0.124626, 51.500728);

    forecast = datapoint.get_forecast_for_site(site.id);

    current_timestep = forecast.days[0].timesteps[0];

    document.getElementById("weather").innerHTML =
        "Temperature is " + current_timestep.temperature.value + "&deg;" + current_timestep.temperature.units + " in " + site.name;

  </script>
</body>
</html>
Output

The contents of the <p> block is replaced with Temperature is 15°C in London.

Contributing changes

Please feel free to submit issues and pull requests.

To work on the project simply clone the project and run npm install.

This project uses gulp as its task runner and can be used to browserify the code and generate the documentation.

Documentation

Documentation is automatically generated using JSDoc and is stored in docs.

To regenerate the documentation simply run

gulp document

License

GPL v3

FAQs

Last updated on 08 Apr 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc