{"library":"socketdev","title":"Socket Security Python SDK","type":"library","description":"The Socket Security Python SDK provides an interface to interact with the Socket API for software supply chain security scanning. It allows users to scan packages, retrieve security insights, and manage their Socket account programmatically. The current version is 3.0.32, and it follows an active release cadence with regular updates.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install socketdev"],"cli":{"name":"socket","version":"sh: 1: socket: not found"}},"imports":["from socketdev import SocketSDKClient"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":"https://socket.dev","github":"https://github.com/socketdev/socketdev","docs":null,"changelog":null,"pypi":"https://pypi.org/project/socketdev/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import os\nimport socketdev\n\n# Ensure you have SOCKET_API_KEY set as an environment variable or pass api_key directly\n# e.g., os.environ['SOCKET_API_KEY'] = 'your_api_key_here'\n\ntry:\n    client = socketdev.SocketSDKClient(api_key=os.environ.get('SOCKET_API_KEY', ''))\n\n    # Example: Scan a package (npm, lodash, v4.17.21)\n    result = client.scan_package(\n        ecosystem=\"npm\", \n        package=\"lodash\", \n        version=\"4.17.21\", \n        options={\"allow_insecure_versions\": True}\n    )\n    print(f\"Scan status: {result.status}\")\n    print(f\"Issue count: {result.issues_count}\")\n    \n    # Accessing specific issues if available\n    if result.issues:\n        print(\"First issue type:\", result.issues[0].issue_type)\n\nexcept socketdev.exceptions.SocketApiException as e:\n    print(f\"API Error: {e.status_code} - {e.message}\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\n","lang":"python","description":"Initializes the SocketSDKClient using an API key (preferably from an environment variable) and performs a basic package scan. Demonstrates handling of the returned `ScanPackageResult` object.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}