netLD API HowTo

Search Inventory with Code

This example shows the basic netLD API flow: authenticate with an API key, send a JSON-RPC request to Inventory.search, and print the returned devices. Each language uses a small netld_example_client helper so the search script stays readable.

Before You Start

Create a Local .env File

Keep credentials out of source code. Put the API URL, API key, network, and search parameters in a local .env file that is not committed to source control.

NETLD_BASE_URL="https://netld.example.com"
NETLD_API_KEY="replace-with-your-api-key"
NETLD_NETWORK="Default"
NETLD_SEARCH_SCHEME="ipAddress"
NETLD_SEARCH_QUERY="10.95.1.0/24"

Example helper

The Client File Is Reusable Example Code

These examples include a small netld_example_client helper to handle login, sessions, JSON-RPC formatting, redirects, and errors. It is example code, not a supported SDK package. Use it as a starting point, then adapt it to your team’s automation standards.

Example: Search for Devices

Download the example bundle for your language. Each bundle includes the short search script, the matching example client, and a .env.example template. The search script is the part you edit for different searches.

import os

from netld_example_client import NetLDClient, print_devices


client = NetLDClient.from_env()
client.login()

page_data = client.search_inventory(
    networks=[os.environ.get("NETLD_NETWORK", "Default")],
    schemes=os.environ.get("NETLD_SEARCH_SCHEME", "ipAddress"),
    queries=os.environ.get("NETLD_SEARCH_QUERY", "10.95.1.0/24"),
)

print_devices(page_data)

Run It

python -m pip install requests python-dotenv
python search_inventory.py

Example Output

Login status=200
Returned 3 of 3 matching devices
10.95.1.12      core-switch-01                 Cisco::IOS
10.95.1.13      core-switch-02                 Cisco::IOS
10.95.1.44      branch-fw-01                   PaloAlto::PANOS

Try Other Searches

Change the search scheme and query to search by a different supported inventory field.

NETLD_SEARCH_SCHEME="hostname"
NETLD_SEARCH_QUERY="core-switch"

Common Gotchas

What to Check If It Fails

  • Redirects usually mean the request is being sent through an SSO/browser-login path.
  • Inventory.search expects search text with a trailing newline.
  • The network parameter is passed as a list, even for one network.
  • Set NETLD_DEBUG=1 to print JSON-RPC request and response payloads.
netLD API inventory search examples

30 Day Free Trial

Understand, monitor, and control your network with ThirdEye, free for 30 days.

Start Your Trial