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

sunapi365

v0.1.0

Published

Professional JavaScript and TypeScript SDK for SUNAPI 365 PE.

Readme

SUNAPI SDK

sunapi365

Official JavaScript and TypeScript SDK for SUNAPI.

This package is prepared as a real npm library for production use. It exposes the public SUNAPI surface with a clean domain-based API, generated type declarations, and support for modern JavaScript, CommonJS, and TypeScript consumers.

Why this package exists

SUNAPI covers products, customers, tickets, receipts, invoices, notes, summaries, dispatch guides, credentials, settings, and webhooks. A public SDK must make those resources easy to discover without hiding the underlying API model.

This package is organized to do that:

  • one public package for JavaScript and TypeScript
  • typed resources grouped by domain
  • ESM and CommonJS support from the same publication
  • a production-ready default endpoint with local override support

Install

npm install sunapi365
pnpm add sunapi365
bun add sunapi365

Quick start

import { auth, companies, createSunApiSdk } from "sunapi365";

const sdk = createSunApiSdk();

const tokens = await auth.oauthClientCredentials(
  sdk,
  "YOUR_CLIENT_ID",
  "YOUR_CLIENT_SECRET",
);

sdk.setAccessToken(tokens.accessToken);

const companyList = await companies.list(sdk);

What the package supports

This package is designed for:

  • JavaScript via import
  • JavaScript via require
  • TypeScript with generated .d.ts

CommonJS example:

const { createSunApiSdk, auth } = require("sunapi365");

const sdk = createSunApiSdk();

Public entrypoints

Root import:

import { createSunApiSdk, products, tickets, documents } from "sunapi365";

Subpath imports:

import { createSunApiSdk } from "sunapi365/client";
import { products } from "sunapi365/products";
import type { TicketCreateInput } from "sunapi365/types";

Available subpaths:

  • sunapi365/client
  • sunapi365/errors
  • sunapi365/types
  • sunapi365/auth
  • sunapi365/catalogs
  • sunapi365/companies
  • sunapi365/branches
  • sunapi365/customers
  • sunapi365/products
  • sunapi365/settings
  • sunapi365/tickets
  • sunapi365/cash
  • sunapi365/documents
  • sunapi365/credentials
  • sunapi365/webhooks

Package layout

sdk/
  src/
    index.ts
    resources/
      client.ts
      errors.ts
      types.ts
      internal.ts
      auth.ts
      catalogs.ts
      companies.ts
      branches.ts
      customers.ts
      products.ts
      settings.ts
      tickets.ts
      cash.ts
      documents.ts
      credentials.ts
      webhooks.ts
  dist/

Endpoint strategy

The SDK defaults to the production API:

https://api.sunapi.site

That is the right default for a public npm package. Consumers can still override baseUrl for local development, staging, proxy routing, or tests.

const sdk = createSunApiSdk({
  baseUrl: "http://localhost:3000",
});

Authentication

Supported OAuth grants:

  • clientCredentials
  • password
  • refreshToken

Server-to-server integrations should prefer clientCredentials.

const tokens = await auth.oauthClientCredentials(
  sdk,
  "YOUR_CLIENT_ID",
  "YOUR_CLIENT_SECRET",
);

Document example

import { auth, createSunApiSdk } from "sunapi365";
import { invoices } from "sunapi365/documents";

const sdk = createSunApiSdk();
const tokens = await auth.oauthClientCredentials(
  sdk,
  "YOUR_CLIENT_ID",
  "YOUR_CLIENT_SECRET",
);

sdk.setAccessToken(tokens.accessToken);

const created = await invoices.create(sdk, "sandbox", {
  companyId: "YOUR_COMPANY_ID",
  branchId: "YOUR_BRANCH_ID",
  processingMode: "sync",
  series: "F001",
  issueDate: "2026-04-15",
  currency: "PEN",
  paymentType: "cash",
  paymentMethod: "transferencia",
  client: {
    documentType: "6",
    documentNumber: "RUC_CLIENTE_DEMO",
    legalName: "CLIENTE DEMO S.A.C.",
  },
  details: [
    {
      code: "PROD-001",
      description: "Producto demo",
      unit: "NIU",
      quantity: 1,
      unitPrice: 100,
      igvPercent: 18,
      igvAffectationType: "10",
    },
  ],
});

await invoices.sendToSunat(sdk, "sandbox", created.data.id, "sync");

Ticket and POS example

import { auth, createSunApiSdk } from "sunapi365";
import { tickets } from "sunapi365/tickets";

const sdk = createSunApiSdk();
const tokens = await auth.oauthClientCredentials(
  sdk,
  "YOUR_CLIENT_ID",
  "YOUR_CLIENT_SECRET",
);

sdk.setAccessToken(tokens.accessToken);

const created = await tickets.create(sdk, {
  companyId: "YOUR_COMPANY_ID",
  branchId: "YOUR_BRANCH_ID",
  customerName: "Cliente demo",
  targetDocumentType: "receipt",
  currency: "PEN",
  items: [
    {
      productId: "YOUR_PRODUCT_ID",
      quantity: 1,
      unitPrice: 30,
    },
  ],
});

await tickets.pay(sdk, created.data.id, {
  method: "cash",
  amount: 30,
});

Publication readiness

The package is already prepared with:

  • exports for root and subpath entrypoints
  • generated ESM, CommonJS, and type declarations
  • npm metadata for homepage, repository, and issues
  • publishConfig.access = public
  • a README structured for package discovery and installation