Retrieving the Latest Results for Scheduled Tests with the NetBeez API

Want to quickly access the most recent results for each agent running a scheduled test? The NetBeez API makes it a breeze! In this guide, we’ll walk you through the process of retrieving the latest results using the API.

Prerequisites:

  • Access to the NetBeez BeezKeeper API.
  • A tool to make API calls (e.g., Postman, curl, or a Python script).

Steps:

  1. Identify the Scheduled Test Template ID:
    • Navigate to the Scheduled Tests section of your NetBeez dashboard.
    • Find the scheduled test you’re interested in.
    • Note the ID associated with the test template.
  2. Construct the API URL:
    • Use the following base URL, replacing {{HOSTNAME}} with your BeezKeeper hostname: https://{{HOSTNAME}}/scheduled_nb_test_templates/:scheduled_nb_test_template_id/results?filter[last_result]=true
    • Replace :scheduled_nb_test_template_id with the ID you obtained in step 1.
  3. Authorize Your API Call:
    • Include an authorization header with your API token in the API call.
  4. Make the API Request:
    • Use your chosen tool to send a GET request to the constructed URL.
  5. Process the Response:
    • The API response will provide a JSON object containing the latest results for each agent running the scheduled test.
    • Parse the JSON data to extract the information you need.

Example (Python):

import requests

BASE_URL = "https://your-beezkeeper-hostname"  # Replace with your hostname
API_TOKEN = "your-api-token"  # Replace with your API token
SCHEDULED_TEST_TEMPLATE_ID = "123"  # Replace with the template ID

url = f"{BASE_URL}/scheduled_nb_test_templates/{SCHEDULED_TEST_TEMPLATE_ID}/results?filter[last_result]=true"
headers = {'Authorization': f'Bearer {API_TOKEN}'}

response = requests.get(url, headers=headers)

if response.status_code == 200:
    data = response.json()
    # Process the JSON data here
else:
    print("Error:", response.status_code)

Additional Tips:

  • Use the page[limit] and page[offset] parameters to paginate through results if necessary.
  • Refer to the official NetBeez API documentation for more details and options: https://api.netbeez.net

Happy result fetching!