pysnyk is a Python client library for interacting with the Snyk API, enabling programmatic access to Snyk's security analysis and vulnerability management capabilities. It provides an object-oriented interface to various Snyk resources like organizations, projects, and issues. The library is currently at version 0.9.19 and maintains a frequent release cadence, often with patch versions addressing bug fixes and minor enhancements.
pip install pysnykVerified import paths — ran on the pinned version, not inferred.
This quickstart initializes the SnykClient using an API token, preferably from the `SNYK_TOKEN` environment variable. It then fetches and prints all accessible Snyk organizations and, for the first organization found, lists its associated projects.
Review any code that makes assumptions about the number of items per page or the total API calls for `.all()` methods. If a specific page size is required, explicitly pass the `per_page` argument (e.g., `client.organizations.all(per_page=50)`).
Set the `SNYK_TOKEN` environment variable with your Snyk API token (e.g., `export SNYK_TOKEN='your_api_token'`). The `SnykClient` constructor will automatically pick it up. Alternatively, pass it explicitly `SnykClient(os.environ.get('SNYK_TOKEN'))`.Catch potential exceptions when calling `project.dependency_graph` and verify the project type beforehand if possible. Refer to Snyk API documentation for supported project types for dependency graph retrieval.
Ensure you are using a Python version between 3.7 and 3.9 (inclusive for minor versions) and that the package name `pysnyk` is spelled correctly. Upgrade Python if necessary.
Verify that your `SNYK_TOKEN` environment variable is correctly set and contains a valid, non-expired Snyk API token with the appropriate scopes. Generate a new token if unsure.
Upgrade `pysnyk` to the latest version. If the issue persists with the latest version, consider accessing the raw data via `obj.data` or `obj.json` properties (if available for the specific object) and parsing the JSON manually, or report the issue to the `pysnyk` maintainers.
No dependency data recorded yet.