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

numbeo-helpers

v1.0.2

Published

Helpers for translation data in Numbeo API

Downloads

1

Readme

numbeo-helpers

Helpers for translation data in Numbeo API.

The most basic purpose is getting russian translations of categories names used in API. These categories used in this API methods:

Prices:

  • /api/price_items
  • /api/city_prices
  • /api/country_prices
  • /api/historical_city_prices
  • /api/historical_country_prices
  • /api/city_prices_raw
  • /api/city_prices_archive_raw

Example:

{
   "monthLastUpdate":4,
   "contributors":91,
   "name":"Belgrade, Serbia",
   "prices":[
      {
         "average_price":5.443478260869566,
         "item_name":"Meal, Inexpensive Restaurant, Restaurants",
         "highest_price":7,
         "item_id":1,
         "lowest_price":4
      },
      {
         "average_price":1.8523809523809522,
         "item_name":"Imported Beer (0.33 liter bottle), Restaurants",
         "highest_price":2.3,
         "item_id":5,
         "lowest_price":1.5
      },
      {
         "average_price":0.3611111111111111,
         "item_name":"Lettuce (1 head), Markets",
         "highest_price":0.5,
         "item_id":113,
         "lowest_price":0.25
      },
      {
         "average_price":1.3,
         "item_name":"Cappuccino (regular), Restaurants",
         "highest_price":1.5,
         "item_id":114,
         "lowest_price":1.2
      }
   ],
   "yearLastUpdate":2012,
   "currency":"EUR"
}

Here you see array of objects named prices, and every object have item_id. So, numbeo-helpers working with this IDs.

Also there is one small method for getting textual version of crime and safety indices used by this API methods:

Indices:

  • /api/indices
  • /api/country_indices
  • /api/city_crime
  • /api/country_crime

Example:

{
   "health_care_index":66.75925925925927,
   "crime_index":38.84500915750915,
   "traffic_time_index":17,
   "purchasing_power_incl_rent_index":104.48707062276117,
   "cpi_index":77.32543080858119,
   "pollution_index":69.3103448275862,
   "traffic_index":93.60606499265447,
   "quality_of_life_index":141.4787210994602,
   "cpi_and_rent_index":58.15013366824719,
   "groceries_index":71.8735218572076,
   "safety_index":61.154990842490825,
   "name":"Kuwait",
   "rent_index":37.49969632054832,
   "traffic_co2_index":4256,
   "restaurant_price_index":75.45173244741275,
   "traffic_inefficiency_index":52.48906353257302,
   "property_price_to_income_ratio":6.989395647748136
}

Install

$ npm install numbeo-helpers
$ yarn add numbeo-helpers

Usage

Basic:

const numbeo = require("numbeo-helpers")();

Debug:

const numbeo = require("numbeo-helpers")({"debug": true});

You can pass {"debug": true} in function, so it console.log messages, if you pass something wrong to method. If you don't pass - debug is false by default.

API

numbeo.categoryObjectById(category_id)

Returns object of category by ID.

category_id

Type: number, string

Example:

numbeo.categoryObjectById(1);

Result:

  {
    "id": 1,
    "category_name": {
      "en": "Restaurants",
      "ru": "Рестораны"
    },
    "item_name": {
      "en": "Meal, Inexpensive Restaurant",
      "ru": "Порция, недорогой ресторан"
    },
    "payment_type": "oneoff",
    "slug": "restaurants"
  }

numbeo.nameById(category_id, [locale])

Get name of category by ID on specified language.

category_id

Type: number, string

locale

Type: string Default: ru Supported: ru, en

If locale not specified, then ru will be used.

Example:

numbeo.nameById(2, "ru")

Result:

Порция на двоих, ресторан среднего класса, три блюда

numbeo.allCategoriesByType(category)

Returns array of objects with categories of this type.

category

Type: string Supported: restaurants, markets, transportation, utilities, sportsleisure, childcare, fashion, rent, apartments, finance

Example:

numbeo.allCategoriesByType("finance")

Result:

[ { id: 105,
    category_name:
     { en: 'Salaries And Financing',
       ru: 'Зарплата и финансирование' },
    item_name:
     { en: 'Average Monthly Net Salary (After Tax)',
       ru: 'Месячная (после уплаты налогов)' },
    payment_type: 'monthly',
    slug: 'finance' },
  { id: 106,
    category_name:
     { en: 'Salaries And Financing',
       ru: 'Зарплата и финансирование' },
    item_name:
     { en: 'Mortgage Interest Rate in Percentages (%), Yearly',
       ru: 'Ипотека (%, год)' },
    payment_type: 'yearly',
    slug: 'finance' } ]

numbeo.allCategoriesByPaymentType(payment_type)

Returns array of objects with categories of this payment type.

payment_type

Type: string Supported: oneoff, monthly, yearly (oneoff means one-time payments, e.g. market purchases, taxi payments and suchlike)

Example:

numbeo.allCategoriesByPaymentType("yearly")

Results in:

[ { id: 228,
    category_name: { en: 'Childcare', ru: 'Дети' },
    item_name:
     { en: 'International Primary School, Yearly for 1 Child',
       ru: '' },
    payment_type: 'yearly',
    slug: 'childcare' },
  { id: 106,
    category_name:
     { en: 'Salaries And Financing',
       ru: 'Зарплата и финансирование' },
    item_name:
     { en: 'Mortgage Interest Rate in Percentages (%), Yearly',
       ru: 'Ипотека (%, год)' },
    payment_type: 'yearly',
    slug: 'finance' } ]

numbeo.crimeAndSafetyIndex(index, [locale])

Get text description of crime and safety index.

Returns object with text descriptions of crime and safety indices by passing crime index. In Numbeo API safety index is a number opposite to crime index, so it's decriptions is opposite too (high level of crime means low level of safety).

index

Type: number

locale

Type: string Default: ru Supported: ru, en

If locale not specified, then ru will be used.

Example:

numbeo.crimeAndSafetyIndex(18.99726889577763, "ru")

Results in:

{
	"crime": "Очень низкий",
	"safety": "Очень высокий"
}

Testing

$ npm run test

License

MIT © Alexander Sharabarov