Skip to main content

Basic Usage

To run a basic scan, import the Scanner class and call scan_folder_with_options. By default, results are written to stdout as JSON:
from scanoss.scanner import Scanner
from scanoss.scanoss_settings import ScanossSettings

def main():
    scanner = Scanner(scanoss_settings=ScanossSettings())
    scanner.scan_folder_with_options('/path/to/project')

if __name__ == "__main__":
    main()
Note: ScanossSettings() is initialised here with its default values. Replace '/path/to/project' with the path to the directory you want to scan.

Saving Results to a File

To write results to a file rather than stdout, pass the desired output path as the scan_output argument to the Scanner constructor:
from scanoss.scanner import Scanner
from scanoss.scanoss_settings import ScanossSettings

def main():
    scanner = Scanner(
        scan_output='results.json',
        scanoss_settings=ScanossSettings(),
    )
    scanner.scan_folder_with_options('/path/to/project')

if __name__ == "__main__":
    main()
For information on configuring a custom API endpoint or providing an API key, see the Authentication page.