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

@christophern/populartimesjs

v1.0.8

Published

Retrieve popular times and current popularity of google places by its id.

Downloads

14

Readme

populartimesjs

Populartimesjs is a javascript based library to retrieve the popular times of a Google Place, its current popularity and if you provide a Google Developer API key, place meta data such as location, name and many more. All you need to provide is a Google Place id. This library is based on the idea of m-wrzr populartimes library.

🙈 Be aware this library can get broken due to changes of Google Places. Since Google does not provide popular times of places by its api this library makes use of the aria labels for screen readers and converts them into a structured response.

Getting Started

All you need to get started is a place id of a Google Maps place, you can find them by the Google Places ID Finder. Mind that the place needs to provide popular times. Places without popular times are not supported.

Start a new project or import populartimesjs to an existing one as dependency.

npm install @christophern/populartimesjs --save

Mind the default languge 🇩🇪 of the localized labels and texts. This just has impact on the nowBadge and the liveDescription property.

Example

Typescript

// index.ts
import { Populartimes } from '@christophern/populartimesjs';

const populartimes = new Populartimes('yourGoogleAPIKey'); // just needed if you want to get place details
const testPlace = 'ChIJsWlZerbYnUcRI1QgNIGOX5c';

(async () => {
  const data = await populartimes.fullWeek(testPlace);
  console.log('🚀', data);
})();

Vanilla / Node

//index.js
var Populartimes = require('@christophern/populartimesjs').Populartimes;
var populartimes = new Populartimes();

populartimes.fullWeek('ChIJsWlZerbYnUcRI1QgNIGOX5c').then((data) => {
  console.log('🚀', data);
});

Output

fullWeek(placeId: string): Promise<IExtractedData>

This method gives you access to the complete data available. See the documentation section blow for accessing specific subsets.

{
  "currentPopularity": 0,
  "currentPopularityText": {
    "nowBadge": "Derzeit",
    "liveDescription": "geschlossen"
  },
  "popularTimes": [
    {
      "day": "sunday",
      "data": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    },
    {
      "day": "monday",
      "data": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, 49, 58, 61, 58, 54, 56, 58, 49, 31, 0, 0, 0, 0]
    },
    {
      "day": "tuesday",
      "data": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 51, 58, 58, 54, 54, 59, 60, 48, 29, 0, 0, 0, 0]
    },
    {
      "day": "wednesday",
      "data": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, 49, 60, 64, 62, 58, 59, 61, 53, 33, 0, 0, 0, 0]
    },
    {
      "day": "thursday",
      "data": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
      "isToday": true
    },
    {
      "day": "friday",
      "data": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 55, 61, 61, 62, 67, 68, 64, 59, 48, 27, 0, 0, 0]
    },
    {
      "day": "saturday",
      "data": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 81, 96, 100, 98, 96, 96, 91, 70, 40, 0, 0, 0, 0]
    }
  ]
}

placeDetails(placeId: string): Promise<IPlace>

This method returns you available meta data of a place by the official Google Maps API. It requires you to initialize populartimesjs with a personal api key.

{
  "id": "a4ae7e2192c051c60263805b7fdd8bb09150fe9d",
  "name": "IKEA Einrichtungshaus Ludwigsburg",
  "business_status": "OPERATIONAL",
  "geometry": { "lat": 48.9180556, "long": 9.1538889 },
  "opening_hours": {
    "open_now": true,
    "periods": [
      { "close": { "day": 1, "time": "2000" }, "open": { "day": 1, "time": "1000" } },
      { "close": { "day": 2, "time": "2000" }, "open": { "day": 2, "time": "1000" } },
      { "close": { "day": 3, "time": "2000" }, "open": { "day": 3, "time": "1000" } },
      { "close": { "day": 4, "time": "2100" }, "open": { "day": 4, "time": "1000" } },
      { "close": { "day": 5, "time": "2100" }, "open": { "day": 5, "time": "1000" } },
      { "close": { "day": 6, "time": "2000" }, "open": { "day": 6, "time": "1000" } }
    ]
  }
}

Documentation

fullWeek(placeId: string)

Returns you the full data available.

now(placeId: string)

Returns you just the currentPopularity.

currentPopularityText(placeId: string)

Returns you the localized currentPopularityText property.

today(placeId: string)

Returns you the full data but instead all weekdays it just returns you the popular times of today.

placeDetails(placeId: string)

Returns you the meta data of a place by the official Google Maps API if you provide an api key to populartimes.

Development

// follows