Registry / http-networking / snyk-api-ts-client

snyk-api-ts-client

JSON →
library1.11.2jsnpmunverified

This package provides a TypeScript client for interacting with Snyk API v1 endpoints. It is generated from Snyk's API Blueprint definitions, offering type definitions for both request bodies and responses to enhance developer experience with type safety. The current stable version is 1.11.2. The project is explicitly in 'maintenance mode,' meaning new feature development has ceased, with ongoing support limited to bug and security fixes. A critical distinction is that this client exclusively supports Snyk API v1 and does not offer integration with Snyk API v3 endpoints. Releases are irregular, typically driven by necessary bug fixes or updates to the underlying Snyk API v1 definitions. It requires Node.js version 14 or above.

npm install snyk-api-ts-client
INSTALL
IMPORT
SIG · SNYK-API-TS-CLIENT
S
snyk-api-ts-client
http-networkingjavascriptv1.11.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Orgs
import { Orgs } from 'snyk-api-ts-client'
const Orgs = require('snyk-api-ts-client')
The library is TypeScript-first and intended for ESM usage. CommonJS `require` is not officially supported and may lead to issues.
Org
import { Org } from 'snyk-api-ts-client'
import Org from 'snyk-api-ts-client'
Most API client classes are named exports, not default exports.
ProjectsPostBodyType
import { ProjectsPostBodyType } from 'snyk-api-ts-client/dist/client/generated/org'
import { ProjectsPostBodyType } from 'snyk-api-ts-client'
Specific types for request bodies often reside in nested paths reflecting their associated API resource.

This quickstart demonstrates how to initialize the Snyk API client, authenticate using an API token, and list projects for a specific organization using a POST request with filters. It also highlights type usage for request bodies.

import { Org, ProjectsPostBodyType } from 'snyk-api-ts-client'; const SNYK_API_TOKEN = process.env.SNYK_API_TOKEN ?? ''; // Replace with your Snyk API Token const ORG_ID = 'your-org-id'; // Replace with your Snyk Organization ID const main = async () => { if (!SNYK_API_TOKEN || !ORG_ID) { console.error('SNYK_API_TOKEN and ORG_ID must be set in environment variables or hardcoded.'); return; } try { // Initialize the Org client with authentication and specific orgId const orgClient = new Org({ orgId: ORG_ID, apiToken: SNYK_API_TOKEN }); // Example: List projects using a POST request with filters const body: ProjectsPostBodyType = { filters: { type: ['npm'], isPrivate: true } }; console.log(`Fetching projects for organization ${ORG_ID}...`); const result = await orgClient.projects.post(body); console.log('Successfully fetched projects:'); if (result && result.projects && result.projects.length > 0) { result.projects.slice(0, 3).forEach((project: any) => { console.log(` - Project Name: ${project.name}, ID: ${project.id}`); }); if (result.projects.length > 3) { console.log(` ... and ${result.projects.length - 3} more.`); } } else { console.log('No projects found with the specified filters.'); } // You can also get a full response object (including headers, status) by passing true // const fullResponse = await orgClient.projects.post(body, true); // console.log('Full response status:', fullResponse.status); } catch (error: any) { console.error('Error interacting with Snyk API:', error.message); if (error.response) { console.error('API Error Details:', error.response.data); } } }; main();
Debug
Known issues
deprecatedThe `/issues` endpoint was decommissioned as of version 1.7.3. Developers should migrate to the `/aggregated-issues` endpoint or the `/paths` endpoint for vulnerable path information, which now includes `fixVersion` details.
fix
Update your code to use `aggregated-issues` or `paths` endpoints. Consult the Snyk API documentation for updated endpoint details and data structures.
affects: >=1.7.3
gotchaThis client strictly supports Snyk API v1 endpoints. Snyk API v3 endpoints are explicitly not supported, and attempts to use v3-specific functionalities or data structures through this client will fail or result in unexpected behavior.
fix
Ensure your integration targets Snyk API v1. For Snyk API v3 interactions, an alternative client or direct HTTP requests to the v3 API are required.
affects: >=1.0.0
gotchaThe `snyk-api-ts-client` package is in 'maintenance mode'. This means no new features will be developed, and future releases will focus exclusively on bug fixes and security patches. Major API changes or new Snyk functionalities will not be integrated.
fix
Be aware of the limited development scope. For new features or breaking API changes in Snyk, you may need to consider alternative integration methods or direct API calls.
affects: >=1.9.1
gotchaThis package requires Node.js version 14 or above to function correctly. Using older Node.js versions (e.g., Node.js 12) may lead to compatibility issues or runtime errors.
fix
Upgrade your Node.js environment to version 14 or higher.
affects: >=1.11.2
Errors
Common errors & fixes
Error: Request failed with status code 401
Incorrect or missing Snyk API token, or an expired token.
fix
Verify that your `SNYK_API_TOKEN` environment variable or hardcoded token is correct, has the necessary permissions, and has not expired.
TypeError: Cannot read properties of undefined (reading 'someV3Endpoint')
Attempting to call a Snyk API v3 endpoint or property using this v1-only client.
fix
Confirm that the API endpoint or resource you are trying to access is part of Snyk API v1. This client does not support Snyk API v3.
TS2339: Property 'someNewV1Property' does not exist on type 'V1ResourceType'
The client's generated types are outdated relative to recent Snyk API v1 changes, or you're trying to access a property that doesn't exist.
fix
Ensure you are on the latest version of `snyk-api-ts-client`. If the issue persists, the client might not yet reflect the API change due to its maintenance mode, requiring a workaround or manual type assertion.
Upgrade
Version history
1.11.2latest on npm
Audit
Dependencies
axiosrequiredCore HTTP client for making API requests, frequently updated in patch releases.
Agent activity
8 hits · last 30 days
node
6
OpenAI (training)
1
Resources
snyk-api-ts-client — npm install snyk-api-ts-client · libregistry