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

japan-train-data

v0.6.0

Published

A circular object of train data for Japan including translations & station geocoding

Downloads

32

Readme

🚉 japan-train-data

Choo choo.

A circular object of train data for Japan including translations & station geocoding and a tool to generate it. Access train data by prefecture, by lines, or by stations.

Install

yarn add japan-train-data

Usage

import { prefectures, lines, stations } from 'japan-train-data'

console.log(prefectures.find(({ id }) => id === 13))

/*
{
  id: 13,
  name: { ja: '東京都', en: 'Tokyo' },
  lines: [
    {
      id: 11301,
      name: [Object],
      lat: 35.39507962341528,
      lng: 139.4302441326313,
      zoom: 10,
      stations: [Object],
      prefecture: [Circular],
    },
    ...
  ],
}
*/

console.log(lines.find(({ id }) => id === 11302))

/*
{
  id: 11302,
  name: {
    ja: 'JR山手線',
    en: 'JR Yamanote Line',
  },
  lat: 35.69302730762992,
  lng: 139.73522275686264,
  zoom: 12,
  stations: [
    {
      id: 1130201,
      name: [Object],
      location: [Object],
      lines: [Object],
      prefecture: [Object],
    },
    {
      id: 1130202,
      name: [Object],
      location: [Object],
      lines: [Object],
      prefecture: [Object],
    },
    ...
  ],
  prefecture: {
    id: 13,
    name: { ja: '東京都', en: 'Tokyo' },
    lines: [[Object], [Circular], [Object]],
  },
}
*/

console.log(stations.find(({ prefecture: { id } }) => id === 13))

/*
{
  id: 1130101,
  name: { ja: '東京', en: 'Tokyo' },
  location: {
    lat: 35.681391,
    lng: 139.766103,
    countryCode: { en: 'JP', ja: 'JP' },
    postalCode: {
      en: '100-0005',
      ja: '100-0005',
    },
    administrativeArea1: {
      en: 'Tōkyō-to',
      ja: '東京都',
    },
    locality1: {
      en: 'Chiyoda-ku',
      ja: '千代田区',
    },
    sublocality1: {
      en: 'Marunouchi',
      ja: '丸の内',
    },
    sublocality2: {
      en: '1 Chome',
      ja: '1丁目',
    },
    sublocality3: { en: '9', ja: '9' },
    sublocality4: { en: '1', ja: '1' },
  },
  lines: [
    { id: 11301, name: [Object] },
    { id: 11302, name: [Object] },
    { id: 11308, name: [Object] },
    ...
  ],
  prefecture: {
    id: 13,
    name: { ja: '東京都', en: 'Tokyo' },
    lines: [[Object], [Object], [Object]],
  },
}
*/

Just gimme the data

Sure. data/raw-data.json.

Generating the data

First clone the project:

git clone https://github.com/adieuadieu/japan-train-data.git

Set up your environment with Google Cloud keys. To generate the data you need API access to Google's Translation and Geocoding APIs.

echo GCP_PROJECT=your-gcp-project-id-here >> .env
GCP_API_KEY=your-google-maps-api-key-here >> .env
GCP_KEYFILE=./gcp-keyfile.json >> .env

Then to start generating data:

yarn generate

Known Issues

  1. Some of the translations are clearly crap.
  2. In many cases, transliteration would be better than translation, but there's no API? Suggestions?

Todo

  • [X] npm package
  • [ ] unit tests
  • [ ] ci integrations