@socketsecurity/sdk
v3.2.0
Published
SDK for the Socket API client
Readme
@socketsecurity/sdk
JavaScript SDK for Socket.dev API.
Install
pnpm add @socketsecurity/sdkUsage
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/[email protected]' },
{ purl: 'pkg:npm/[email protected]' }
]
})Documentation
| 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 |
Examples
See usage-examples.md for complete examples including:
- Package security analysis
- Batch operations
- Full scans with SBOM
- Policy management
- Quota planning
License
MIT
