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

@codebazen/twinfield

v0.6.1

Published

A Node.js SDK for interacting with Twinfield APIs, enabling easy access to financial data, transactions, and other accounting functions.

Downloads

2,636

Readme

Twinfield Node.js SDK

Project Status

Alpha: This project is currently in the alpha phase of development. It's actively being developed, tested, and improved. Please note that it may contain bugs or incomplete features.

Introduction

Welcome to the Twinfield Node.js SDK, a community-driven project aimed at providing a Node.js SDK for Twinfield, a leading accounting software. Twinfield primarily supports SOAP XML API requests for most of its functionalities, while its OAuth authentication supports RESTful requests. This package facilitates the conversion of XML data to JSON and vice versa, making it easier for Node.js developers to interact with Twinfield's SOAP API.

As of now, there is no official Twinfield SDK for Node.js, and we wanted to give something back to the community by starting this project. Below, you'll find a table indicating the supported actions and their status.

Twinfield API Documentation

Supported Actions

| Action | API | Status | | --------------------------------- | ------------------- | ---------------- | | Authentication | | | | OpenID Connect Authentication | Master Data | Testing | | Master Data | | | | Customers | Master Data | Testing | | Suppliers | Master Data | Not Yet Developed | | General Ledger | Master Data | Not Yet Developed | | Cost Centers | Master Data | Not Yet Developed | | Fixed Assets | Master Data | Not Yet Developed | | Projects | Master Data | Not Yet Developed | | Activities | Master Data | Not Yet Developed | | Dimension Groups | Master Data | Not Yet Developed | | Dimension Types | Master Data | Not Yet Developed | | Asset Methods | Master Data | Not Yet Developed | | Offices | Master Data | Not Yet Developed | | Users | Master Data | Not Yet Developed | | Articles | Master Data | Not Yet Developed | | Currencies | Master Data | Not Yet Developed | | Rates | Master Data | Not Yet Developed | | Budget | Master Data | Not Yet Developed | | Bank Book | Master Data | Not Yet Developed | | Cash Book | Master Data | Not Yet Developed | | VAT | Master Data | Not Yet Developed | | Transaction Data | | | | Bank Transactions | Transaction Data | Not Yet Developed | | Cash Transactions | Transaction Data | Not Yet Developed | | Electronic Bank Statements | Transaction Data | Not Yet Developed | | Journal Transactions | Transaction Data | Not Yet Developed | | Purchase Transactions | Transaction Data | Not Yet Developed | | Sales Invoices | Transaction Data | Not Yet Developed | | Sales Transactions | Transaction Data | Not Yet Developed | | Reversal Transactions | Transaction Data | Not Yet Developed | | Spread Transactions | Transaction Data | Not Yet Developed | | Time | | | | Deleted Transactions | Time | Not Yet Developed | | Transaction Blocked Value | Time | Not Yet Developed | | Request Data | | | | Electronic Bank Statements | Request Data | Not Yet Developed | | Browse Data | Request Data | Not Yet Developed | | Miscellaneous | | | | Declarations | Miscellaneous | Not Yet Developed | | Finder | Miscellaneous | Not Yet Developed | | Hierarchies | Miscellaneous | Not Yet Developed | | Matching | Miscellaneous | Not Yet Developed | | Undo Match | Miscellaneous | Not Yet Developed | | Pay & Collect | Miscellaneous | Not Yet Developed | | Periods | Miscellaneous | Not Yet Developed |

Getting Started

To get started with the Twinfield Node.js SDK, follow these steps:

Installation: Install the SDK in your Node.js project using either npm or yarn:

npm install twinfield

Import Twinfield: Import the Twinfield module into your code:

import Twinfield from "twinfield"

Obtaining a Twinfield Access Token:

To obtain a Twinfield Access Token, start by referring to the Twinfield API documentation. There, you'll find instructions on acquiring a clientId and clientSecret, as well as guidance on configuring the redirect API. You can access the documentation here.

Initialize the Twinfield client:

    const clientId = 'xxxxxxxxxxxxxxxxxxxxxxxx'
    const clientSecret= 'xxxxxxxxxxxxxxxxxxxxxxxx'
    const redirectUrl = 'http://localhost/redirect'


    const twf = new Twinfield(clientId, clientSecret, redirectUrl)

Retrieve the login URL to direct the user to log in. Implement the logic to redirect the end-user to the login URL.

    //get the login url to get the user to login to
    const loginUrl = twf.twinfieldLogin()
example output: "https://login.twinfield.com/auth/authentication/connect/authorize
?client_id=clientId
&redirect_uri=http://localhost/redirect
&response_type=code&scope=openid+twf.organisationUser+twf.user+twf.organisation+offline_access
&state=48fe85e4-41b0-447c-8e5c-3a23a7e835a4&nonce=6d4b4f16-8069-4ad0-88ee-49952043e68d"

Exchange the code for an access token.

    //exchange the code for a accessToken
    twf.exchangeCode('code')

You shouled now be authenticated with Twinfield via oAuth.

console.log(twf.accessToken)
console.log(twf.refreshToken)

Example: Reading a Dimension:

Here's an example of how to read a dimension using the SDK:


//In case you had stored the accessToken or refreshToken somehwere, then you can initialise by passing through the refreshtoken and the accessToken

const twf = new Twinfield(clientId, clientSecret, redirectUrl, refreshToken, accessToken)

const office = 'NLA001234'
const dimensionCode = '1001'
const dimType = 'DEB'

const dimension = await twf.readDimension(office, dimensionCode, dimTyp)

Contact

If you encounter any issues or have questions, please open an issue on our GitHub repository.

License

MIT .