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

billbee-node-sdk

v1.0.0

Published

πŸ”Œ The comprehensive Billbee API SDK for Node.js πŸ’» - Complete TypeScript implementation with full type safety

Readme

Billbee Node.js SDK

πŸ”Œ The comprehensive Billbee API SDK for Node.js πŸ’»

npm version TypeScript License: MIT

A comprehensive TypeScript/Node.js SDK for the Billbee API, providing full access to all Billbee functionality with type safety and modern JavaScript features.

πŸš€ Features

  • Complete API Coverage - All Billbee API endpoints supported
  • TypeScript First - Full type safety with comprehensive type definitions
  • PHP SDK Compatible - Method names and patterns match the official PHP SDK
  • Batch Operations - Execute multiple API calls efficiently
  • Modern Async/Await - Promise-based API with async/await support
  • Automatic Rate Limiting - Built-in handling of API rate limits
  • Error Handling - Comprehensive error handling and reporting
  • Extensible - Easy to extend and customize

πŸ“¦ Installation

npm install billbee-node-sdk

πŸ”§ Prerequisites

  • Node.js 16+
  • A Billbee account with API access enabled
  • API credentials (username, API password, and API key)

Getting API Credentials

  1. Enable API Access: Go to Settings β†’ API in your Billbee account
  2. API Key: Contact Billbee support ([email protected]) to get an API key
  3. API Password: Generate an API password in your Billbee account settings

πŸš€ Quick Start

import { BillbeeClient } from 'billbee-node-sdk'

const client = new BillbeeClient({
  username: 'YOUR_BILLBEE_USERNAME',
  apiPassword: 'YOUR_API_PASSWORD',
  apiKey: 'YOUR_API_KEY'
})

// Get products (PHP-compatible alias)
const products = await client.products().getProducts()
console.log(`Found ${products.Data.length} products`)

// Alternative: semantic method names
// const products = await client.articles().getList()

// Get orders
const orders = await client.orders().getOrders({ page: 1, pageSize: 10 })
console.log(`Found ${orders.Data.length} orders`)

πŸ“š API Documentation

Articles/Products

// Get all products (PHP-compatible)
const products = await client.products().getProducts((page = 1), (pageSize = 50))
// Alternative: client.articles().getProducts() or client.articles().getList()

// Get single product (PHP-compatible)
const product = await client.products().getProduct(123) // by ID
const product = await client.products().getProduct('SKU-123', 'sku') // by SKU
const product = await client.products().getProduct('1234567890123', 'ean') // by EAN

// Create product (PHP-compatible)
const newProduct = await client.products().createArticle({
  Title: 'New Product',
  SKU: 'NEW-001',
  Price: 29.99,
  StockCurrent: 100,
  VatIndex: 1
})

// Update product (PHP-compatible)
await client.products().patchArticle(123, {
  Price: 34.99,
  StockCurrent: 75
})

// Update stock
await client.articles().updateStock({
  SKU: 'PRODUCT-001',
  Stock: 50
})

// Get product images
const images = await client.articles().getImages(123)

// Upload image
await client.articles().uploadImage(123, base64ImageData, 1, true)

Orders

// Get orders with filtering
const orders = await client.orders().getOrders({
  minOrderDate: '2023-01-01',
  maxOrderDate: '2023-12-31',
  orderStateId: [1, 2, 3], // ordered, confirmed, paid
  page: 1,
  pageSize: 50
})

// Get single order
const order = await client.orders().getOrder(12345)

// Create order
const newOrder = await client.orders().postNewOrder({
  OrderNumber: 'ORDER-001',
  Buyer: {
    Email: '[email protected]',
    FirstName: 'John',
    LastName: 'Doe'
  },
  OrderItems: [
    {
      Product: { Id: 123 },
      Quantity: 2,
      TotalPrice: 59.98
    }
  ]
})

// Update order state
await client.orders().updateState(12345, {
  NewStateId: 3, // paid
  Comment: 'Payment received'
})

// Add shipment
await client.orders().addShipment(12345, {
  ShippingId: 'TRACK123',
  ShippingProviderName: 'DHL',
  TrackingNumber: 'TRACK123'
})

// Create invoice
const invoice = await client.orders().createInvoice(12345, {
  includeInvoicePdf: true
})

// Send message to customer
await client.orders().sendMessage(12345, {
  Subject: 'Order Update',
  Body: 'Your order has been processed.'
})

Customers

// Get customers
const customers = await client.customers().getAll()

// Get single customer
const customer = await client.customers().getOne(123)

// Create customer
const newCustomer = await client.customers().create({
  Name: 'John Doe',
  Email: '[email protected]',
  Type: 0 // Consumer
})

// Get customer addresses
const addresses = await client.customers().getCustomerAddresses(123)

// Get customer orders
const customerOrders = await client.customers().getCustomerOrders(123)

Events

// Get events (throttled to 2 calls per page per hour)
const events = await client.events().getEvents({
  minDate: '2023-01-01',
  maxDate: '2023-12-31',
  typeId: [1, 2, 3], // specific event types
  orderId: 12345
})

Enums & Reference Data

// Get order states
const orderStates = await client.enums().getOrderStates()

// Get payment types
const paymentTypes = await client.enums().getPaymentTypes()

// Get shipping carriers
const carriers = await client.enums().getShippingCarriers()

πŸ”„ Batch Operations

Execute multiple API calls efficiently:

// Enable batch mode
client.enableBatchMode()

// Queue multiple requests
client.articles().getProducts(1, 10) // Returns null in batch mode
client.orders().getOrders({ page: 1 }) // Returns null in batch mode
client.customers().getAll() // Returns null in batch mode

// Execute all queued requests
const results = await client.executeBatch()

// results[0] = products response
// results[1] = orders response
// results[2] = customers response

// Disable batch mode
client.disableBatchMode()

πŸ”„ PHP SDK Compatibility

This SDK provides full compatibility with the official PHP SDK method names and patterns:

// PHP SDK style
const client = new BillbeeClient(config)
const products = await client.products().getProducts(1, 10)
const product = await client.products().getProduct(123)
const order = await client.orders().getOrder(456)

// Plus modern alternatives
const products = await client.articles().getList({ page: 1, pageSize: 10 })
const product = await client.articles().get(123)
const order = await client.orders().get(456)

Method Mapping

| PHP SDK | Node.js SDK | Alternative | | --------------------- | ------------------- | ------------------- | | $client->products() | client.products() | client.articles() | | ->getProducts() | .getProducts() | .getList() | | ->getProduct() | .getProduct() | .get() | | ->getOrders() | .getOrders() | .getList() | | ->getOrder() | .getOrder() | .get() |

πŸ”§ Configuration

const client = new BillbeeClient({
  username: 'YOUR_BILLBEE_USERNAME',
  apiPassword: 'YOUR_API_PASSWORD',
  apiKey: 'YOUR_API_KEY',
  baseUrl: 'https://app.billbee.io/api/v1' // optional, defaults to official API
})

πŸ›‘οΈ Error Handling

try {
  const product = await client.articles().getProduct(123)
} catch (error) {
  if (error.message.includes('Rate limit exceeded')) {
    console.log('Rate limited, retry later')
  } else if (error.message.includes('Authentication failed')) {
    console.log('Check your API credentials')
  } else {
    console.error('API Error:', error.message)
  }
}

🎯 TypeScript Support

The SDK is built with TypeScript and provides comprehensive type definitions:

import { BillbeeClient, Article, Order, Customer, OrderState } from 'billbee-node-sdk'

const client = new BillbeeClient(config)

// Full type safety
const product: Article = await client.articles().getProduct(123)
const order: Order = await client.orders().getOrder(456)

// Enum support
const newState: OrderState = OrderState.Paid

πŸ“ Advanced Usage

Custom HTTP Client

import { HttpClient, BillbeeConfig } from 'billbee-node-sdk'

const httpClient = new HttpClient(config)

// Direct HTTP calls
const response = await httpClient.get('/products', { page: 1 })

Rate Limiting

The SDK automatically handles Billbee's rate limits:

  • Maximum 2 requests per second per API key/user combination
  • Automatic retry with backoff on rate limit errors
  • Special handling for throttled endpoints (events, invoices)

πŸ§ͺ Testing

npm test

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Inspired by the official Billbee PHP SDK
  • Built for the Node.js/TypeScript community
  • Thanks to Billbee for providing a comprehensive API

πŸ“ž Support


Made with ❀️ for the Node.js community