@balancer-team/quickbooks

中文文档
0.0.18发布于 2025/05/28MITTypeScriptCommonJS近 30 天下载 6339

QuickBooks JavaScript Client

此软件包已被标记为弃用

This package has moved to @nextform/quickbooks. Please update your dependencies.

原始使用文档
文档目录7 节
  1. Install
  2. Configure
  3. Get Auth URL
  4. Get Access Token from Grant
  5. Access and Refresh Tokens
  6. General-purpose Query Request
  7. General-purpose Post Request

QuickBooks JavaScript Client

JavaScript client for QuickBooks. Easily connect to the QuickBooks API. Make queries and create objects. TypeScript definitions are built in.

Install

npm i @balancer-team/quickbooks

Configure

import { QuickBooks } from '@balancer-team/quickbooks'

export const qb = new QuickBooks({
  clientId: 'YOUR_CLIENT_ID',
  clientSecret: 'YOUR_CLIENT_SECRET',
  redirectUri: 'YOUR_REDIRECT_URI',
  environment: 'SANDBOX_OR_PRODUCTION',
})

Get Auth URL

Begin the OAuth 2.0 flow by getting the auth url.

const authUrl = qb.getAuthUrl()

Get Access Token from Grant

Complete the OAuth 2.0 flow by using the grant details to retrieve the access token.

const token = await qb.getTokenFromGrant({
  code: 'GRANT_CODE',
  state: 'STATE_STRING',
  realmId: 'REALM_ID',
})

Access and Refresh Tokens

The token is an object that includes the access and refresh tokens, the realm ID, expirations, and other metadata. Tokens aren't stored in the qb instance. You must write your own application logic to manage tokens. This makes it easier to create multi-tenant applications, where different tokens have to be used for different users.

Intuit's access tokens are valid for one hour, and refresh tokens are valid for 100 days. You should ensure you are using an active access token by calling the following function. If the access token is still valid, it will simply return the token. If it needs to be refreshed, it will send the request to Intuit and obtain the refreshed token.

const validToken = await qb.getValidToken(staleToken) // -->
// {
//   access_token: 'eyJlbmMiOiJBMTI4...',
//   refresh_token: 'AB11734177244q21...',
//   token_type: 'bearer',
//   realm_id: '8241451349686734',
//   expires_in: 3600,
//   expires_at: 1725454384,
//   x_refresh_token_expires_in: 8726400,
//   x_refresh_token_expires_at: 1733918044,
// }

General-purpose Query Request

The QuickBooks API uses queries to access resources. Unlike most APIs, It is not necessary to specify an endpoint when retrieving a resource. Instead, the resource is specified in a SQL-like query language. Refer to the API Explorer for structuring your queries.

const vendors = await qb.query({
  token: token,
  query: 'select * from Vendor',
})

General-purpose Post Request

Use any endpoint and create any object using a general-purpose post request. Refer to the API Explorer for endpoints and object structures.

const createdJournalEntry = await qb.post({
  token: token,
  endpoint: '/journalentry',
  body: newJournalEntry,
})

版本与发布记录

@balancer-team/quickbooks 共发布 18 个版本,首次发布于 2024/08/31;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.0.18latest2025/05/281.4 年前
0.0.172025/05/281.4 年前
0.0.162025/05/281.4 年前
0.0.152024/09/042 年前
0.0.142024/09/042 年前
0.0.132024/09/042 年前

关于 @balancer-team/quickbooks 的常见问题

@balancer-team/quickbooks 是什么?

QuickBooks JavaScript Client注意:该包已被作者标记为弃用——This package has moved to @nextform/quickbooks. Please update your dependencies.

如何安装 @balancer-team/quickbooks?

在项目目录运行 npm install @balancer-team/quickbooks,或使用 pnpm add / yarn add / bun add。

@balancer-team/quickbooks 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@balancer-team/quickbooks 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@balancer-team/quickbooks 可以商用吗?

@balancer-team/quickbooks 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@balancer-team/quickbooks 的下载量有多少?

根据 npm 官方下载统计,@balancer-team/quickbooks 在 2026/10/08 – 2026/11/06 这 30 天内被下载 6,339 次,日均约 211 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@balancer-team/quickbooks 还在维护吗?

最新版本 0.0.18 发布于 2025/05/28(1.4 年前);至今共发布 18 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/08/31。作者已将其标记为弃用,新项目建议寻找替代方案。