SwitchHero Collector API v1

Python SENDER scripts — REST endpoints

Getting started

The Collector API is for network collector scripts to write to the database. All responses are JSON; POST bodies must be application/json.

Base URL:

https://switchero.net/api/v1/collector

Example full path: https://switchero.net/api/v1/collector/ip-log

Token: Log in → Settings → Collector API Token

Authentication

A Bearer token is required on every request.

Authorization: Bearer YOUR_64_CHAR_TOKEN
Content-Type: application/json

Alternative: X-Api-Token: YOUR_TOKEN

Company (required)

Every request must include the tenant company code (e.g. RHBLK). The server does not assign it automatically.

MethodWhere?Example
POSTJSON body"company": "RHBLK"
GETQuery parameter?company=RHBLK

Python: COLLECTOR_COMPANY in config.py — api_payload() / api_params().

Python script mapping

ScriptMethodEndpoint
switch_active_checker_services.pyGET/cleanup
switch_active_checker_services.pyGET/ip-log/clear
switch_active_checker_services.pyPOST/ip-log
switch_fan_checker_services.pyGET/fan-log/clear
switch_fan_checker_services.pyPOST/fan-status
switch_auto_save_config_services.pyPOST/switch-config
switch_info_collector_services.pyPOST/switch-info, /switch-interface
switch_mac_checker_services.pyPOST/switch-lldp
makos.pyPOST/switch-mac

IP status

GET https://switchero.net/api/v1/collector/cleanup?company=RHBLK

Deletes closed_ips records for that company where alert_rate < 6.

GET https://switchero.net/api/v1/collector/ip-log/clear?company=RHBLK

Deletes only that company's ip_status_log records.

POST https://switchero.net/api/v1/collector/ip-log

{
  "company": "RHBLK",
  "ips": [
    { "ip": "10.0.0.1", "status": "AKTIF" },
    { "ip": "10.0.0.2", "status": "KAPALI" }
  ]
}

status: AKTIF or KAPALI

Fan monitoring

GET https://switchero.net/api/v1/collector/fan-log/clear?company=RHBLK

POST https://switchero.net/api/v1/collector/fan-status

{
  "company": "RHBLK",
  "fans": [
    { "ip": "10.0.0.1", "fan_status": "Normal", "temperature": "42C" }
  ]
}

Configuration backup

POST https://switchero.net/api/v1/collector/switch-config

{
  "company": "RHBLK",
  "ip_address": "10.0.0.1",
  "config_data": "...",
  "config_type": "running"
}

Switch information & interfaces

POST https://switchero.net/api/v1/collector/switch-info

{ "company": "RHBLK", "ip", "description", "uptime", "name", "mac_address" }

POST https://switchero.net/api/v1/collector/switch-interface

{ "company": "RHBLK", "ip", "interface_name", "admin_status", "oper_status", "speed" }

LLDP & MAC

POST https://switchero.net/api/v1/collector/switch-lldp

Required: company, switch_ip, local_port, remote_chassis_id, remote_port_id, remote_sys_name

POST https://switchero.net/api/v1/collector/switch-mac

Required: company, switch_ip, port, mac_address

Python example

All SENDER scripts use v1 paths via api/SENDER/config.py.

from config import api_headers, api_url, api_params, api_payload
import requests

# GET — clear RHBLK logs only
response = requests.get(
    api_url("clear_ip_log"),
    headers=api_headers(),
    params=api_params(),  # {"company": "RHBLK"}
    timeout=60,
)

# POST — company required
response = requests.post(
    api_url("save_all_ips"),
    json=api_payload({
        "ips": [
            {"ip": "10.0.0.1", "status": "AKTIF"},
        ],
    }),
    headers=api_headers(),
    timeout=120,
)

Error codes

HTTPMeaning
401Missing or invalid token
404Invalid path (legacy .php endpoints are not supported)
400Missing company or invalid request body
500Server error
Web API (session) — After login, endpoints such as /api/switch-history must not be confused with the collector token.