Registry / database / firebase-rest

firebase-rest

JSON →
library1.0.0jsnpmunverified

A lightweight REST client for Firebase Realtime Database, version 1.0.0. It wraps the standard Fetch API to provide a simple interface for CRUD operations, supporting both raw and JSON-parsed responses via `Client` and `JSONClient`. Unlike the official Firebase SDK, it avoids heavy dependencies and can be used in Node.js environments without a full Firebase setup. The package is ESM-only, requires `node-fetch` under the hood, and includes TypeScript type definitions.

npm install firebase-rest
INSTALL
IMPORT
SIG · FIREBASE-REST
F
firebase-rest
databasejavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

FirebaseREST
import FirebaseREST from 'firebase-rest'
import { FirebaseREST } from 'firebase-rest'
This is the default export. Named export does not exist.
Client
const { Client } = FirebaseREST;
import { Client } from 'firebase-rest'
Client is a property of the default export, not a separate named export.
JSONClient
const { JSONClient } = FirebaseREST;
import { JSONClient } from 'firebase-rest'
JSONClient is a property of the default export, not a separate named export.

Demonstrates basic CRUD operations using JSONClient with authentication from environment variable.

import FirebaseREST from 'firebase-rest'; const client = new FirebaseREST.JSONClient('https://your-db.firebaseio.com', { auth: process.env.FIREBASE_SECRET ?? '' }); async function main() { // Write data await client.put('/users/1', { name: 'Alice', email: 'alice@example.com' }); // Read data const res = await client.get('/users/1'); console.log(res.body); // Update data await client.patch('/users/1', { email: 'alice@newdomain.com' }); // Delete data await client.delete('/users/1'); } main().catch(console.error);
Debug
Known issues
breakingThe package is ESM-only; CommonJS require() works only via .default at the end.
fix
Use `const FirebaseREST = require('firebase-rest').default;` instead of `const FirebaseREST = require('firebase-rest');`
affects: >=1.0.0
gotchaClient and JSONClient are properties of the default export, not named exports.
fix
Access them as `FirebaseREST.Client` or `FirebaseREST.JSONClient` after importing the default.
affects: >=1.0.0
gotchaThe payload for PUT/POST/PATCH must be a plain object or value, not a stringified JSON.
fix
Pass the object directly; the library handles JSON.stringify internally.
affects: >=1.0.0
gotchaThe `auth` option is required for authenticated requests; omitting it may result in 401 errors if the database has security rules.
fix
Always provide `auth` either in options or via query parameters.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: FirebaseREST is not a constructor
Using CommonJS require without .default
fix
const FirebaseREST = require('firebase-rest').default;
Cannot find module 'firebase-rest'
Package not installed or wrong package name
fix
Run `npm install firebase-rest` and ensure correct spelling.
TypeError: client.get is not a function
Client not instantiated correctly (e.g., importing named export instead of using default export property)
fix
Ensure you use the correct import: `import FirebaseREST from 'firebase-rest'` then `new FirebaseREST.JSONClient(...)`
Unexpected token o in JSON at position 1
Passing a string instead of a JavaScript object as payload
fix
Pass a plain object, e.g., `{ key: 'value' }`, not `JSON.stringify({ key: 'value' })`
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
node-fetchrequiredHTTP client for making REST requests
Agent activity
7 hits · last 30 days
node
6
Resources
firebase-rest — npm install firebase-rest · libregistry