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 🙏

© 2026 – Pkg Stats / Ryan Hefner

live-italy

v1.0.2

Published

API wrapper for the Live Italy API — real-time Italian statistics and open data.

Downloads

14

Readme

live-italy — Live Italy API Wrapper

Live Italy API wrapper — Fetch Italian statistics across economy, population, health, politics, society, security, work, and media. Full TypeScript support included.

Base URL: https://live-italy.vercel.app/api

  • Unified data model (single statistics table)
  • Language output: Italian or English via ?lang=it|en
  • Pagination & sorting included

Installation

npm i live-italy

TypeScript Support

Full TypeScript types and IntelliSense are included.

// ES Module
import { getStatistics, getCategories, getMetrics, getHealth, type StatisticsResponse } from 'live-italy';

const res: StatisticsResponse = await getStatistics({ category: 'economy', lang: 'en', format: 'compact' });
console.log(res.data);
// CommonJS
const { getStatistics, getCategories, getMetrics, getHealth } = require('live-italy');

(async () => {
  const health = await getHealth();
  console.log(health.status);
})();

Getting Statistics

The getStatistics() method retrieves values directly from the statistics table, exactly as stored. It supports filtering, pagination, sorting, and output translation.

const { getStatistics } = require('live-italy');

async function main() {
  try {
    // Economy (English), compact output
    const economyCompact = await getStatistics({
      category: 'economy',
      lang: 'en',
      format: 'compact'
    });
    console.log('Economy (compact):', economyCompact.data);

    // Single metric (GDP), full output with ordering
    const gdpFull = await getStatistics({
      metric: 'gdp',
      lang: 'en',
      sort: 'updated_at',
      order: 'desc',
      limit: 50
    });
    console.log('GDP (full):', gdpFull.data);

    // Pagination example
    const page2 = await getStatistics({ offset: 100, limit: 50 });
    console.log('Page 2 size:', page2.data.length);

  } catch (err) {
    console.error('Statistics error:', err.message);
  }
}

main();

Parameters

type Lang = 'it' | 'en';
type SortField = 'category' | 'metric' | 'value' | 'updated_at' | 'last_updated';
type SortOrder = 'asc' | 'desc';
type Format = 'full' | 'compact';
  • category — (optional) Filter by category (IT or EN), e.g. "economia" / "economy"
  • metric — (optional) Filter by metric (IT or EN), e.g. "pil" / "gdp"
  • lang — (optional) "it" | "en"; default "it" (translates output labels only)
  • limit — (optional) default 100, max 1000
  • offset — (optional) default 0
  • sort — (optional) "category" | "metric" | "value" | "updated_at" | "last_updated" (default "updated_at")
  • order — (optional) "asc" | "desc" (default "desc")
  • format — (optional) "full" | "compact" (default "full")

Getting Categories

The getCategories() method returns available categories in the selected language.

const { getCategories } = require('live-italy');

(async () => {
  const it = await getCategories();            // default 'it'
  const en = await getCategories({ lang: 'en' });
  console.log('IT categories:', it.data);
  console.log('EN categories:', en.data);
})();

Parameters

  • lang — (optional) "it" | "en"; default "it"

Example Response

{
  "success": true,
  "data": ["population", "economy", "society", "work", "media", "politics", "security", "health"],
  "total_categories": 8,
  "filters_applied": { "language": "en" }
}

Getting Metrics

The getMetrics() method lists metrics, optionally filtered by category, and translated according to lang.

const { getMetrics } = require('live-italy');

async function list() {
  // All metrics (IT)
  const all = await getMetrics();

  // Metrics for economy (EN)
  const economy = await getMetrics({ category: 'economy', lang: 'en' });

  console.log('All (IT):', all.data.length, 'blocks');
  console.log('Economy (EN):', economy.data[0]);
}
list();

Parameters

  • category — (optional) Filter by category (IT or EN)
  • lang — (optional) "it" | "en"; default "it"

Example Response

{
  "success": true,
  "data": [
    { "category": "economy", "metrics": ["gdp", "public_debt", "debt_interest", "tax_evasion", "wealthy", "poor"] },
    { "category": "population", "metrics": ["total", "births_per_year", "deaths_per_year", "immigrants_per_year", "emigrants_per_year", "total_immigrants", "births_today", "deaths_today", "current_population"] }
  ],
  "total_categories": 8,
  "filters_applied": { "category": null, "language": "en" }
}

Health Check

The getHealth() method retrieves a simple API and database status snapshot.

const { getHealth } = require('live-italy');

(async () => {
  const health = await getHealth();
  console.log(health.status, health.database?.status);
})();

Example Response

{
  "status": "healthy",
  "api_version": "2.0.0",
  "timestamp": "2025-10-26T00:00:00.000Z",
  "database": {
    "status": "connected",
    "server_time": "2025-10-26T00:00:00.000Z",
    "total_statistics": 65
  },
  "endpoints": ["/api/statistics", "/api/categories", "/api/metrics", "/api/health"]
}

Error Handling

All methods throw an Error on failure. Use try/catch:

try {
  const stats = await getStatistics({ metric: 'gdp', lang: 'en' });
  console.log(stats.data);
} catch (error) {
  console.error('Request failed:', error.message);
}

Category & Metric Translations

The SDK translates output labels based on ?lang=it|en. Examples:

Categories

| Italian | English | | ----------- | ---------- | | popolazione | population | | economia | economy | | societa | society | | lavoro | work | | media | media | | politica | politics | | sicurezza | security | | salute | health |