Repository Public
1# =============================================================================2# SP BOUCHER | SOFTWARE & RESEARCH3# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4# =============================================================================5#6# Project : SPIDER7# File : sdk/python/spider_sdk/_routes.py8# Module : Sdk9# Repository : https://git.spboucher.ai/spider10# Project Website : Not specified11# Created : 2026-12-0412# Last Modified : 2026-12-0413#14# Author : Simon-Pierre Boucher15# Position : Professor of Finance16# Institution : Université du Québec en Outaouais (UQO)17# Organization : SP Boucher18# Website : https://spboucher.ai19# Git : https://git.spboucher.ai20#21# Preferred Contact: contact@spboucher.ai22# Development : dev@spboucher.ai23# Support : support@spboucher.ai24# Security/Admin : admin@spboucher.ai25#26# Copyright (c) 202627# Simon-Pierre Boucher28# All rights reserved where applicable. This file is governed by the29# applicable project license, copyright notices and relevant law.30# Existing third-party rights and notices remain unaffected.31#32# License : ISC33#34# Do not embed credentials, private keys, access tokens,35# certificates or confidential personal information.36#37# =============================================================================38# END OF SP BOUCHER SOURCE HEADER39# =============================================================================4041"""The routes of the SPIDER API used by the SDK: one entry per typed method.4243``tests/unit/sdk/test_sdk_openapi.py`` checks every entry against ``docs/openapi.json``.44Retry class of a route:4546* ``safe`` — repeating the request has no additional effect (reads, cancel, pause): retried on47 connection errors, 429 and 502/503/504.48* ``keyed`` — creates a job; the SDK always sends an ``Idempotency-Key`` and reuses it across49 retries, which makes the submission as safe to repeat as a read.50* ``unsafe`` — creates something and the API takes no idempotency key: retried only when the51 request provably did not reach the application (connection never established, or 429).52"""53from __future__ import annotations5455from typing import NamedTuple565758class Route(NamedTuple):59 method: str60 path: str61 retry: str # safe | keyed | unsafe626364ROUTES: dict[str, Route] = {65 # job submissions (202)66 "scrape": Route("POST", "/v1/scrape", "keyed"),67 "crawl": Route("POST", "/v1/crawl", "keyed"),68 "map": Route("POST", "/v1/map", "keyed"),69 "screenshot": Route("POST", "/v1/screenshot", "keyed"),70 "deep_capture": Route("POST", "/v1/deep-capture", "keyed"),71 "extract": Route("POST", "/v1/extract", "keyed"),72 "ocr": Route("POST", "/v1/ocr", "keyed"),73 "vision": Route("POST", "/v1/vision", "keyed"),74 "batch": Route("POST", "/v1/batch", "keyed"),75 # watch and search76 "create_monitor": Route("POST", "/v1/monitor", "unsafe"),77 "diff": Route("POST", "/v1/diff", "safe"),78 "search": Route("POST", "/v1/search", "safe"),79 # jobs80 "list_jobs": Route("GET", "/v1/jobs", "safe"),81 "get_job": Route("GET", "/v1/jobs/{job_id}", "safe"),82 "cancel_job": Route("POST", "/v1/jobs/{job_id}/cancel", "safe"),83 "pause_job": Route("POST", "/v1/jobs/{job_id}/pause", "safe"),84 "retry_job": Route("POST", "/v1/jobs/{job_id}/retry", "unsafe"),85 "get_results": Route("GET", "/v1/jobs/{job_id}/results", "safe"),86 "stream_events": Route("GET", "/v1/jobs/{job_id}/events", "safe"),87 "export": Route("GET", "/v1/jobs/{job_id}/export", "safe"),88 # artifacts and snapshots89 "get_artifact": Route("GET", "/v1/artifacts/{artifact_id}", "safe"),90 "get_snapshot": Route("GET", "/v1/snapshots/{snapshot_id}", "safe"),91 "snapshot_history": Route("GET", "/v1/snapshots", "safe"),92 # sites93 "list_sites": Route("GET", "/v1/sites", "safe"),94 "site_graph": Route("GET", "/v1/sites/{site_id}/graph", "safe"),95 "site_coverage": Route("GET", "/v1/sites/{site_id}/coverage", "safe"),96 # system97 "health": Route("GET", "/v1/health", "safe"),98 "me": Route("GET", "/v1/me", "safe"),99 # admin helpers100 "list_monitors": Route("GET", "/v1/monitors", "safe"),101 "monitor_action": Route("POST", "/v1/monitors/{schedule_id}/{action}", "unsafe"),102 "list_changes": Route("GET", "/v1/changes", "safe"),103 "webhook_secret": Route("GET", "/v1/webhook-secret", "safe"),104}105106JOB_STATES = ("queued", "running", "partial", "succeeded", "failed", "cancelled", "blocked")107TERMINAL_JOB_STATES = ("partial", "succeeded", "failed", "cancelled", "blocked")108MONITOR_ACTIONS = ("enable", "disable", "run-now", "delete")109