Skip to content

Commit 8a44c0d

Browse files
committed
Add support for listing cascade options
Specify protocol to find out what cascade options are available to a client using `OPTIONS` method and a specific HTTP response header. This enables clients to programmatically determine the alternative routing systems to which a lookup may optionally be cascaded. Add extra wording to clarify that there are no constraints on the order by which results are returned at the presence of `cascade` query option.
1 parent b4f781d commit 8a44c0d

2 files changed

Lines changed: 74 additions & 10 deletions

File tree

IPNI.md

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,22 @@ to fetch the advertisement chain.
459459

460460
An indexer node can be queried over HTTP for a multihash or a CID. This section provides a summary of the HTTP query APIs. A full OpenAPI specification of the APIs can be found [here](schemas/v1/openapi.yaml).
461461

462+
463+
#### Cascading Lookup
464+
465+
The HTTP query API supports cascading queries for a given multihash or CID onto alternative routing systems in addition to searching IPNI records.
466+
A client may optionally specify a query parameter with key set to `cascade`, and value set to comma separated alternative routing systems, which are also searched for records.
467+
468+
The specification imposes no constraints on the order by which the results are returned.
469+
Implementers are free to return results as they are found.
470+
471+
The alternative routing systems currently supported is:
472+
* `ipfs-dht`: equivalent to searching records on the IPFS network.
473+
474+
A client may discover the list of alternative routing systems supported by a server via sending `OPTIONS` request.
475+
In response, the server may include `X-IPNI-Allow-Cascade` header key, with value as the comma separated list of alternative routing systems supported.
476+
The absence of this header key implies that the server does not offer cascading lookups.
477+
462478
#### `GET /cid/{cid}`
463479

464480
Given a CID as path parameter, returns a list of its content providers. The lookup ignores CID codec
@@ -471,8 +487,7 @@ and uses the multihash portion of the CID only.
471487

472488
##### Query Parameters
473489

474-
* `cascade` - _Optional_. The comma separated alternative routing systems to which the lookup is cascaded in addition to searching IPNI index records. If unspecified, only IPNI index records are searched. Supported values:
475-
* `ipfs-dht`- The IPFS Kademlia DHT.
490+
* `cascade` - _Optional_. The comma separated alternative routing systems to which the lookup is cascaded in addition to searching IPNI index records. If unspecified, only IPNI index records are searched. See [Cascading Lookup](#cascading-lookup)
476491

477492
##### Response
478493

@@ -495,8 +510,7 @@ Given a multihash as path parameter, returns a list of its content providers.
495510

496511
##### Query Parameters
497512

498-
* `cascade` - _Optional_. The comma separated alternative routing systems to which the lookup is cascaded in addition to searching IPNI index records. If unspecified, only IPNI index records are searched. Supported values:
499-
* `ipfs-dht`- The IPFS Kademlia DHT.
513+
* `cascade` - _Optional_. The comma separated alternative routing systems to which the lookup is cascaded in addition to searching IPNI index records. If unspecified, only IPNI index records are searched. See [Cascading Lookup](#cascading-lookup)
500514

501515

502516
##### Response
@@ -533,8 +547,7 @@ Base58 string representation. See [`FindRequest`][find-request-schema] schema.
533547

534548
##### Query Parameters
535549

536-
* `cascade` - _Optional_. The comma separated alternative routing systems to which the lookup is cascaded in addition to searching IPNI index records. If unspecified, only IPNI index records are searched. Supported values:
537-
* `ipfs-dht`- The IPFS Kademlia DHT.
550+
* `cascade` - _Optional_. The comma separated alternative routing systems to which the lookup is cascaded in addition to searching IPNI index records. If unspecified, only IPNI index records are searched. See [Cascading Lookup](#cascading-lookup)
538551

539552

540553
##### Response
@@ -667,6 +680,6 @@ The following lists the libraries and implementations of IPNI protocol:
667680

668681
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).
669682

670-
[find-response-schema]: schemas/v1/openapi.yaml#L108
671-
[provider-record-schema]: (schemas/v1/openapi.yaml#L124)
672-
[find-request-schema]: schemas/v1/openapi.yaml#L144
683+
[find-response-schema]: schemas/v1/openapi.yaml#L120
684+
[provider-record-schema]: (schemas/v1/openapi.yaml#L136)
685+
[find-request-schema]: schemas/v1/openapi.yaml#L156

schemas/v1/openapi.yaml

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
openapi: 3.0.3
22
info:
33
title: IPNI HTTP API
4-
summary: IPNI HTTP query API
54
description: The Interplanetary Network Indexer (IPNI) HTTP query API.
65
version: 0.0.1
76
paths:
@@ -13,6 +12,7 @@ paths:
1312
in: path
1413
description: The string representation of the CID.
1514
required: true
15+
- $ref: '#/components/parameters/Cascade'
1616
responses:
1717
'200':
1818
description: At least one provider was found successfully.
@@ -39,6 +39,12 @@ paths:
3939
description: Failure occurred while processing the request.
4040
content:
4141
text/plain: { }
42+
/cid:
43+
options:
44+
description: Returns permitted communication options for lookup by CID.
45+
responses:
46+
204:
47+
$ref: '#/components/responses/FindOptions'
4248
/multihash/{multihash}:
4349
get:
4450
description: Finds provider records for a given multihash
@@ -47,6 +53,7 @@ paths:
4753
in: path
4854
description: The base58 string representation of the multihash.
4955
required: true
56+
- $ref: '#/components/parameters/Cascade'
5057
responses:
5158
'200':
5259
description: At least one provider was found successfully.
@@ -74,6 +81,11 @@ paths:
7481
content:
7582
text/plain: { }
7683
/multihash:
84+
options:
85+
description: Returns permitted communication options for lookup by multihash.
86+
responses:
87+
204:
88+
$ref: '#/components/responses/FindOptions'
7789
post:
7890
description: Batch finds provider records for a given set of multihashes
7991
requestBody:
@@ -236,6 +248,45 @@ components:
236248
}
237249
]
238250
}
251+
parameters:
252+
Cascade:
253+
name: cascade
254+
in: query
255+
description: |
256+
The comma separated list of routing systems to search for providers in addition to IPNI.
257+
The list of supported routing systems can be discovered by reading `X-IPNI-Allow-Cascade`
258+
response header to `OPTIONS` request.
259+
schema:
260+
type: string
261+
required: false
262+
responses:
263+
FindOptions:
264+
description: Request accepted.
265+
headers:
266+
Access-Control-Allow-Origin:
267+
description: |
268+
The origin permitted to the request.
269+
See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin.
270+
schema:
271+
type: string
272+
Access-Control-Allow-Headers:
273+
description: |
274+
The comma separated list of HTTP headers inspected by the server.
275+
See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers
276+
schema:
277+
type: string
278+
Access-Control-Allow-Methods:
279+
description: |
280+
The comma separated list of permitted HTTP methods.
281+
See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Request-Method
282+
schema:
283+
type: string
284+
X-IPNI-Allow-Cascade:
285+
description: |
286+
The comma separated list of supported routing systems onto which the lookup can be cascaded.
287+
The absence of this header implies that the server does not offer cascading lookups.
288+
schema:
289+
type: string
239290
externalDocs:
240291
description: IPNI Specification
241292
url: https://github.com/ipni/specs/blob/main/IPNI.md

0 commit comments

Comments
 (0)