OriginChainDB
Database endpoints

Find k shortest paths

Returns up to k loop-free shortest paths between two nodes, ranked by cost.

GET /v1/tenants/{tenant}/graph/{schema}/k-shortest

Compare the best few loop-free routesThe result contains up to k routes, not every possible route.
  1. Set source and targetChoose the relation, path count and optional weight column.
  2. Find low-cost alternativesRank loop-free paths by cost.
  3. Read nodes and costsCompare the ordered routes returned.

Before you start

Use your database bearer token.

Connection setup

Register the schema and relation, then add their rows. The examples use demo.people, its bidirectional follows relation, and linked rows u1, u2 and u3.

Path parameters

FieldTypeRequired
tenantstringRequired
schemastringRequired

Query parameters

FieldTypeRequired
relstringRequired
sourcestringRequired
targetstringRequired
kintegerRequired
weight_colstringOptional

Headers

FieldTypeRequiredDescription
x-oc-db-userstringOptionalActing database user (role, grant and row-policy checks). Send with x-oc-db-key.
x-oc-db-keystringOptionalAPI key of the x-oc-db-user user.

Read the result

paths contains up to k loop-free routes, each with ordered nodes and a cost. A cost ranks the returned paths; it is not a count of all routes through the graph.

Response statuses

HTTP status reference
StatusWhat to do
200OK
400Correct the request before retrying.
401Check the credential and Authorization header.
402Check feature access or available credits.
403Check tenant access, roles and permissions.
404Check the resource ID and API route.
408Reduce query work or adjust the timeout.
429Honor Retry-After when present; back off.
499The client cancelled the request.
500Check the outcome before retrying a write.
503Honor Retry-After when present; check write outcomes.
ยฉ 2026 Silicoyn Technologies Pvt Ltd