Skip to content

Commit d4e94a8

Browse files
committed
refactor: move DHT endpoint to separate section
- create new "DHT Routing API" section for DHT-specific operations - move /routing/v1/dht/closest/{peer-id} to the new DHT section - keep general peer lookup in "Peer Routing API" section - update cache value to 172800 (48h) for consistency - fix typo: "Query Paramters" -> "Query Parameters"
1 parent 9aa55a3 commit d4e94a8

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

src/routing/http-routing-v1.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -106,23 +106,16 @@ Each object in the `Providers` list is a record conforming to a schema, usually
106106

107107
## Peer Routing API
108108

109-
### `GET /routing/v1/dht/closest/{peer-id}?[closerThan]&[count]`
109+
### `GET /routing/v1/peers/{peer-id}`
110110

111111
#### Path Parameters
112112

113-
- `peer-id` is a [Peer ID](https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md) represented as a CIDv1 encoded with `libp2p-key` codec.
114-
115-
#### Query Paramters
116-
117-
- `closerThan` is an optional [Peer ID](https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md) represented as a CIDv1 encoded with `libp2p-key` codec.
118-
- Returned peer records must be closer to `peer-id` than `closerThan`.
119-
- If omitted the routing implementation should use its own [Peer ID](https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md).
120-
- `count` is an optional number that specifies how many peer records the requester desires.
121-
- Minimum 1, maximum 100, default 20.
113+
- `peer-id` is the [Peer ID](https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md) to fetch peer records for,
114+
represented as a CIDv1 encoded with `libp2p-key` codec.
122115

123116
#### Response Status Codes
124117

125-
- `200` (OK): the response body contains peer records.
118+
- `200` (OK): the response body contains the peer record.
126119
- `404` (Not Found): must be returned if no matching records are found.
127120
- `422` (Unprocessable Entity): request does not conform to schema or semantic constraints.
128121

@@ -134,7 +127,7 @@ Each object in the `Providers` list is a record conforming to a schema, usually
134127
- When present, `ttl` SHOULD be shorter for responses whose resolution ended in no results (e.g. 15 seconds),
135128
and longer for responses that have results (e.g. 5 minutes).
136129
- Implementations SHOULD include `max-ttl`, set to the maximum cache window of the underlying routing system.
137-
For example, if Amino DHT results are returned, `stale-while-revalidate` SHOULD be set to `79200` (22h, which at the time of writing this specification, is the [Provider Record Republish Interval](https://github.com/libp2p/specs/tree/master/kad-dht#content-provider-advertisement-and-discovery)).
130+
For example, if Amino DHT results are returned, `stale-while-revalidate` SHOULD be set to `172800` (48h, which at the time of writing this specification, is the provider record expiration window).
138131
- `Vary: Accept`: allows intermediate caches to play nicely with the different possible content types.
139132

140133
#### Response Body
@@ -154,22 +147,31 @@ Each object in the `Providers` list is a record conforming to a schema, usually
154147
}
155148
```
156149

157-
The number of peer records in the responses SHOULD be limited to the `count` query parameter, which defaults to 20 if unspecified.
150+
The `application/json` responses SHOULD be limited to 100 peers.
158151

159152
The client SHOULD be able to make a request with `Accept: application/x-ndjson` and get a [stream](#streaming) with more results.
160153

161154
Each object in the `Peers` list is a record conforming to the [Peer Schema](#peer-schema).
162155

163-
### `GET /routing/v1/peers/{peer-id}`
156+
## DHT Routing API
157+
158+
### `GET /routing/v1/dht/closest/{peer-id}?[closerThan]&[count]`
164159

165160
#### Path Parameters
166161

167-
- `peer-id` is the [Peer ID](https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md) to fetch peer records for,
168-
represented as a CIDv1 encoded with `libp2p-key` codec.
162+
- `peer-id` is a [Peer ID](https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md) represented as a CIDv1 encoded with `libp2p-key` codec.
163+
164+
#### Query Parameters
165+
166+
- `closerThan` is an optional [Peer ID](https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md) represented as a CIDv1 encoded with `libp2p-key` codec.
167+
- Returned peer records must be closer to `peer-id` than `closerThan`.
168+
- If omitted the routing implementation should use its own [Peer ID](https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md).
169+
- `count` is an optional number that specifies how many peer records the requester desires.
170+
- Minimum 1, maximum 100, default 20.
169171

170172
#### Response Status Codes
171173

172-
- `200` (OK): the response body contains the peer record.
174+
- `200` (OK): the response body contains peer records.
173175
- `404` (Not Found): must be returned if no matching records are found.
174176
- `422` (Unprocessable Entity): request does not conform to schema or semantic constraints.
175177

@@ -201,7 +203,7 @@ represented as a CIDv1 encoded with `libp2p-key` codec.
201203
}
202204
```
203205

204-
The `application/json` responses SHOULD be limited to 100 peers.
206+
The number of peer records in the responses SHOULD be limited to the `count` query parameter, which defaults to 20 if unspecified.
205207

206208
The client SHOULD be able to make a request with `Accept: application/x-ndjson` and get a [stream](#streaming) with more results.
207209

0 commit comments

Comments
 (0)