# analytics-nodejs-client
**Repository Path**: mirrors_couchbaselabs/analytics-nodejs-client
## Basic Information
- **Project Name**: analytics-nodejs-client
- **Description**: Couchbase Node.js Analytics Client Library
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2025-08-06
- **Last Updated**: 2026-04-25
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Couchbase Node.js Analytics Client
Node.js client for [Couchbase](https://couchbase.com) Analytics
# Installing the SDK
To install the latest release using npm, run:
```console
npm install couchbase-analytics
```
To install the development version directly from github, run:
```console
npm install https://github.com/couchbase/analytics-nodejs-client
```
# Using the SDK
Some more examples are provided in the [examples directory](https://github.com/couchbase/analytics-nodejs-client/tree/main/examples).
## CommonJS
**Connecting and executing a query**
```javascript
const analytics = require('couchbase-analytics')
async function main() {
// Update this to your cluster
// IMPORTANT: The appropriate port needs to be specified. The SDK's default ports are 80 (http) and 443 (https).
// If attempting to connect to Capella, the correct ports are most likely to be 8095 (http) and 18095 (https).
// Capella example: https://cb.2xg3vwszqgqcrsix.cloud.couchbase.com:18095
const clusterEndpoint = 'https://--your-instance--'
const username = 'username'
const password = 'password'
// User Input ends here.
const credential = new analytics.Credential(username, password)
const cluster = analytics.createInstance(clusterEndpoint, credential)
// Execute a streaming query with positional arguments.
let qs = 'SELECT * FROM `travel-sample`.inventory.airline LIMIT 10;'
let res = await cluster.executeQuery(qs)
for await (let row of res.rows()) {
console.log('Found row: ', row)
}
console.log('Metadata: ', res.metadata())
// Execute a streaming query with positional arguments.
qs =
'SELECT * FROM `travel-sample`.inventory.airline WHERE country=$1 LIMIT $2;'
res = await cluster.executeQuery(qs, { parameters: ['United States', 10] })
for await (let row of res.rows()) {
console.log('Found row: ', row)
}
console.log('Metadata: ', res.metadata())
// Execute a streaming query with named parameters.
qs =
'SELECT * FROM `travel-sample`.inventory.airline WHERE country=$country LIMIT $limit;'
res = await cluster.executeQuery(qs, {
namedParameters: { country: 'United States', limit: 10 },
})
for await (let row of res.rows()) {
console.log('Found row: ', row)
}
console.log('Metadata: ', res.metadata())
}
main()
.then(() => {
console.log('Finished. Exiting app...')
})
.catch((err) => {
console.log('ERR: ', err)
console.log('Exiting app...')
process.exit(1)
})
```
## ES Modules
**Connecting and executing a query**
```javascript
import { Certificates, Credential, createInstance } from "couchbase-analytics"
async function main() {
// Update this to your cluster
// IMPORTANT: The appropriate port needs to be specified. The SDK's default ports are 80 (http) and 443 (https).
// If attempting to connect to Capella, the correct ports are most likely to be 8095 (http) and 18095 (https).
// Capella example: https://cb.2xg3vwszqgqcrsix.cloud.couchbase.com:18095
const clusterEndpoint = 'https://--your-instance--'
const username = 'username'
const password = 'password'
// User Input ends here.
const credential = new Credential(username, password)
const cluster = createInstance(clusterEndpoint, credential)
// Execute a streaming query with positional arguments.
let qs = "SELECT * FROM `travel-sample`.inventory.airline LIMIT 10;"
let res = await cluster.executeQuery(qs)
for await (let row of res.rows()) {
console.log("Found row: ", row)
}
console.log("Metadata: ", res.metadata())
// Execute a streaming query with positional arguments.
qs =
"SELECT * FROM `travel-sample`.inventory.airline WHERE country=$1 LIMIT $2;"
res = await cluster.executeQuery(qs, { parameters: ["United States", 10] })
for await (let row of res.rows()) {
console.log("Found row: ", row)
}
console.log("Metadata: ", res.metadata())
// Execute a streaming query with named parameters.
qs =
"SELECT * FROM `travel-sample`.inventory.airline WHERE country=$country LIMIT $limit;"
res = await cluster.executeQuery(qs, {
namedParameters: { country: "United States", limit: 10 },
})
for await (let row of res.rows()) {
console.log("Found row: ", row)
}
console.log("Metadata: ", res.metadata())
}
main()
.then(() => {
console.log("Finished. Exiting app...")
})
.catch((err) => {
console.log("ERR: ", err)
console.log("Exiting app...")
process.exit(1)
})
```