{"id":18801,"library":"snyk-api-import","title":"Snyk API Import","description":"Snyk API Import is a CLI tool for importing projects into Snyk via the Snyk API at a controlled pace, with built-in rate limiting handling, queuing, and retries. Current stable version is 2.23.1, with releases on a monthly/quarterly cadence. It supports GitHub, GitLab, Bitbucket Server, Bitbucket Cloud, and Azure Repos. Key differentiators include automatic rate limit handling for SCMs, queuing to reduce failures, and ability to resume after interruption. This repository is in maintenance mode (no new features, only bug & security fixes). Node.js >=20 required.","status":"maintenance","version":"2.23.1","language":"javascript","source_language":"en","source_url":"https://github.com/snyk/snyk-api-import","tags":["javascript","typescript"],"install":[{"cmd":"npm install snyk-api-import","lang":"bash","label":"npm"},{"cmd":"yarn add snyk-api-import","lang":"bash","label":"yarn"},{"cmd":"pnpm add snyk-api-import","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only since v2.0; requires Node.js >=20 and \"type\": \"module\" in package.json.","wrong":"const snykApiImport = require('snyk-api-import')","symbol":"default","correct":"import snykApiImport from 'snyk-api-import'"},{"note":"Named export for programmatic use; ESM-only.","wrong":"const { runImport } = require('snyk-api-import')","symbol":"runImport","correct":"import { runImport } from 'snyk-api-import'"},{"note":"Available as named export for generating import data programmatically.","wrong":null,"symbol":"generateImportData","correct":"import { generateImportData } from 'snyk-api-import'"},{"note":"This is a named export, not default. TypeScript types included.","wrong":"import SnykApiImportError from 'snyk-api-import'","symbol":"SnykApiImportError","correct":"import { SnykApiImportError } from 'snyk-api-import'"}],"quickstart":{"code":"import { runImport } from 'snyk-api-import';\n\nconst options = {\n  org: process.env.SNYK_ORG_ID ?? '',\n  source: process.env.IMPORT_SOURCE ?? 'github',\n  integrationId: process.env.SNYK_INTEGRATION_ID ?? '',\n  concurrency: 5,\n  skipExisting: true\n};\n\nasync function main() {\n  try {\n    const result = await runImport(options);\n    console.log('Import completed:', result);\n  } catch (error) {\n    console.error('Import failed:', error);\n  }\n}\n\nmain();","lang":"typescript","description":"Demonstrates programmatic usage of runImport with async/await and environment variables for credentials."},"warnings":[{"fix":"Use --force flag to re-import existing targets","message":"Import will skip repos already imported unless --force is used","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Rate limiting is now automatic; remove the flag","message":"The --rateLimit option has been deprecated since v2.0","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Upgrade to Node.js 20 or later","message":"Node.js 18 support dropped in v2.0, requires >=20","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Convert to ES module imports or use dynamic import()","message":"ESM-only since v2.0; CommonJS require() no longer works","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Set SNYK_TOKEN environment variable and omit --token","message":"The --token flag is deprecated; use SNYK_TOKEN environment variable","severity":"deprecated","affected_versions":">=1.20.0"},{"fix":"Set SNAPI_BASE_URL instead of SNYK_API","message":"SNYK_API environment variable removed; use SNAPI_BASE_URL instead","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Ensure your GitHub personal access token has sufficient rate limits; consider using a GitHub App token","message":"Large imports may hit GitHub API rate limits; script handles 429 responses but may slow down","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install snyk-api-import@latest' and ensure 'type': 'module' in package.json","cause":"Missing npm install or wrong environment (CJS vs ESM)","error":"Cannot find module 'snyk-api-import'"},{"fix":"Install globally: 'npm install -g snyk-api-import' or use npx: 'npx snyk-api-import'","cause":"Package not installed globally or not in PATH","error":"snyk-api-import: command not found"},{"fix":"Set SNYK_TOKEN environment variable: 'export SNYK_TOKEN=your-token'","cause":"Missing environment variable for authentication","error":"Error: SNYK_TOKEN is not set"},{"fix":"Add 'type': 'module' to package.json or rename file to .mjs","cause":"Running ESM code without module context","error":"SyntaxError: Cannot use import statement outside a module"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}