Skip to content

Commit 5418b4b

Browse files
committed
Adds /operators?withDomains endpoint. Updates readme to document new endpoints
1 parent 76863a0 commit 5418b4b

2 files changed

Lines changed: 65 additions & 1 deletion

File tree

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,53 @@ Example response:
228228
```
229229

230230
This endpoint is used for geolocation and network analysis of all known relays.
231+
232+
# Operators
233+
Fetch a list of relay operator addresses
234+
- **GET** `/operators` => `string[]`
235+
236+
Example response:
237+
```json
238+
[
239+
"0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
240+
"0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
241+
"0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
242+
... more results
243+
]
244+
```
245+
246+
# Operators with Anyone Domains
247+
Fetch a list of relay operators and any domains they own
248+
- **GET** `/operators?withDomains=true`
249+
250+
Response:
251+
```json
252+
[
253+
{
254+
"address": string,
255+
"domains": {
256+
tokenId: string,
257+
name: string,
258+
owner: string | undefined,
259+
tld: string
260+
}[]
261+
}
262+
]
263+
```
264+
265+
# Anyone Domains
266+
Fetch a list of .anyone domains
267+
- **GET** `/anyone-domains`
268+
Response:
269+
270+
```json
271+
[
272+
{
273+
"tokenId": string,
274+
"name": string,
275+
"owner": string | undefined,
276+
"tld": string
277+
},
278+
... more results
279+
]
280+
```

src/app.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,20 @@ class HexInfo {
299299

300300
app.get('/operators', async (req, res) => {
301301
try {
302+
const withDomains = req
303+
.query
304+
.withDomains as string | undefined === 'true';
302305
const operators = await operatorRegistryService.getOperators();
306+
if (withDomains) {
307+
const anyoneDomains = await unstoppableDomainsService
308+
.getAnyoneDomains();
309+
const operatorsWithDomains = operators.map(operator => ({
310+
address: operator,
311+
domains: anyoneDomains
312+
.filter(domain => domain.owner === operator)
313+
}));
314+
return res.json(operatorsWithDomains);
315+
}
303316
return res.json(operators);
304317
} catch (error) {
305318
console.error(error);
@@ -309,7 +322,8 @@ app.get('/operators', async (req, res) => {
309322

310323
app.get('/anyone-domains', async (req, res) => {
311324
try {
312-
const anyoneDomains = await unstoppableDomainsService.getAnyoneDomains();
325+
const anyoneDomains = await unstoppableDomainsService
326+
.getAnyoneDomains();
313327
return res.json(anyoneDomains);
314328
} catch (error) {
315329
console.error(error);

0 commit comments

Comments
 (0)