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

@digdir/einnsyn-sdk

v1.3.0

Published

TypeScript client library for the eInnsyn API

Readme

TypeScript SDK for the eInnsyn API

Table of Contents

Installation

Install the package via npm:

npm install https://github.com/felleslosninger/einnsyn-sdk-typescript

Import and use it in your TypeScript project:

import { EInnsynClient } from 'einnsyn-sdk';

Authentication

The SDK supports multiple authentication methods:

  • JWT
  • Username/Password
  • API Key

Usage

Creating a client instance

// Client set-up (all options are optional)
const client = new EInnsynClient({
  baseUrl: 'https://api.einnsyn.no',
  appInfo: 'My eInnsyn client',
  username: '[email protected]',
  password: 'myPassword',
  jwtToken: '...',
  apiKey: 'secret_apikey',
});

Authenticating using JWT

When authenticating as an organization through Ansattporten, you would supply your JWT like this:

const authenticatedClient = new EInnsynClient({
  jwt: '...',
});

Authenticating using an eInnsyn username / password

const authenticatedClient = new EInnsynClient({
  username: '[email protected]',
  password: '...',
});

Authenticating using an API key

const authenticatedClient = new EInnsynClient({
  apiKey: 'secret_...',
});

Fetching content

// Get a saksmappe
const saksmappe = await client.saksmappe.get('sm_...');
console.log(saksmappe.offentligTittel);

// Get all journalposts in the saksmappe
const journalpostList = await client.saksmappe.getJournalpost('sm_...');

// Iterate over all journalposts
for await (const journalpost of client.iterate(journalpostList)) {
  console.log(`${journalpost.offentligTittel}`);
}

Iterating over paginated lists

You can automatically iterate over paginates lists like this:

const journalpostList = await client.saksmappe.getJournalpost('sm_...');

// Iterate over all journalposts
for await (const journalpost of client.iterate(journalpostList)) {
  console.log(`${journalpost.offentligTittel}`);
}

Expanding fields

You can expand fields in your queries to include related entities:

// Non-expanded:
const saksmappe = await client.saksmappe.get('sm_...');
console.log(saksmappe);
// Example output:
// {
//   entity: 'Saksmappe',
//   id: 'sm_...',
//   offentligTittel: 'Saksmappe title',
//   offentligTittelSensitiv: 'Saksmappe title with sensitive data',
//   saksaar: 2025,
//   sakssekvensnummer: 1,
//   journalpost: ['jp_...'],
// }

// Expanded:
const expandedSaksmappe = await client.saksmappe.get('sm_...', { expand: ['journalpost'] });
console.log(expandedSaksmappe);
// Example output:
// {
//   entity: 'Saksmappe',
//   id: 'sm_...',
//   offentligTittel: 'Saksmappe title',
//   offentligTittelSensitiv: 'Saksmappe title with sensitive data',
//   saksaar: 2025,
//   sakssekvensnummer: 1,
//   journalpost: [{
//     offentligTittel: 'Journalpost title',
//     offentligTittelSensitiv: 'Journalpost title with sensitive data',
//     journalaar: 2025,
//     journalsekvensnummer: 1,
//     journalpostnummer: 1,
//     journalposttype: 'inngaaende_dokument',
//     journaldato: '2025-01-01',
//   }],
// }

Adding / updating content

// Create a containing Arkiv
const arkiv = await client.arkiv.add({
  tittel: 'Arkiv title',
});

// Create a containing Arkivdel
const arkivdel = await client.arkiv.addArkivdel(arkiv.id, {
  tittel: 'Arkivdel title'
});

// Create a saksmappe with a Journalpost
const saksmappe = await client.arkivdel.addSaksmappe(arkivdel.id, {
  offentligTittel: 'Saksmappe title',
  offentligTittelSensitiv: 'Saksmappe title with sensitive data',
  saksaar: 2025,
  sakssekvensnummer: 1,
  journalpost: [{
    offentligTittel: 'Journalpost title',
    offentligTittelSensitiv: 'Journalpost title with sensitive data',
    journalaar: 2025,
    journalsekvensnummer: 1,
    journalpostnummer: 1,
    journalposttype: 'inngaaende_dokument',
    journaldato: '2025-01-01',
  }]
});

// Add a Journalpost with a Dokumentbeskrivelse to an existing Saksmappe
const journalpost = await client.saksmappe.addJournalpost(saksmappe.id, {
    offentligTittel: 'Second Journalpost',
    offentligTittelSensitiv: 'Second Journalpost title with sensitive data',
    journalaar: 2025,
    journalsekvensnummer: 2,
    journalpostnummer: 2,
    journalposttype: 'inngaaende_dokument',
    journaldato: '2025-01-03',
    dokumentbeskrivelse: [{
      tittel: 'Dokumentbeskrivelse title',
      tittelSensitiv: 'Title with sensitive data',
      dokumentnummer: 1,
      tilknyttetRegistreringSom: 'vedlegg',
    }]
});

// Update an existing Saksmappe
const updatedSaksmappe = await client.saksmappe.update(saksmappe.id, {
  offentligTittel: 'Updated offentligTittel',
});

Deleting content

const deletedSaksmappe = client.saksmappe.delete(saksmappe.id);

Search

// Search for "robot"
const searchResultList = client.search({
  query: 'robot',
});

// Iterate all results
for await (const searchResult of client.iterate(searchResultList)) {
    if (isSaksmappe(result)) {
      // This is a Saksmappe.
      console.log(`Saksmappe: ${result.offentligTittel}`);
    } else if (isJournalpost(result)) {
      // This is a Journalpost.
      console.log(`Journalpost - ${result.offentligTittel}`);
    } else if (isMoetemappe(result)) {
      // This is a Moetemappe.
      console.log(`Moetemappe - ${result.offentligTittel}`);
    } else if (isMoetesak(result)) {
      // This is a Moetesak.
      console.log(`Moetesak - ${result.offentligTittel}`);
    } else {
      // Unknown search result, should not happen.
      console.log(`Unknown result type`);
    }
}

// Search for "robot", in documents by a given enhet
const enhetsRobotList = client.search({
  query: 'robot',
  administrativEnhet: 'enh_...',
});

// Advanced search
const advancedSearch = client.search({
  query: 'advanced query',
  administrativEnhet: 'enh_...',
  excludeAdministrativEnhet: 'enh_...',
  sortBy: 'publisertDato',
  sortOrder: 'asc',
});

API Documentation

For detailed API documentation, please refer to the eInnsyn API Specification.

License

This project is licensed under the BSD 3-Clause License. See the LICENSE file for details.

References