JavaScript SDK for Socket.dev API - Security analysis, vulnerability scanning, and compliance monitoring for software supply chains.
pnpm add @socketsecurity/sdk
import { SocketSdk } from '@socketsecurity/sdk'
const client = new SocketSdk('your-api-key', {
retries: 3, // Retry failed requests up to 3 times
retryDelay: 1000, // Start with 1s delay, exponential backoff
timeout: 30000, // 30 second timeout
})
// Check your quota
const quota = await client.getQuota()
if (quota.success) {
console.log(`Available quota: ${quota.data.quota} units`)
}
// Analyze a package
const result = await client.getScoreByNpmPackage('express', '4.18.0')
if (result.success) {
console.log(`Security Score: ${result.data.score}/100`)
}
// Batch analyze multiple packages
const batchResult = await client.batchPackageFetch({
components: [
{ purl: 'pkg:npm/express@4.18.0' },
{ purl: 'pkg:npm/react@18.0.0' }
]
})
Quick security checks: batchPackageFetch()
• batchPackageStream()
• getIssuesByNpmPackage()
• getScoreByNpmPackage()
Project scanning: createDependenciesSnapshot()
• createOrgFullScan()
• createScanFromFilepaths()
• getScan()
• getScanList()
• getSupportedScanFiles()
Organizations and repositories: getOrganizations()
• createOrgRepo()
• getOrgRepo()
• getOrgRepoList()
• updateOrgRepo()
• deleteOrgRepo()
Security configuration: getOrgSecurityPolicy()
• updateOrgSecurityPolicy()
• getOrgLicensePolicy()
• updateOrgLicensePolicy()
• postSettings()
Deep analysis: getOrgFullScanList()
• getOrgFullScanMetadata()
• getOrgFullScanBuffered()
• streamOrgFullScan()
• deleteOrgFullScan()
Scan comparison: createOrgDiffScanFromIds()
• getDiffScanById()
• listOrgDiffScans()
• deleteOrgDiffScan()
Security fixes: streamPatchesFromScan()
• viewPatch()
Alert management: getOrgTriage()
• updateOrgAlertTriage()
SBOM export: exportCDX()
• exportSPDX()
• searchDependencies()
• uploadManifestFiles()
Categorization: createOrgRepoLabel()
• getOrgRepoLabel()
• getOrgRepoLabelList()
• updateOrgRepoLabel()
• deleteOrgRepoLabel()
Usage metrics: getQuota()
• getOrgAnalytics()
• getRepoAnalytics()
• getAuditLogEvents()
API tokens: getAPITokens()
• postAPIToken()
• postAPITokensRotate()
• postAPITokensRevoke()
• postAPITokenUpdate()
Feature access: getEnabledEntitlements()
• getEntitlements()
Cost helpers: getQuotaCost()
• getRequiredPermissions()
• calculateTotalQuotaCost()
• hasQuotaForMethods()
• getMethodsByQuotaCost()
• getMethodsByPermissions()
• getQuotaUsageSummary()
• getAllMethodRequirements()
Raw API access: getApi()
• sendApi()
→ Quota Management - Cost tiers: 0 (free), 10 (standard), 100 (batch/uploads)
→ Testing Utilities - Mock factories, fixtures, type guards
- Socket.dev API Reference - Official API documentation
- Socket CLI - Command-line interface
- Socket GitHub App - GitHub integration
MIT