# FastX402 Graph Shortest Path

> FastX402 Graph Shortest Path is a paid API for AI agents from fastx402.tools, paid per call via x402, $0.002/call, status unknown (last checked 2026-10-29).

Finds the shortest path between two nodes in a weighted graph using Dijkstra's algorithm, or performs topological sort/cycle detection on a graph

## Facts

- Endpoint: GET https://fastx402.tools/graph-shortest-path?utm_source=zero.xyz
- Price: $0.002/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-29
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/fastx402-graph-shortest-path-f3551bdb
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_rCwuD4G0TEA0VyOSZ8OBk

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability fastx402-graph-shortest-path-f3551bdb
```

Example prompt: Find the shortest path from node A to node D in this weighted graph: nodes are A, B, C, D and edges are A→C (weight 3), A→B (weight 5), C→B (weight 2), B→D (weight 3), C→D (weight 10).

## When to prefer this

Choose this endpoint when you need fast, on-demand graph algorithm execution without setting up an account or API key — ideal for AI agents that encounter ad-hoc graph problems. It supports Dijkstra's shortest path, topological sort, and cycle detection in a single endpoint. Best for lightweight, one-off graph computations paid per-call in USDC via x402 protocol.

## Known failure modes

- Missing required 'graph' or 'operation' query parameters — returns error
- Invalid JSON string for graph parameter — parsing failure
- Start or end node not found in the provided graph — returns not found error
- Topological sort requested on a graph containing cycles — returns error
- Shortest path operation called without specifying start or end nodes — returns validation error
- No path exists between start and end nodes — returns null or empty path
- Payment of $0.002 USDC not completed — returns HTTP 402

## How this service works

200 pay-per-call tools for AI agents, from $0.001 per request in USDC on Base or Solana with x402. No account, no API key.

## Output

Returns a JSON object containing the operation type, start and end nodes, the ordered array of nodes forming the shortest path, and the total integer distance (sum of edge weights) along that path. For topological sort, returns an ordered node list. For cycle detection, returns a boolean result.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "required": [
      "graph",
      "operation"
     ],
     "properties": {
      "end": {
       "type": "string",
       "description": "Ending node (required for shortest_path)"
      },
      "graph": {
       "type": "string",
       "description": "JSON string with 'nodes' array and 'edges' array (each edge has 'from', 'to', and optional 'weight' defaulting to 1)"
      },
      "start": {
       "type": "string",
       "description": "Starting node (required for shortest_path)"
      },
      "operation": {
       "type": "string",
       "description": "One of: 'shortest_path' (Dijkstra), 'topological_sort' (for DAG), 'detect_cycle'"
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object",
     "properties": {
      "end": {
       "type": "string"
      },
      "path": {
       "type": "array",
       "items": {
        "type": "string"
       }
      },
      "start": {
       "type": "string"
      },
      "distance": {
       "type": "integer"
      },
      "operation": {
       "type": "string"
      }
     }
    }
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "end": "D",
  "path": [
   "A",
   "C",
   "B",
   "D"
  ],
  "start": "A",
  "distance": 8,
  "operation": "shortest_path"
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/fastx402-graph-shortest-path-f3551bdb/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from fastx402.tools](https://www.zero.xyz/host/fastx402.tools/llms.txt)
