{"id":14903,"library":"scrapli","title":"scrapli","description":"Scrapli (scrape cli) is a fast, flexible, Python 3.9+ library designed for connecting to and interacting with network devices (routers, switches, firewalls) via SSH or Telnet. It supports both synchronous and asynchronous operations, offering a consistent API across different connection types. The library is actively developed, with frequent releases including release candidates for a major v2.0.0 update, indicating ongoing enhancements and maintenance.","status":"active","version":"2026.2.20","language":"en","source_language":"en","source_url":"https://github.com/carlmontanari/scrapli","tags":["network automation","ssh","telnet","cli scraping","asyncio","network devices","configuration management"],"install":[{"cmd":"pip install scrapli","lang":"bash","label":"Standard Installation"},{"cmd":"pip install scrapli[paramiko,ssh2,asyncssh,textfsm,genie,netconf,community,full]","lang":"bash","label":"Installation with optional extras"}],"dependencies":[{"reason":"Runtime requirement","package":"Python","optional":false},{"reason":"Optional transport backend for SSH","package":"paramiko","optional":true},{"reason":"Optional transport backend for SSH (wrapper around libssh2 for speed)","package":"ssh2-python","optional":true},{"reason":"Optional transport backend for asynchronous SSH","package":"asyncssh","optional":true},{"reason":"For parsing command output using TextFSM templates (requires ntc-templates)","package":"textfsm","optional":true},{"reason":"For parsing command output using Cisco Genie (installs as 'pyats[library]')","package":"pyats","optional":true},{"reason":"Required by scrapli_netconf for XML parsing","package":"lxml","optional":true},{"reason":"Provides NETCONF client functionality built on scrapli core","package":"scrapli_netconf","optional":true},{"reason":"Provides drivers for additional network device platforms not in core scrapli","package":"scrapli_community","optional":true}],"imports":[{"note":"General factory class for platform-agnostic connections","symbol":"Scrapli","correct":"from scrapli import Scrapli"},{"note":"Specific synchronous driver for Cisco IOS-XE devices. Replace 'IOSXEDriver' with the appropriate driver for your platform (e.g., 'NXOSDriver', 'JunosDriver', 'EOSDriver', 'IOSXRDriver').","symbol":"IOSXEDriver","correct":"from scrapli.driver.core import IOSXEDriver"},{"note":"Specific asynchronous driver for Cisco IOS-XE devices. Replace 'AsyncIOSXEDriver' with the appropriate driver for your platform.","symbol":"AsyncIOSXEDriver","correct":"from scrapli.driver.core import AsyncIOSXEDriver"},{"note":"The 'NetconfScrape' class was deprecated and removed in 'scrapli_netconf' v2022.01.30. Use 'NetconfDriver' instead for NETCONF connections.","wrong":"from scrapli_netconf import NetconfScrape","symbol":"NetconfDriver","correct":"from scrapli_netconf.driver import NetconfDriver"}],"quickstart":{"code":"import os\nfrom scrapli.driver.core import IOSXEDriver\nfrom scrapli.exceptions import ScrapliException\n\ndef get_device_info():\n    device = {\n        \"host\": os.environ.get(\"SCRAPLI_HOST\", \"your_device_ip\"),\n        \"auth_username\": os.environ.get(\"SCRAPLI_USERNAME\", \"admin\"),\n        \"auth_password\": os.environ.get(\"SCRAPLI_PASSWORD\", \"password\"),\n        \"auth_strict_key\": False, # Often needed for labs or unknown hosts\n        \"transport\": \"system\", # 'system', 'paramiko', 'ssh2', 'telnet'\n        \"port\": 22 # Default for SSH, 23 for Telnet\n    }\n    return device\n\ndef main_sync():\n    device_info = get_device_info()\n    try:\n        # Using a context manager for automatic open/close\n        with IOSXEDriver(**device_info) as conn:\n            print(f\"Connected to {conn.host} successfully.\")\n            response = conn.send_command(\"show version\")\n            if response.failed:\n                print(f\"Command failed: {response.result}\")\n                return\n            print(\"--- Show Version Output ---\")\n            print(response.result)\n\n            response_config = conn.send_configs([\"interface Loopback0\", \"description Test Loopback\"]) \n            if response_config.failed:\n                print(f\"Config failed: {response_config.result}\")\n                return\n            print(\"--- Configuration Output ---\")\n            print(response_config.result)\n\n    except ScrapliException as e:\n        print(f\"Scrapli error: {e}\")\n    except Exception as e:\n        print(f\"An unexpected error occurred: {e}\")\n\nif __name__ == \"__main__\":\n    # Example usage: Set environment variables or update `get_device_info` with actual values\n    # os.environ['SCRAPLI_HOST'] = '172.18.0.11'\n    # os.environ['SCRAPLI_USERNAME'] = 'vrnetlab'\n    # os.environ['SCRAPLI_PASSWORD'] = 'VR-netlab9'\n    main_sync()\n","lang":"python","description":"This quickstart demonstrates a synchronous connection to a Cisco IOS-XE device, sending a 'show version' command and a configuration. It uses the `IOSXEDriver` with a context manager for automatic connection management. Device credentials are retrieved from environment variables for security. Replace `IOSXEDriver` with `AsyncIOSXEDriver` and `conn.send_command` with `await conn.send_command` within an `async def` function if using asynchronous operations."},"warnings":[{"fix":"Consult the official v2.0.0 documentation and migration guides upon final release. For now, pin to `scrapli<2.0.0` for stability.","message":"Scrapli v2.0.0, currently in Release Candidate, introduces significant architectural changes ('scrapli2'). While the core API aims for consistency between sync/async, users should review the changelog for specific breaking changes in import paths, class structures, or method signatures upon the final v2.0.0 release.","severity":"breaking","affected_versions":">=2.0.0-rc.1"},{"fix":"Upgrade your Python environment to 3.9 or higher. The current version requires Python >=3.9.","message":"Support for Python 3.6 was dropped in scrapli core (v2022.01.30) and related libraries like `scrapli_netconf` and `scrapli_community`.","severity":"deprecated","affected_versions":">=2022.01.30"},{"fix":"Update your imports from `from scrapli_netconf import NetconfScrape` to `from scrapli_netconf.driver import NetconfDriver`.","message":"In `scrapli_netconf`, `NetconfScrape` and `AsyncNetconfScrape` classes were renamed to `NetconfDriver` and `AsyncNetconfDriver`, respectively, and subsequently removed.","severity":"deprecated","affected_versions":"scrapli_netconf >=2022.01.30"},{"fix":"Include `auth_strict_key=False` in your device dictionary if you encounter host key verification issues. For production, consider proper `known_hosts` management or specifying an SSH config file.","message":"By default, scrapli uses 'system' transport, leveraging the local SSH binary. While this has zero external Python dependencies, it may require `auth_strict_key=False` in device arguments to bypass strict host key checking, especially in lab environments or when `known_hosts` is not managed.","severity":"gotcha","affected_versions":"All"},{"fix":"For unsupported platforms, install `scrapli-community` (`pip install scrapli-community`) and import drivers from there, or use `from scrapli.driver.generic import GenericDriver` and define custom interaction logic.","message":"Scrapli's core library supports a limited set of 'NAPALM-like' platforms (Cisco IOS-XE, IOS-XR, NX-OS, Arista EOS, Juniper JunOS). For other network operating systems, you will need `scrapli_community` or to use `GenericDriver`/`NetworkDriver` with custom privilege levels and on-open/on-close functions.","severity":"gotcha","affected_versions":"All"},{"fix":"When using Telnet, ensure you explicitly set `transport='telnet'` and `port=23` (or your custom Telnet port) in your device arguments.","message":"Using Telnet as a transport requires explicit configuration. The default port is 22 (SSH), even if the Telnet driver is implicitly selected by an older method.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z","problems":[],"ecosystem":"pypi"}