Socket JavaScript SDK

Use the Socket API from JavaScript/TypeScript.

The Socket JavaScript SDK provides typed access to the Socket API from Node.js.

Install

The SDK requires Node.js 24 or newer.
Use a .mjs file or configure TypeScript for ESM.

pnpm add @socketsecurity/sdk

Authenticate and check quota

Create an API token and provide it through the SOCKET_API_TOKEN environment variable.

import { SocketSdk } from '@socketsecurity/sdk'

const token = process.env.SOCKET_API_TOKEN
if (!token) {
  throw new Error('Set SOCKET_API_TOKEN before running this script.')
}

const sdk = new SocketSdk(token)
const quota = await sdk.getQuota()
if (!quota.success) {
  throw new Error(`Socket API ${quota.status}: ${quota.error}`)
}

console.log(`Available quota: ${quota.data.quota}`)

API documentation

Use the SDK repository for method signatures, client options, and detailed examples:

Repository documentation follows the latest source and can include APIs that are not yet in the published package.
Use the release history to check availability for your installed version.

The Socket REST API reference describes endpoint behavior, request fields, and permissions.


Did this page help you?