npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

datapoint-js

v0.2.1

Published

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

Downloads

7

Readme

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