Python SENDER scripts — REST endpoints
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:
Example full path: https://switchero.net/api/v1/collector/ip-log
A Bearer token is required on every request.
Authorization: Bearer YOUR_64_CHAR_TOKEN
Content-Type: application/json
Alternative: X-Api-Token: YOUR_TOKEN
Every request must include the tenant company code (e.g. RHBLK). The server does not assign it automatically.
| Method | Where? | Example |
|---|---|---|
| POST | JSON body | "company": "RHBLK" |
| GET | Query parameter | ?company=RHBLK |
Python: COLLECTOR_COMPANY in config.py — api_payload() / api_params().
| Script | Method | Endpoint |
|---|---|---|
| switch_active_checker_services.py | GET | /cleanup |
| switch_active_checker_services.py | GET | /ip-log/clear |
| switch_active_checker_services.py | POST | /ip-log |
| switch_fan_checker_services.py | GET | /fan-log/clear |
| switch_fan_checker_services.py | POST | /fan-status |
| switch_auto_save_config_services.py | POST | /switch-config |
| switch_info_collector_services.py | POST | /switch-info, /switch-interface |
| switch_mac_checker_services.py | POST | /switch-lldp |
| makos.py | POST | /switch-mac |
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
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" }
]
}
POST https://switchero.net/api/v1/collector/switch-config
{
"company": "RHBLK",
"ip_address": "10.0.0.1",
"config_data": "...",
"config_type": "running"
}
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" }
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
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,
)
| HTTP | Meaning |
|---|---|
| 401 | Missing or invalid token |
| 404 | Invalid path (legacy .php endpoints are not supported) |
| 400 | Missing company or invalid request body |
| 500 | Server error |
/api/switch-history must not be confused with the collector token.