{"library":"pyeapi","title":"Python Client for Arista eAPI","description":"pyeapi is a Python client library for interacting with Arista EOS devices via their eAPI. It provides a simple, Pythonic interface for sending commands, parsing responses, and managing network configurations. The current version is 1.0.4, with releases occurring periodically to address bugs and introduce minor enhancements.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install pyeapi"],"cli":null},"imports":["from pyeapi.client import Node","import pyeapi\nnode = pyeapi.connect(host='10.0.0.1')"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import pyeapi\nimport os\n\n# Configure connection details (e.g., in a YAML file or environment variables)\n# For quickstart, using environment variables as placeholders:\nHOST = os.environ.get('PYEAPI_HOST', '10.0.0.1')\nUSERNAME = os.environ.get('PYEAPI_USERNAME', 'admin')\nPASSWORD = os.environ.get('PYEAPI_PASSWORD', 'arista')\n\n# A more robust setup would use a pyeapi.conf file or direct dictionary config\n# For simplicity, we'll create a dictionary config for direct connection\n\nnode_config = {\n    'transport': 'https',\n    'host': HOST,\n    'username': USERNAME,\n    'password': PASSWORD,\n    'port': 443,\n    'timeout': 30\n}\n\ntry:\n    # Connect to the Arista EOS device\n    node = pyeapi.connect(**node_config)\n    print(f\"Successfully connected to {HOST}\")\n\n    # Run a 'show version' command\n    response = node.run_commands(['show version'])\n    print(\"\\n--- Device Version ---\")\n    print(f\"EOS Version: {response[0]['version']}\")\n    print(f\"Hostname: {response[0]['hostname']}\")\n\n    # Run a 'show interfaces' command\n    interfaces_response = node.run_commands(['show interfaces'])\n    print(\"\\n--- Interfaces Status ---\")\n    for intf_name, intf_data in interfaces_response[0]['interfaces'].items():\n        print(f\"  {intf_name}: {intf_data['lineProtocolStatus']} (Admin: {intf_data['interfaceStatus']})\")\n\nexcept pyeapi.eapilib.EapiError as e:\n    print(f\"EAPI Error: {e}\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\n","lang":"python","description":"This example demonstrates how to connect to an Arista EOS device using `pyeapi.connect` and execute simple 'show' commands. It uses environment variables as placeholders for credentials, which should be replaced with actual values or a `pyeapi.conf` file for production use. It then prints the device's EOS version, hostname, and the status of its network interfaces.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}