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

backlight-api

v0.1.0

Published

Node client for the Backlight API

Readme

backlight-api

Node.js client for the Backlight JSON API.

Requirements

  • Node.js 18+
  • Backlight with JSON API enabled (Admin → Settings → JSON API → Enable: yes)

Installation

npm install backlight-api

Usage

import Backlight from 'backlight-api'

const api = new Backlight({ apiUrl: 'https://yoursite.com/backlight/api' })

const album = await api.getAlbum(12345)

Constructor

new Backlight(options?)

| Option | Type | Default | Description | |--------|------|---------|-------------| | apiUrl | string | '/backlight/api' | Full URL to the API endpoint |

Error handling

Methods throw on HTTP errors, so use try/catch or .catch():

// async/await
try {
  const album = await api.getAlbum(12345)
} catch (err) {
  console.error('Failed to fetch album:', err.message)
}

// Promise chain
api.getAlbum(12345)
  .then(album => { /* ... */ })
  .catch(err => console.error('Failed to fetch album:', err.message))

Methods

All methods return a Promise and throw on HTTP errors.

An apiToken option can be passed to any method when your Backlight installation requires token-based request signing.


getAlbum(id, options?)

Returns complete album data including title, description, and photos.

const album = await api.getAlbum(12345)
const album = await api.getAlbum(12345, { apiToken: 'your-token' })

getPagedAlbum(id, options?)

Returns album data in paged form.

const album = await api.getPagedAlbum(12345)

getPhoto(id, options?)

Returns data for a single photo.

const photo = await api.getPhoto(67890)

getPhotos(id, options?)

Returns the photos array for an album without additional album metadata. Supports optional range parameters.

const photos = await api.getPhotos(12345)

// First ten photos
const photos = await api.getPhotos(12345, { from: 1, to: 10 })

| Option | Type | Description | |--------|------|-------------| | from | string \| number | Start of photo range (1-based) | | to | string \| number | End of photo range | | apiToken | string | Request signing token |


getPhotosForPage(id, options)

Returns photos for a specific page of a paged album.

const photos = await api.getPhotosForPage(12345, { page: 2 })

| Option | Type | Description | |--------|------|-------------| | page | string \| number | Required. Page number | | apiToken | string | Request signing token |


getRoot(id?, options?)

Returns top-level set (publisher root) data. Pass an id to fetch a specific root; omit it to fetch all roots.

// All publisher roots
const roots = await api.getRoot()

// Specific root (e.g. default galleries set)
const root = await api.getRoot(1)

Finding IDs

Album and photo IDs are visible in the URL when browsing your site in Backlight's publisher interface.

Direct API Endpoints

The underlying REST endpoints, if you prefer to call them directly:

| Endpoint | Description | |----------|-------------| | GET /backlight/api/get_album/:id | Album with photos | | GET /backlight/api/get_paged_album/:id | Paged album | | GET /backlight/api/get_photo/:id | Single photo | | GET /backlight/api/get_photos/:id/(:from)/(:to) | Photos array | | GET /backlight/api/get_photos_for_page/:id/:page | Photos for a page | | GET /backlight/api/get_publisher_root/:id | Single top-level set | | GET /backlight/api/get_all_publisher_roots | All top-level sets |