Accessing the ThousandEyes API

The ThousandEyes API is very well documented. The examples in the documentation show the request/response transactions using curl. I will be writing my API calls with Python so they can be accessed and post-processed easily. I will be using the requests and json Python modules.

Here is the “Hello World” of requesting API data and saving it as json:

Output:

The API uses HTTP Basic authentication to access your account. The username is your account login and the password is the user token which can be found in your user settings. To test access to my account, I am going to pull back a list of tests.

Output:

I currently have one test created, so the API response contains information about that test. You can see that the response data contains API links to test data. In order to programmatically access the response data, you can treat the json object as a Python dictionary. For instance, to return the API link for BGP test data you would access j['test'][0]['apiLinks'][4]['href']: 'https://api.thousandeyes.com/net/bgp-metrics/39575'. This link will return the BGP metrics from the test.

This post has gone over accessing the ThousandEyes API. In my next post I will review additional API functionality.

1 thought on Accessing the ThousandEyes API

  1. Pingback ThousandEyes Alerts – API and Webhooks • JO Packet

Leave a Reply