Posted on April 17, 2019 12:30 am
 |  Asked by Nilesh Bhadane
Print Friendly, PDF & Email


Is there a way to write a python or Java program or script to login to Arista device & perform an action on the arista device?


Posted by Himanshu Singh
Answered on April 17, 2019 6:25 am

Hi Nilesh,

You can use Arista eAPI to configure the switch via JSON-RPC.

For more information about eAPI please refer to the following:

For more information on Python Client for eAPI (pyeapi):

Documentation on Arista’s integration with Ansible:


Posted by Pratik
Answered on April 17, 2019 9:58 am

You can use python client for this.

1) First install python client (pyeapi)
2) This python client requires a configuration file, so create one config file and mention the device details in
it. For example,
$ cat .eapi.conf
[connection: DEVICE NAME]
username: XXXXXX
password: XXXXXX
transport: http
You can also put multiple nodes (devices) in config file.
3) Run python
4) Import pyeapi
5) Connect to node first, with below command,
node = pyeapi.connect_to(‘DEVICE NAME’)
6) from pprint import pprint as pp…….to print output
7) Now you can execute show commands in python,
pp (node.enable(‘show version’))
pp (node.enable([‘show version’, ‘show ip route’]))……if you want to execute multip command together
8) Also you can execute config commands,
node.config([‘interface ethernet 4/1’ , ‘description Test_1’])

Posted by Gerard Phillips
Answered on April 17, 2019 11:41 am

Hi Nilesh,

Absolutely. You can use python or Java, and the appropriate libraries to remotely access an Arista switch for both configuration and monitoring purposes.

There is a great article here that outlines the steps you need to take and points at a bunch more resources:

There are loads of examples that you can use, or build on here:


Posted by Adam Levin
Answered on April 17, 2019 2:10 pm

Hello Nilesh. The feature you are looking for is called eAPI, our EOS Application Programming Interface. It uses JSON, and the JSONRPC Library is supported in most any programming or scripting language. Our Arista Programming Essentials class teaches Python, so we usually recommend that.

You can enable eAPI on a switch by entering the commands

Switch(config)#username Script secret Arista
Switch(config)#management api http-commands
Switch(config-mgmt-api-http-cmds)#no shutdown

You will also need to create a user, but you can use existing users from AAA configuration,local or TACACS, etc.

Once enabled you can go to the URL of the management interface on the switch:


You can navigate, explore, and read the documentation from this link. Note that anything you do in the tool will actually run and be executed on the switch so be careful.

Post your Answer

You must be logged in to post an answer.