Socket
Socket
Sign inDemoInstall

@aspida/resas

Package Overview
Dependencies
18
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @aspida/resas

resas API for aspida


Version published
Weekly downloads
1
Maintainers
1
Install size
0.973 MB
Created
Weekly downloads
 

Readme

Source
RESAS-API for aspida

RESAS-API | Cabinet Office,Government Of Japan.

Installation

$ npm install typescript ts-node @types/node axios @aspida/resas

Usage

index.ts

Because there is mock data, this script works without registering API key.

import axios from "axios"
import api, { mock, ApiTypes } from "@aspida/resas"

if (process.env.NODE_ENV === "production") {
  // Get API key here: https://opendata.resas-portal.go.jp/form.html
  axios.defaults.headers.common["X-API-KEY"] = process.env.API_KEY
} else {
  mock()
}

;(async () => {
  const prefCode = ApiTypes.PrefCode.Hokkaido
  const cities = await api().v1.cities.$get({ params: { prefCode } })
  const { cityCode } = cities.result.filter(city => city.cityName === "札幌市")[0]

  const population = await api().v1.population.composition.perYear.$get({
    params: { prefCode, cityCode }
  })

  console.log(population.result)
})()

package.json

{
  "scripts": {
    "start": "ts-node index"
  }
}

Run

$ npm start

Result

{ boundaryYear: 2015,
  data:
   [ { label: '総人口', data: [Array] },
     { label: '年少人口', data: [Array] },
     { label: '生産年齢人口', data: [Array] },
     { label: '老年人口', data: [Array] } ] }

FAQs

Last updated on 22 Oct 2019

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