JavaScript SDK for Socket.dev API.
pnpm add @socketsecurity/sdkimport { 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' }
]
})| Guide | Description |
|---|---|
| Getting Started | Quick start for contributors (5 min setup) |
| API Reference | Complete API method documentation |
| Usage Examples | Real-world patterns and code samples |
| Quota Management | Cost tiers (0/10/100) and utilities |
| Testing Guide | Test helpers, fixtures, and patterns |
| Method Reference | Quick method selection guide |
See usage-examples.md for complete examples including:
- Package security analysis
- Batch operations
- Full scans with SBOM
- Policy management
- Quota planning
MIT