You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Delegated routing is a mechanism for IPFS implementations to use for offloading
5
5
content routing and naming to another process/server. This specification describes
6
6
an HTTP API for delegated content routing.
7
-
date: 2023-03-22
7
+
date: 2023-08-31
8
8
maturity: reliable
9
9
editors:
10
10
- name: Gus Eggert
11
11
github: guseggert
12
+
affiliation:
13
+
name: Protocol Labs
14
+
url: https://protocol.ai/
12
15
- name: Masih H. Derkani
13
16
github: masih
17
+
affiliation:
18
+
name: Protocol Labs
19
+
url: https://protocol.ai/
14
20
- name: Henrique Dias
15
21
url: https://hacdias.com/
16
22
github: hacdias
23
+
affiliation:
24
+
name: Protocol Labs
25
+
url: https://protocol.ai/
26
+
- name: Marcin Rataj
27
+
github: lidel
28
+
url: https://lidel.org/
29
+
affiliation:
30
+
name: Protocol Labs
31
+
url: https://protocol.ai/
17
32
xref:
18
33
- ipns-record
19
34
order: 0
@@ -32,75 +47,89 @@ As such, human-readable encodings of types are preferred. This specification may
32
47
33
48
- CIDs are always string-encoded using a [multibase]-encoded [CIDv1].
34
49
- Multiaddrs are string-encoded according to the [human-readable multiaddr specification][multiaddr].
35
-
- Peer IDs are string-encoded according [PeerID string representation specification][peer-id-representation].
50
+
- Peer IDs are string-encoded according [PeerID string representation specification][peer-id-representation]: either a Multihash in Base58btc, or a CIDv1 with libp2p-key (`0x72`) codec.
36
51
- Multibase bytes are string-encoded according to [the Multibase spec][multibase], and SHOULD use base64.
37
52
- Timestamps are Unix millisecond epoch timestamps.
38
53
39
54
Until required for business logic, servers should treat these types as opaque strings, and should preserve unknown JSON fields.
40
55
41
-
###Versioning
56
+
## Versioning
42
57
43
58
This API uses a standard version prefix in the path, such as `/v1/...`. If a backwards-incompatible change must be made, then the version number should be increased.
44
59
45
-
### Provider Records
60
+
##Content Routing API
46
61
47
-
A provider record contains information about a content provider, including the transfer protocol and any protocol-specific information useful for fetching the content from the provider.
62
+
### `GET /routing/v1/providers/{cid}`
48
63
49
-
The information required to write a record to a router (*"write" provider records*) may be different than the information contained when reading provider records (*"read" provider records*).
64
+
#### Path Parameters
50
65
51
-
For example, indexers may require a signature in `bitswap` write records for authentication of the peer contained in the record, but the read records may not include this authentication information.
66
+
-`cid` is the [CID](https://github.com/multiformats/cid) to fetch provider records for.
52
67
53
-
Both read and write provider records have a minimal required schema as follows:
68
+
#### Response Status Codes
69
+
70
+
-`200` (OK): the response body contains 0 or more records.
71
+
-`404` (Not Found): must be returned if no matching records are found.
72
+
-`422` (Unprocessable Entity): request does not conform to schema or semantic constraints.
73
+
74
+
#### Response Body
54
75
55
76
```json
56
77
{
57
-
"Protocol": "<transfer_protocol_name>",
58
-
"Schema": "<transfer_protocol_schema>",
78
+
"Providers": [
79
+
{
80
+
"Schema": "<schema>",
81
+
"ID": "bafz...",
82
+
"Addrs": ["/ip4/..."],
83
+
...
84
+
},
59
85
...
86
+
]
60
87
}
61
88
```
62
89
63
-
Where:
90
+
The `application/json` responses SHOULD be limited to 100 providers.
64
91
65
-
-`Protocol` is the multicodec name of the transfer protocol or an opaque string (for experimenting with novel protocols without a multicodec)
66
-
-`Schema` denotes the schema to use for encoding/decoding the record
67
-
- This is separate from the `Protocol` to allow this HTTP API to evolve independently of the transfer protocol
68
-
- Implementations should switch on this when parsing records, not on `Protocol`
69
-
-`...` denotes opaque JSON, which may contain information specific to the transfer protocol
92
+
The client SHOULD be able to make a request with `Accept: application/x-ndjson` and get a [stream](#streaming) with more results.
70
93
71
-
Specifications for some transfer protocols are provided in the "Transfer Protocols" section.
94
+
Each object in the `Providers` list is a record conforming to a schema, usually the [Peer Schema](#peer-schema).
72
95
73
-
## Content Providers API
96
+
## Peer Routing API
74
97
75
-
### `GET /routing/v1/providers/{cid}`
98
+
### `GET /routing/v1/peers/{peer-id}`
76
99
77
100
#### Path Parameters
78
101
79
-
-`cid` is the [CID](https://github.com/multiformats/cid) to fetch provider records for.
102
+
-`peer-id` is the [Peer ID](https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md) to fetch peer records for,
103
+
represented as a CIDv1 encoded with `libp2p-key` codec.
80
104
81
105
#### Response Status Codes
82
106
83
-
-`200` (OK): the response body contains 0 or more records.
107
+
-`200` (OK): the response body contains the peer record.
84
108
-`404` (Not Found): must be returned if no matching records are found.
85
109
-`422` (Unprocessable Entity): request does not conform to schema or semantic constraints.
The `application/json` responses SHOULD be limited to 100 peers.
129
+
130
+
The client SHOULD be able to make a request with `Accept: application/x-ndjson` and get a [stream](#streaming) with more results.
102
131
103
-
Each object in the `Providers` list is a *read provider record*.
132
+
Each object in the `Peers` list is a record conforming to the [Peer Schema](#peer-schema).
104
133
105
134
## IPNS API
106
135
@@ -123,7 +152,7 @@ Each object in the `Providers` list is a *read provider record*.
123
152
124
153
#### Response Body
125
154
126
-
The response body contains a :ref[IPNS Record] serialized using the verifiable [`application/vnd.ipfs.ipns-record`](https://www.iana.org/assignments/media-types/application/vnd.ipfs.ipns-record) protobuf format.
155
+
The response body contains a :ref[IPNS Record] serialized using the verifiable [`application/vnd.ipfs.ipns-record`](https://www.iana.org/assignments/media-types/application/vnd.ipfs.ipns-record) protobuf format.
127
156
128
157
### `PUT /routing/v1/ipns/{name}`
129
158
@@ -163,7 +192,7 @@ with one result per line:
163
192
164
193
:::note
165
194
166
-
Streaming is opt-in and backwards-compatibile with clients and servers that do
195
+
Streaming is opt-in and backwards-compatible with clients and servers that do
167
196
not support streaming:
168
197
169
198
- Requests without the `Accept: application/x-ndjson` header MUST default to
-`ID`: the [Peer ID][peer-id] as Multihash in Base58btc or CIDv1 with libp2p-key codec.
250
+
-`Addrs`: an optional list of known [multiaddrs][multiaddr] for this peer.
251
+
- If missing or empty, it means the router server is missing that information, and the client should use `ID` to lookup updated peer information.
252
+
-`Protocols`: an optional list of protocols known to be supported by this peer.
253
+
- If missing or empty, it means the router server is missing that information, and the client should use `ID` and `Addrs` to lookup connect to the peer and use the [libp2p identify protocol](https://github.com/libp2p/specs/tree/master/identify) to learn about supported ones.
254
+
255
+
:::note
256
+
257
+
To allow for protocol-specific fields and future-proofing, the parser MUST
258
+
allow for unknown fields, and the clients MUST ignore unknown ones.
259
+
260
+
Below is an example on how one could include `protocol-a` and `protocol-b`
261
+
protocols that includes an additional fields `protocol-a` and `protocol-b`.
262
+
263
+
If the client knows the protocol, they are free to use the extra binary
264
+
(base64) or JSON information contained in the additional field. If that is not
A legacy schema used by some routers to indicate a peer supports retrieval over
306
+
the [graphsync](https://github.com/ipfs/go-graphsync/blob/main/docs/architecture.md)
307
+
libp2p protocol.
236
308
237
309
```json
238
310
{
239
311
"Protocol": "transport-graphsync-filecoinv1",
240
312
"Schema": "graphsync-filecoinv1",
241
-
"ID": "12D3K...",
313
+
"ID": "bafz...",
242
314
"Addrs": ["/ip4/..."],
243
315
"PieceCID": "<cid>",
244
316
"VerifiedDeal": true,
245
317
"FastRetrieval": true
246
318
}
247
319
```
248
320
249
-
-`ID`: the [Peer ID][peer-id] of the provider
250
-
-`Addrs`: a list of known multiaddrs for the provider
251
-
-`PieceCID`: the CID of the [piece](https://spec.filecoin.io/systems/filecoin_files/piece/#section-systems.filecoin_files.piece) within which the data is stored
252
-
-`VerifiedDeal`: whether the deal corresponding to the data is verified
253
-
-`FastRetrieval`: whether the provider claims there is an unsealed copy of the data available for fast retrieval
0 commit comments