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 🙏

© 2025 – Pkg Stats / Ryan Hefner

nortax-ts

v0.1.2

Published

Norwegian Tax Calculator - TypeScript Implementation

Downloads

255

Readme

NorTax-TS

A TypeScript client for the Norwegian tax authority’s API, based on the original Python package. This library focuses on fetching Norwegian tax calculations for various income types, periods, and tables.

License: MIT NPM Version GitHub Last Commit Tests Codecov

Note: This library is the TypeScript variant of the Nortax project. For the Python version, visit github.com/lewiuberg/nortax.

Table of Contents

Installation

npm install nortax-ts

Or use your preferred package manager:

yarn add nortax-ts
pnpm add nortax-ts

Usage

Import the Tax Class

import { Tax } from 'nortax-ts';

Create a Tax Object

// Create a Tax object with default or custom parameters
const tax = new Tax(
25000,        // grossIncome
'7100',       // taxTable
'Pension',    // incomeType
'2 weeks',    // period
2024          // year
);

Obtain Tax Details

(async () => {
// Get the deduction
const deduction = await tax.getDeduction();
console.log('Tax deduction:', deduction);

// Get the net income
const netIncome = await tax.getNetIncome();
console.log('Net income:', netIncome);

// Get a descriptive string with all details
const fullDetails = await tax.getFullDetails();
console.log(fullDetails);
})();

Example output (for getFullDetails()):

URL: str = https://api-tabellkort.app.skatteetaten.no/?valgtTabell=7100&valgtInntektType=Pensjon&valgtPeriode=PERIODE_14_DAGER&valgtLonn=25000&visHeleTabellen=false&valgtAar=2024&hentHeleTabellen=false
Tax table: valid_tables = 7100
Income type: income_type = Pension
Period: period = 2 weeks
Year: int = 2024
Gross income: int = 25000
Tax deduction: int = 6735
Net income: int = 18265

Retrieving the Whole Table

(async () => {
const wholeTable = await tax.getWholeTable();
console.log('Whole table:', wholeTable);
})();

Example output (truncated for readability):

{
"30000": 6971,
"40000": 10872,
"50000": 14774
}

Examples

import { Tax } from 'nortax-ts';

(async () => {
// 1) Instantiate a Tax object with desired parameters
const myTax = new Tax(50000, '7100', 'Wage', 'Monthly', 2024);

// 2) Fetch deduction
const deduction = await myTax.getDeduction();
console.log(`Monthly deduction on 50k gross: ${deduction}`);

// 3) Fetch net income
const netIncome = await myTax.getNetIncome();
console.log(`Net income: ${netIncome}`);

// 4) Obtain the entire deduction table if needed
const table = await myTax.getWholeTable();
console.log('Deduction table for various incomes:', table);
})();

Testing

This project uses Jest for both unit and integration testing.

  • Run all tests (without integration tests):

    npm test
  • Run with coverage:

    npm run test:coverage
  • Run integration tests (this hits the live API; ensure your network is available):

    npm run test:integration

Supported Values

Income Types

  • Wage
  • Pension

Periods

  • 1 day
  • 2 days
  • 3 days
  • 4 days
  • 1 week
  • 2 weeks
  • Monthly

Tax Tables

The tax tables are year-specific in the Norwegian tax system:

2020-2024 Tables

Standard tables (7100-7133), special tables (7150, 7160, 7170), and pension tables (6300, 6350, etc.).

Example usage:

// Valid for 2020-2024
const tax2024 = new Tax(50000, '7100', 'Wage', 'Monthly', 2024);

2025 Tables

New table system starting with 8xxx series (8100-8133, 8150, 8160, etc.).

Example usage:

// Valid only for 2025
const tax2025 = new Tax(50000, '8150', 'Wage', 'Monthly', 2025);

Note: Using a tax table with an incorrect year (e.g., trying to use table '8150' in 2024) will throw an error.

Error handling example:

// This will throw an error
try {
  const invalidTax = new Tax(50000, '8150', 'Wage', 'Monthly', 2024);
} catch (error) {
  console.error(error); // Error: Invalid tax table "8150" for year 2024
}

For a complete list of valid tables per year, see:

License

This project is released under the MIT License.

For more details on the original Python package, visit github.com/lewiuberg/nortax.