summaryrefslogtreecommitdiff
path: root/src/main/resources/web/protocol.html
blob: f5d56a938cf2cecf13bc2afd3744cb40dfd9a6c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Onionoo &mdash; protocol overview</title>
<link href="css/style.css" type="text/css" rel="stylesheet">
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link href="favicon.ico" type="image/x-icon" rel="shortcut icon">
</head>
<body>

<div class="box">

<h1><a href="index.html">Onionoo</a> &mdash;</h1>
<h2>protocol overview</h2>

    <h4>Table of contents</h4>
    <ul>
        <li><a href="#general">General</a></li>
        <li><a href="#methods">Methods</a></li>
        <li><a href="#responses">Responses</a></li>
        <li><a href="#summary">Summary documents</a></li>
        <li><a href="#details">Details documents</a></li>
        <li><a href="#history">History objects</a></li>
        <li><a href="#bandwidth">Bandwidth documents</a></li>
        <li><a href="#weights">Weights documents</a></li>
        <li><a href="#clients">Clients documents</a></li>
        <li><a href="#uptime">Uptime documents</a></li>
        <li><a href="#examples">Example usage</a></li>
    </ul>

</div>
<div class="box">

<a name="general"></a>
<h3>General <a href="#general">#</a></h3>

<p>
The Onionoo service is designed as a RESTful web service.
Onionoo clients send HTTP GET requests to the Onionoo server which
responds with JSON-formatted replies.
Onionoo clients and their developers should follow a few rules:
</p>

<h4>Compression</h4>
<p>
Clients should include an <strong>"Accept-Encoding:
gzip"</strong> header in their requests and handle gzip-compressed
responses.
Only requests starting at a certain size will be compressed by the
server.
</p>

<h4>Caching</h4>
<p>Clients should make use of the <strong>"Last-Modified"</strong>
header of responses and include that timestamp in a
<strong>"If-Modified-Since"</strong> header of subsequent requests.
</p>

<h4>Response codes</h4>
<p>
Clients should handle response codes by
distinguishing between client and server errors, and if there's a problem,
informing their users about the kind of problem.
The following response codes are used:
</p>

<ul class="properties">

<li>
<b>200 OK</b>
<p>
The request was processed successfully.
</p>
</li>

<li>
<b>304 Not Modified</b>
<p>
Server data has not changed since the
<strong>"If-Modified-Since"</strong> header included in the request.
</p>
</li>

<li>
<b>400 Bad Request</b>
<p>
The request for a known resource could not be processed because of bad
syntax.
This is most likely a client problem.
</p>
</li>

<li>
<b>404 Not Available</b>
<p>
The request could not be processed because the requested resource could
not be found.
This is most likely a client problem.
</p>
</li>

<li>
<b>500 Internal Server Error</b>
<p>
There is an unspecific problem with
the server which the service operator may not yet be aware of.
Please check if there's already a bug report for this problem, and if not,
file one.
</p>
</li>

<li>
<b>503 Service Unavailable</b>
<p>
The server is temporarily down for
maintenance, or there is a temporary problem with the server that the
service operator is already aware of.
Only file a bug report if this problem persists.
</p>
</li>

</ul>

<h4>Protocol versions</h4>
<p>
There are plenty of reasons why we may have
to change the protocol described here.
Clients should be able to handle all valid JSON responses, ignoring
unknown fields and not breaking horribly in case of missing fields.
Protocol changes will be announced here by writing deprecated API parts in
<strong><font color="red">red</font></strong> and new parts in
<strong><font color="blue">blue</font></strong>.
Deprecated parts will be removed one month after their announcement.
If you want to be informed of upcoming protocol changes, subscribe to the
<a href="https://lists.torproject.org/cgi-bin/mailman/listinfo/onionoo-announce">onionoo-announce</a>
mailing list.
</p>

<p>All responses contain a <strong>"version"</strong> string that
indicates whether clients can parse the document or not.
Version strings consist of a major and a minor version number.
The major version number is raised when previously required fields are
dropped or turned into optional fields, when request parameters or
response documents are removed, or when there are structural changes.
The minor version number is raised when new fields, request parameters, or
response documents are added or optional fields are dropped.
If clients support the same major version given in a response but only a
lower minor version, they should be able to parse the document but may not
understand all fields.
If clients support a lower major version, they should not attempt to parse
a document, because there may be backward-incompatible changes.</p>

<p>Responses may also contain the optional
<strong>"next_major_version_scheduled"</strong> field that announces when
the next major version is scheduled to be deployed.
Clients should inform their users that they should upgrade to the next
major protocol version before the provided date.</p>

<p>The following versions have been used in the past six months or are
scheduled to be deployed in the next months:</p>

<ul>
<li><strong>1.0</strong>: First assigned version number on August 31,
2014.</li>
<li><strong>1.1</strong>: Added optional "next_major_version_scheduled"
field on September 16, 2014.</li>
<li><strong>1.2</strong>: Added qualified search terms to "search"
parameter on October 17, 2014.</li>
<li><strong>2.0</strong>: Extended search parameter to base64-encoded
fingerprints on November 15, 2014.</li>
<li><strong>2.1</strong>: Removed optional "advertised_bandwidth_fraction"
field from details documents and optional "advertised_bandwidth" and
"advertised_bandwidth_fraction" fields from weights documents on November
16, 2014.</li>
<li><strong>2.2</strong>: Removed optional "pool_assignment" field and
added "transports" field to bridge details documents on December 8,
2014.</li>
<li><strong>2.3</strong>: Added optional "flags" field to uptime
documents on March 22, 2015.</li>
<li><strong>2.4</strong>: Added optional "effective_family" field to
details documents on July 3, 2015.</li>
<li><strong>2.5</strong>: Added optional "measured" field to details
documents on August 13, 2015.</li>
<li><strong>2.6</strong>: Added optional "alleged_family" and
"indirect_family" fields and deprecated optional "family" field in details
documents on August 25, 2015.</li>
<li><strong>3.0</strong>: Extended search parameter to match any 4 hex
characters of a space-separated fingerprint on November 15, 2015.</li>
<li><strong>3.1</strong>: Removed optional "family" field on January 18,
2016.</li>
<li><strong>3.2</strong>: Added response meta data fields
"relays_skipped", "relays_truncated", "bridges_skipped", and
"bridges_truncated" on January 9, 2017.</li>
</ul>

</div> <!-- box -->

<div class="box">

<a name="methods"></a>
<h3>Methods <a href="#methods">#</a></h3>

<p>
The following methods each return a single document containing zero or
more objects of relays and/or bridges.
By default, all relays and bridges are included that have been running in
the past week.
</p>

<ul class="api-urls">

<li class="api-request">
<span class="request-type">GET</span>
<span class="request-url">https://onionoo.torproject.org/summary</span>
<span class="request-response">returns a <a href="#summary">summary
document</a></span>
</li>

<li class="api-request">
<span class="request-type">GET</span>
<span class="request-url">https://onionoo.torproject.org/details</span>
<span class="request-response">returns a <a href="#details">details
document</a></span>
</li>

<li class="api-request">
<span class="request-type">GET</span>
<span class="request-url">https://onionoo.torproject.org/bandwidth</span>
<span class="request-response">returns a <a href="#bandwidth">bandwidth
document</a></span>
</li>

<li class="api-request">
<span class="request-type">GET</span>
<span class="request-url">https://onionoo.torproject.org/weights</span>
<span class="request-response">returns a <a href="#weights">weights
document</a></span>
</li>

<li class="api-request">
<span class="request-type">GET</span>
<span class="request-url">https://onionoo.torproject.org/clients</span>
<span class="request-response">returns a <a href="#clients">clients
document</a></span>
</li>

<li class="api-request">
<span class="request-type">GET</span>
<span class="request-url">https://onionoo.torproject.org/uptime</span>
<span class="request-response">returns a <a href="#uptime">uptime
document</a></span>
</li>

</ul>

<h4>Parameters</h4>
<p>
Each of the methods can be parameterized to select only a subset of relay
and/or bridge documents that are currently running or that have been
running in the past week.
(The <strong>fingerprint</strong> parameter is special here, because it
allows selecting a specific relay or bridge, regardless of whether it has
been running in the past week.)
If multiple parameters are specified, they are combined using a logical
AND operation, meaning that only the intersection of relays and bridges
matching all parameters is returned.
If the same parameter is specified more than once, only the first
parameter value is considered.
</p>

<ul class="properties">

<li>
<b>type</b>
<p>
Return only relay (parameter value
<strong>relay</strong>) or only bridge documents (parameter value
<strong>bridge</strong>).
Parameter values are case-insensitive.
</p>
</li>

<li>
<b>running</b>
<p>
Return only running (parameter value
<strong>true</strong>) or only non-running relays and/or bridges
(paramter value
<strong>false</strong>).
Parameter values are case-insensitive.
</p>
</li>

<li>
<b>search</b>
<p>
Return only (1) relays with the parameter value matching (part of a)
nickname, (possibly $-prefixed) beginning of a hex-encoded fingerprint,
any 4 hex characters of a space-separated fingerprint, beginning of a
base64-encoded fingerprint without trailing equal signs, or beginning of
an IP address, (2) bridges with (part of a) nickname or (possibly
$-prefixed) beginning of a hashed hex-encoded fingerprint, and (3) relays
and/or bridges matching a given qualified search term.
Searches by relay IP address include all known addresses used for onion
routing and for exiting to the Internet.
Searches for beginnings of IP addresses are performed on textual
representations of canonical IP address forms, so that searches using CIDR
notation or non-canonical forms will return empty results.
Searches are case-insensitive, except for base64-encoded fingerprints.
If multiple search terms are given, separated by spaces, the intersection
of all relays and bridges matching all search terms will be returned.
Complete hex-encoded fingerprints should always be hashed using SHA-1,
regardless of searching for a relay or a bridge, in order to not
accidentally leak non-hashed bridge fingerprints in the URL.
Qualified search terms have the form "key:value" (without double quotes)
with "key" being one of the parameters listed here except for "search",
"fingerprint", "order", "limit", "offset", and "fields", and "value" being
the string that will internally be passed to that parameter.
</p>
</li>

<li>
<b>lookup</b>
<p>
Return only the relay with the parameter
value matching the fingerprint or the bridge with the parameter value
matching the hashed fingerprint.
Fingerprints should always be hashed using SHA-1, regardless of looking up
a relay or a bridge, in order to not accidentally leak non-hashed bridge
fingerprints in the URL.
Lookups only work for full fingerprints or hashed fingerprints consisting
of 40 hex characters.
Lookups are case-insensitive.
</p>
</li>

<li>
<b>fingerprint</b>
<p>
Return only the relay with the parameter value matching the fingerprint
or the bridge with the parameter value matching the hashed fingerprint.
Fingerprints must consist of 40 hex characters, case does not matter.
This parameter is quite similar to the <strong>lookup</strong> parameter
with two exceptions:
(1) the provided relay fingerprint or hashed bridge fingerprint <i>must
not</i> be hashed (again) using SHA-1;
(2) the response will contain any matching relay or bridge regardless of
whether they have been running in the past week.
</p>
</li>

<li>
<b>country</b>
<p>
Return only relays which are located in the
given country as identified by a two-letter country code.
Filtering by country code is case-insensitive.
</p>
</li>

<li>
<b>as</b>
<p>
Return only relays which are located in the
given autonomous system (AS) as identified by the AS number (with or
without preceding "AS" part).
Filtering by AS number is case-insensitive.
</p>
</li>

<li>
<b>flag</b>
<p>
Return only relays which have the
given relay flag assigned by the directory authorities.
Note that if the flag parameter is specified more than once, only the
first parameter value will be considered.
Filtering by flag is case-insensitive.
</p>
</li>

<li>
<b>first_seen_days</b>
<p>
Return only relays or bridges which
have first been seen during the given range of days ago.
A parameter value "x-y" with x &lt;= y returns relays or bridges that have
first been seen at least x and at most y days ago.
Accepted short forms are "x", "x-", and "-y" which are interpreted as
"x-x", "x-infinity", and "0-y".
</p>
</li>

<li>
<b>last_seen_days</b>
<p>
Return only relays or bridges which
have last been seen during the given range of days ago.
A parameter value "x-y" with x &lt;= y returns relays or bridges that have
last been seen at least x and at most y days ago.
Accepted short forms are "x", "x-", and "-y" which are interpreted as
"x-x", "x-infinity", and "0-y".
Note that relays and bridges that haven't been running in the past week
are not included in results, so that setting x to 8 or higher will lead to
an empty result set.
</p>
</li>

<li>
<b>contact</b>
<p>
Return only relays with the parameter value
matching (part of) the contact line.
If the parameter value contains spaces, only relays are returned which
contain all space-separated parts in their contact line.
Only printable ASCII characters are permitted in the parameter value,
some of which need to be percent-encoded (# as %23, % as %25, &#38; as
%26, + as %2B, and / as %2F).
Comparisons are case-insensitive.
</p>
</li>

<li>
<b>family</b>
<p>
Return only the relay whose fingerprint matches the parameter value and
all relays that this relay has listed in its family by fingerprint and
that in turn have listed this relay in their family by fingerprint.
If relays have listed other relays in their family by nickname, those
family relationships will not be considered, regardless of whether they
have the Named flag or not.
The provided relay fingerprint must consist of 40 hex characters where
case does not matter, and it must not be hashed using SHA-1.
Bridges are not contained in the result, regardless of whether they define
a family.
</p>
</li>

</ul>

<p>
Response documents can be reduced in size by requesting only a subset
of contained fields.
</p>

<ul class="properties">

<li>
<b>fields</b>
<p>
Comma-separated list of fields that will be
included in the result.
So far, only top-level fields in relay or bridge objects of details
documents can be specified, e.g.,
<strong>nickname,hashed_fingerprint</strong>.
If the fields parameter is provided, all other fields which are not
contained in the provided list will be removed from the result.
Field names are case-insensitive.
</p>
</li>

</ul>

<p>
Relay and/or bridge documents in the response can be ordered and
limited by providing further parameters.
If the same parameter is specified more than once, only the first
parameter value is considered.
</p>

<ul class="properties">

<li>
<b>order</b>
<p>
Re-order results by a comma-separated list
of fields in ascending or descending order.
Results are first ordered by the first list element, then by the second,
and so on.
Possible fields for ordering are: <strong>consensus_weight</strong>.
Field names are case-insensitive.
Ascending order is the default; descending order is selected by prepending
fields with a minus sign (<strong>-</strong>).
Relays or bridges which don't have any value for a field to be ordered by
are always appended to the end, regardless or sorting order.
The ordering is defined independent of the requested document type and
does not require the ordering field to be contained in the document.
If no <strong>order</strong> parameter is given, ordering of results is
undefined.
</p>
</li>

<li>
<b>offset</b>
<p>
Skip the given number of relays and/or
bridges.
Relays are skipped first, then bridges.
Non-positive <strong>offset</strong> values are treated as zero and don't
change the
result.
</p>
</li>

<li>
<b>limit</b>
<p>
Limit result to the given number of
relays and/or bridges.
Relays are kept first, then bridges.
Non-positive <strong>limit</strong> values are treated as zero and lead
to an empty
result.
When used together with <strong>offset</strong>, the offsetting step
precedes the
limiting step.
</p>
</li>

</ul>

</div> <!-- box -->

<div class="box">
<a name="responses"></a>
<h3>Responses <a href="#responses">#</a></h3>

<p>Responses all have the same structure, regardless of requested
method and provided parameters.
Responses contain the following fields:</p>

<ul class="properties">

<li>
<b>version</b>
<code class="typeof">string</code>
<span class="required-true">required</span>
<p>
Onionoo protocol version string.
</p>
</li>

<li>
<b>next_major_version_scheduled</b>
<code class="typeof">string</code>
<span class="required-false">optional</span>
<p>
UTC date (YYYY-MM-DD) when the next major protocol version is scheduled to
be deployed.
Omitted if no major protocol changes are planned.
</p>
</li>

<li>
<b>relays_published</b>
<code class="typeof">string</code>
<span class="required-true">required</span>
<p>
UTC timestamp (YYYY-MM-DD hh:mm:ss) when the last known relay network
status consensus started being valid.
Indicates how recent the relay objects in this document are.
</p>
</li>

<li>
<b><font color="blue">relays_skipped</font></b>
<code class="typeof">number</code>
<span class="required-false">optional</span>
<p>
Number of skipped relays as requested by a positive "offset" parameter
value.
Omitted if zero.
<font color="blue">Added on January 9, 2017.</font>
</p>
</li>

<li>
<b>relays</b>
<code class="typeof">array of objects</code>
<span class="required-true">required</span>
<p>
Array of relay objects as specified below.
</p>
</li>

<li>
<b><font color="blue">relays_truncated</font></b>
<code class="typeof">number</code>
<span class="required-false">optional</span>
<p>
Number of truncated relays as requested by a positive "limit"
parameter value.
Omitted if zero.
<font color="blue">Added on January 9, 2017.</font>
</p>
</li>

<li>
<b>bridges_published</b>
<code class="typeof">string</code>
<span class="required-true">required</span>
<p>
UTC timestamp (YYYY-MM-DD hh:mm:ss) when
the last known bridge network status was published.
Indicates how recent the bridge objects in this document are.
</p>
</li>

<li>
<b><font color="blue">bridge_skipped</font></b>
<code class="typeof">number</code>
<span class="required-false">optional</span>
<p>
Number of skipped bridges as requested by a positive "offset"
parameter value.
Omitted if zero.
<font color="blue">Added on January 9, 2017.</font>
</p>
</li>

<li>
<b>bridges</b>
<code class="typeof">array of objects</code>
<span class="required-true">required</span>
<p>
Array of bridge objects as specified below.
</p>
</li>

<li>
<b><font color="blue">bridges_truncated</font></b>
<code class="typeof">number</code>
<span class="required-false">optional</span>
<p>
Number of truncated bridges as requested by a positive "limit"
parameter value.
Omitted if zero.
<font color="blue">Added on January 9, 2017.</font>
</p>
</li>

</ul>

</div> <!-- box -->

<div class="box">
<a name="summary"></a>
<h3>Summary documents <a href="#summary">#</a>
<span class="request-response">
<a href="summary?limit=4">example request</a>
</span>
</h3>

<p>Summary documents contain short summaries of relays with nicknames,
fingerprints, IP addresses, and running information as well as bridges
with hashed fingerprints and running information.</p>

<h4>Relay summary objects</h4>

<p>
Relay summary objects contain the following key-value pairs:
</p>

<ul class="properties">

<li>
<b>n</b>
<code class="typeof">string</code>
<span class="required-false">optional</span>
<p>
Relay nickname consisting of 1&ndash;19 alphanumerical characters.
Omitted if the relay nickname is <strong>"Unnamed"</strong>.
</p>
</li>

<li>
<b>f</b>
<code class="typeof">string</code>
<span class="required-true">required</span>
<p>
Relay fingerprint consisting of 40 upper-case hexadecimal characters.
</p>
</li>

<li>
<b>a</b>
<code class="typeof">array of strings</code>
<span class="required-true">required</span>
<p>
Array of IPv4 or IPv6 addresses where the relay accepts
onion-routing connections or which the relay used to exit to the Internet
in the past 24 hours.
The first address is the primary onion-routing address that the relay used
to register in the network, subsequent addresses are in arbitrary order.
IPv6 hex characters are all lower-case.
</p>
</li>

<li>
<b>r</b>
<code class="typeof">boolean</code>
<span class="required-true">required</span>
<p>
Boolean field saying whether this relay was listed as
running in the last relay network status consensus.
</p>
</li>

</ul>

<h4>Bridge summary objects</h4>

<p>
Bridge summary objects contain the following key-value pairs:
</p>

<ul class="properties">

<li>
<b>n</b>
<code class="typeof">string</code>
<span class="required-false">optional</span>
<p>
Bridge nickname consisting of 1&ndash;19 alphanumerical characters.
Omitted if the bridge nickname is <strong>"Unnamed"</strong>.
</p>
</li>

<li>
<b>h</b>
<code class="typeof">string</code>
<span class="required-true">required</span>
<p>
SHA-1 hash of the bridge fingerprint consisting of 40
upper-case hexadecimal characters.
</p>
</li>

<li>
<b>r</b>
<code class="typeof">boolean</code>
<span class="required-true">required</span>
<p>
Boolean field saying whether this bridge was listed as
running in the last bridge network status.
</p>
</li>

</ul>

</div> <!-- box -->

<div class="box">
<a name="details"></a>
<h3>Details documents <a href="#details">#</a>
<span class="request-response">
<a href="details?limit=4">example request</a>
</span>
</h3>

<p>
Details documents are based on network statuses published by the Tor
directories, server descriptors published by relays and bridges, and data
published by Tor network services TorDNSEL and BridgeDB.
Details documents use the most recently published data from these sources,
which may lead to contradictions between fields based on different sources
in rare edge cases.
</p>

<h4>Relay details objects</h4>

<p>
Relay details objects contain the following key-value pairs:
</p>

<ul class="properties">

<li>
<b>nickname</b>
<code class="typeof">string</code>
<span class="required-false">optional</span>
<p>
Relay nickname consisting of 1&ndash;19 alphanumerical characters.
Omitted if the relay nickname is <strong>"Unnamed"</strong>.
</p>
</li>

<li>
<b>fingerprint</b>
<code class="typeof">string</code>
<span class="required-true">required</span>
<p>
Relay fingerprint consisting of 40 upper-case
hexadecimal characters.
</p>
</li>

<li>
<b>or_addresses</b>
<code class="typeof">array of strings</code>
<span class="required-true">required</span>
<p>
Array of IPv4 or IPv6 addresses and TCP ports
or port lists where the relay accepts onion-routing connections.
The first address is the primary onion-routing address that the relay used
to register in the network, subsequent addresses are in arbitrary order.
IPv6 hex characters are all lower-case.
</p>
</li>

<li>
<b>exit_addresses</b>
<code class="typeof">array of strings</code>
<span class="required-false">optional</span>
<p>
Array of IPv4 or IPv6 addresses that the
relay used to exit to the Internet in the past 24 hours.
IPv6 hex characters are all lower-case.
Only those addresses are listed that are different from onion-routing
addresses.
Omitted if array is empty.
</p>
</li>

<li>
<b>dir_address</b>
<code class="typeof">string</code>
<span class="required-false">optional</span>
<p>
IPv4 address and TCP port where the relay
accepts directory connections.
Omitted if the relay does not accept directory connections.
</p>
</li>

<li>
<b>last_seen</b>
<code class="typeof">string</code>
<span class="required-true">required</span>
<p>
UTC timestamp (YYYY-MM-DD hh:mm:ss) when this
relay was last seen in a network status consensus.
</p>
</li>

<li>
<b>last_changed_address_or_port</b>
<code class="typeof">string</code>
<span class="required-true">required</span>
<p>
UTC timestamp (YYYY-MM-DD
hh:mm:ss) when this relay last stopped announcing an IPv4 or IPv6 address
or TCP port where it previously accepted onion-routing or directory
connections.
This timestamp can serve as indicator whether this relay would be a
suitable fallback directory.
</p>
</li>

<li>
<b>first_seen</b>
<code class="typeof">string</code>
<span class="required-true">required</span>
<p>
UTC timestamp (YYYY-MM-DD hh:mm:ss) when this
relay was first seen in a network status consensus.
</p>
</li>

<li>
<b>running</b>
<code class="typeof">boolean</code>
<span class="required-true">required</span>
<p>
Boolean field saying whether this relay was listed as
running in the last relay network status consensus.
</p>
</li>

<li>
<b>hibernating</b>
<code class="typeof">boolean</code>
<span class="required-false">optional</span>
<p>
Boolean field saying whether this relay indicated that it is hibernating
in its last known server descriptor.
This information may be helpful to decide whether a relay that is not
running anymore has reached its accounting limit and has not dropped out
of the network for another, unknown reason.
Omitted if either the relay is not hibernating, or if no information is
available about the hiberation status of the relay.
</p>
</li>

<li>
<b>flags</b>
<code class="typeof">array of strings</code>
<span class="required-false">optional</span>
<p>
Array of relay flags that the directory authorities
assigned to this relay.
May be omitted if empty.
</p>
</li>

<li>
<b>country</b>
<code class="typeof">string</code>
<span class="required-false">optional</span>
<p>
Two-letter lower-case country code as found in a
GeoIP database by resolving the relay's first onion-routing IP address.
Omitted if the relay IP address could not be found in the GeoIP
database.
</p>
</li>

<li>
<b>country_name</b>
<code class="typeof">string</code>
<span class="required-false">optional</span>
<p>
Country name as found in a GeoIP database by
resolving the relay's first onion-routing IP address.
Omitted if the relay IP address could not be found in the GeoIP
database, or if the GeoIP database did not contain a country name.
</p>
</li>

<li>
<b>region_name</b>
<code class="typeof">string</code>
<span class="required-false">optional</span>
<p>
Region name as found in a GeoIP database by
resolving the relay's first onion-routing IP address.
Omitted if the relay IP address could not be found in the GeoIP
database, or if the GeoIP database did not contain a region name.
</p>
</li>

<li>
<b>city_name</b>
<code class="typeof">string</code>
<span class="required-false">optional</span>
<p>
City name as found in a
GeoIP database by resolving the relay's first onion-routing IP address.
Omitted if the relay IP address could not be found in the GeoIP
database, or if the GeoIP database did not contain a city name.
</p>
</li>

<li>
<b>latitude</b>
<code class="typeof">number</code>
<span class="required-false">optional</span>
<p>
Latitude as found in a GeoIP database by resolving
the relay's first onion-routing IP address.
Omitted if the relay IP address could not be found in the GeoIP
database.
</p>
</li>

<li>
<b>longitude</b>
<code class="typeof">number</code>
<span class="required-false">optional</span>
<p>
Longitude as found in a GeoIP database by
resolving the relay's first onion-routing IP address.
Omitted if the relay IP address could not be found in the GeoIP
database.
</p>
</li>

<li>
<b>as_number</b>
<code class="typeof">string</code>
<span class="required-false">optional</span>
<p>
AS number as found in an AS database by
resolving the relay's first onion-routing IP address.
AS number strings start with "AS", followed directly by the AS number.
Omitted if the relay IP address could not be found in the AS
database.
</p>
</li>

<li>
<b>as_name</b>
<code class="typeof">string</code>
<span class="required-false">optional</span>
<p>
AS name as found in an AS database by resolving the
relay's first onion-routing IP address.
Omitted if the relay IP address could not be found in the AS
database.
</p>
</li>

<li>
<b>consensus_weight</b>
<code class="typeof">number</code>
<span class="required-true">required</span>
<p>
Weight assigned to this relay by the
directory authorities that clients use in their path selection algorithm.
The unit is arbitrary; currently it's kilobytes per second, but that might
change in the future.
</p>
</li>

<li>
<b>host_name</b>
<code class="typeof">string</code>
<span class="required-false">optional</span>
<p>
Host name as found in a reverse DNS lookup of the
relay IP address.
This field is updated at most once in 12 hours, unless the relay IP
address changes.
Omitted if the relay IP address was not looked up or if no lookup request
was successful yet.
</p>
</li>

<li>
<b>last_restarted</b>
<code class="typeof">string</code>
<span class="required-false">optional</span>
<p>
UTC timestamp (YYYY-MM-DD hh:mm:ss) when the
relay was last (re-)started.
Missing if router descriptor containing this information cannot be
found.
</p>
</li>

<li>
<b>bandwidth_rate</b>
<code class="typeof">number</code>
<span class="required-false">optional</span>
<p>
Average bandwidth
in bytes per second that this relay is willing to sustain over long
periods.
Missing if router descriptor containing this information cannot be
found.
</p>
</li>

<li>
<b>bandwidth_burst</b>
<code class="typeof">number</code>
<span class="required-false">optional</span>
<p>
Bandwidth in bytes
per second that this relay is willing to sustain in very short intervals.
Missing if router descriptor containing this information cannot be
found.
</p>
</li>

<li>
<b>observed_bandwidth</b>
<code class="typeof">number</code>
<span class="required-false">optional</span>
<p>
Bandwidth
estimate in bytes per second of the capacity this relay can handle.
The relay remembers the maximum bandwidth sustained output over any ten
second period in the past day, and another sustained input.
The "observed_bandwidth" value is the lesser of these two numbers.
Missing if router descriptor containing this information cannot be
found.
</p>
</li>

<li>
<b>advertised_bandwidth</b>
<code class="typeof">number</code>
<span class="required-false">optional</span>
<p>
Bandwidth in bytes per second that this
relay is willing and capable to provide.
This bandwidth value is the minimum of <strong>bandwidth_rate</strong>,
<strong>bandwidth_burst</strong>, and <strong>observed_bandwidth</strong>.
Missing if router descriptor containing this information cannot be
found.
</p>
</li>

<li>
<b>exit_policy</b>
<code class="typeof">array of strings</code>
<span class="required-false">optional</span>
<p>
Array of exit-policy lines.
Missing if router descriptor containing this information cannot be
found.
May contradict the <strong>"exit_policy_summary"</strong> field in a rare
edge case: this happens when the relay changes its exit policy after the
directory authorities summarized the previous exit policy.
</p>
</li>

<li>
<b>exit_policy_summary</b>
<code class="typeof">object</code>
<span class="required-false">optional</span>
<p>
Summary
version of the relay's exit policy containing a dictionary with either an
"accept" or a "reject" element.
If there is an "accept" ("reject") element, the relay accepts (rejects)
all TCP ports or port ranges in the given list for most IP addresses and
rejects (accepts) all other ports.
May contradict the <strong>"exit_policy"</strong> field in a rare edge
case: this happens when the relay changes its exit policy after the
directory authorities summarized the previous exit policy.
</p>
</li>

<li>
<b>exit_policy_v6_summary</b>
<code class="typeof">object</code>
<span class="required-false">optional</span>
<p>
Summary version of the relay's IPv6 exit policy containing a dictionary
with either an "accept" or a "reject" element.
If there is an "accept" ("reject") element, the relay accepts (rejects)
all TCP ports or port ranges in the given list for most IP addresses and
rejects (accepts) all other ports.
Missing if the relay rejects all connections to IPv6 addresses.
May contradict the <strong>"exit_policy_summary"</strong> field in a rare
edge case: this happens when the relay changes its exit policy after the
directory authorities summarized the previous exit policy.
</p>
</li>

<li>
<b>contact</b>
<code class="typeof">string</code>
<span class="required-false">optional</span>
<p>
Contact address of the relay operator.
Omitted if empty or if descriptor containing this information cannot be
found.
</p>
</li>

<li>
<b>platform</b>
<code class="typeof">string</code>
<span class="required-false">optional</span>
<p>
Platform string containing operating system and Tor
version details.
Omitted if empty or if descriptor containing this information cannot be
found.
</p>
</li>

<li>
<b>recommended_version</b>
<code class="typeof">boolean</code>
<span class="required-false">optional</span>
<p>
Boolean field saying whether the Tor software version of this relay is
recommended by the directory authorities or not.
Omitted if either the directory authorities did not recommend versions, or
the relay did not report which version it runs.
</p>
</li>

<li>
<b><font color="red">family</font></b>
<code class="typeof">array of strings</code>
<span class="required-false">optional</span>
<p>
Array of fingerprints or nicknames of relays that this relay considers to
be part of its family.
There are no cross-checks whether the listed relays exist or consider this
relay part of their family, so that the effective family of this relay may
be smaller.
Omitted if empty or if descriptor containing this information cannot be
found.
<font color="red">Deprecated on August 25, 2015, removed on January 18,
2016.</font>
</p>
</li>

<li>
<b>effective_family</b>
<code class="typeof">array of strings</code>
<span class="required-false">optional</span>
<p>
Array of $-prefixed fingerprints of relays that are in an effective,
mutual family relationship with this relay.
These relays are part of this relay's family and they consider this relay
to be part of their family.
Omitted if empty or if descriptor containing this information cannot be
found.
</p>
</li>

<li>
<b>alleged_family</b>
<code class="typeof">array of strings</code>
<span class="required-false">optional</span>
<p>
Array of $-prefixed fingerprints of relays that are not in an effective,
mutual family relationship with this relay.
These relays are part of this relay's family but they don't consider this
relay to be part of their family.
Omitted if empty or if descriptor containing this information cannot be
found.
</p>
</li>

<li>
<b>indirect_family</b>
<code class="typeof">array of strings</code>
<span class="required-false">optional</span>
<p>
Array of $-prefixed fingerprints of relays that are not in an effective,
mutual family relationship with this relay but that can be reached by
following effective, mutual family relationships starting at this relay.
Omitted if empty or if descriptor containing this information cannot be
found.
</p>
</li>

<li>
<b>consensus_weight_fraction</b>
<code class="typeof">number</code>
<span class="required-false">optional</span>
<p>
Fraction of this relay's consensus weight compared to the sum of all
consensus weights in the network.
This fraction is a very rough approximation of the probability of this
relay to be selected by clients.
Omitted if the relay is not running.
</p>
</li>

<li>
<b>guard_probability</b>
<code class="typeof">number</code>
<span class="required-false">optional</span>
<p>
Probability of this relay to be selected for the guard position.
This probability is calculated based on consensus weights, relay flags,
and bandwidth weights in the consensus.
Path selection depends on more factors, so that this probability can only
be an approximation.
Omitted if the relay is not running, or the consensus does not contain
bandwidth weights.
</p>
</li>

<li>
<b>middle_probability</b>
<code class="typeof">number</code>
<span class="required-false">optional</span>
<p>
Probability of this relay to be selected for the middle position.
This probability is calculated based on consensus weights, relay flags,
and bandwidth weights in the consensus.
Path selection depends on more factors, so that this probability can only
be an approximation.
Omitted if the relay is not running, or the consensus does not contain
bandwidth weights.
</p>
</li>

<li>
<b>exit_probability</b>
<code class="typeof">number</code>
<span class="required-false">optional</span>
<p>
Probability of this relay to be selected for the exit position.
This probability is calculated based on consensus weights, relay flags,
and bandwidth weights in the consensus.
Path selection depends on more factors, so that this probability can only
be an approximation.
Omitted if the relay is not running, or the consensus does not contain
bandwidth weights.
</p>
</li>

<li>
<b>measured</b>
<code class="typeof">boolean</code>
<span class="required-false">optional</span>
<p>
Boolean field saying whether the consensus weight of this relay is based
on a threshold of 3 or more measurements by Tor bandwidth authorities.
Omitted if the network status consensus containing this relay does not
contain measurement information.
</p>
</li>

</ul>

<h4>Bridge details objects</h4>

<p>
Bridge details objects contain the following key-value pairs:
</p>

<ul class="properties">

<li>
<b>nickname</b>
<code class="typeof">string</code>
<span class="required-false">optional</span>
<p>
Bridge nickname consisting of 1&ndash;19
alphanumerical characters.
Omitted if the bridge nickname is <strong>"Unnamed"</strong>.
</p>
</li>

<li>
<b>hashed_fingerprint</b>
<code class="typeof">string</code>
<span class="required-true">required</span>
<p>
SHA-1 hash of the bridge fingerprint
consisting of 40 upper-case hexadecimal characters.
</p>
</li>

<li>
<b>or_addresses</b>
<code class="typeof">array of strings</code>
<span class="required-true">required</span>
<p>
Array of sanitized IPv4 or IPv6 addresses and
TCP ports or port lists where the bridge accepts onion-routing
connections.
The first address is the primary onion-routing address that the bridge
used to register in the network, subsequent addresses are in arbitrary
order.
IPv6 hex characters are all lower-case.
Sanitized IP addresses are always in <strong>10/8</strong> or
<strong>[fd9f:2e19:3bcf/48]</strong> IP networks and are only useful to
learn which
IP version the bridge uses and to detect whether the bridge changed its
address.
Sanitized IP addresses always change on the 1st of every month at 00:00:00
UTC, regardless of the bridge actually changing its IP address.
TCP ports are not sanitized.
</p>
</li>

<li>
<b>last_seen</b>
<code class="typeof">string</code>
<span class="required-true">required</span>
<p>
UTC timestamp (YYYY-MM-DD hh:mm:ss) when this
bridge was last seen in a bridge network status.
</p>
</li>

<li>
<b>first_seen</b>
<code class="typeof">string</code>
<span class="required-true">required</span>
<p>
UTC timestamp (YYYY-MM-DD hh:mm:ss) when this
bridge was first seen in a bridge network status.
</p>
</li>

<li>
<b>running</b>
<code class="typeof">boolean</code>
<span class="required-true">required</span>
<p>
Boolean field saying whether this bridge was listed
as running in the last bridge network status.
</p>
</li>

<li>
<b>flags</b>
<code class="typeof">array of strings</code>
<span class="required-false">optional</span>
<p>
Array of relay flags that the bridge authority
assigned to this bridge.
May be omitted if empty.
</p>
</li>

<li>
<b>last_restarted</b>
<code class="typeof">string</code>
<span class="required-false">optional</span>
<p>
UTC timestamp (YYYY-MM-DD hh:mm:ss) when the
bridge was last (re-)started.
Missing if router descriptor containing this information cannot be
found.
</p>
</li>

<li>
<b>advertised_bandwidth</b>
<code class="typeof">number</code>
<span class="required-false">optional</span>
<p>
Bandwidth in bytes per second that this
bridge is willing and capable to provide.
This bandwidth value is the minimum of <strong>bandwidth_rate</strong>,
<strong>bandwidth_burst</strong>, and <strong>observed_bandwidth</strong>.
Missing if router descriptor containing this information cannot be
found.
</p>
</li>

<li>
<b>platform</b>
<code class="typeof">string</code>
<span class="required-false">optional</span>
<p>
Platform string containing operating system and Tor
version details.
Omitted if not provided by the bridge or if descriptor containing this
information cannot be found.
</p>
</li>

<li>
<b>transports</b>
<code class="typeof">array of strings</code>
<span class="required-false">optional</span>
<p>
Array of (pluggable) transport names supported by this bridge.
</p>
</li>

</ul>

</div> <!-- box -->

<div class="box">
<a name="history"></a>
<h3>History objects <a href="#history">#</a></h3>

<p>
History objects are no documents by themselves, but are contained in
subsequent documents.
<p>

<h4>Graph history objects</h4>

<p>
Graph history objects contain the following fields:
</p>

<ul class="properties">

<li>
<b>first</b>
<code class="typeof">string</code>
<span class="required-true">required</span>
<p>
UTC timestamp (YYYY-MM-DD hh:mm:ss) of the first data point, or more
specifically the interval midpoint of the first interval.
</p>
</li>

<li>
<b>last</b>
<code class="typeof">string</code>
<span class="required-true">required</span>
<p>
UTC timestamp (YYYY-MM-DD hh:mm:ss) of the last data point, or more
specifically the interval midpoint of the last interval.
</p>
</li>

<li>
<b>interval</b>
<code class="typeof">number</code>
<span class="required-true">required</span>
<p>
Time interval between two data points in seconds.
</p>
</li>

<li>
<b>factor</b>
<code class="typeof">number</code>
<span class="required-true">required</span>
<p>
Factor by which subsequent data values need to be multiplied to obtain
original values.
The idea is to reduce document size while still providing sufficient
detail for very different data scales.
</p>
</li>

<li>
<b>count</b>
<code class="typeof">number</code>
<span class="required-false">optional</span>
<p>
Number of provided data points, included mostly for debugging purposes.
Can also be derived from the number of elements in the subsequent array.
</p>
</li>

<li>
<b>values</b>
<code class="typeof">array of numbers</code>
<span class="required-true">required</span>
<p>
Array of normalized values between 0 and 999.
May contain null values.
Contains at least two subsequent non-null values to enable drawing of line
graphs.
</p>
</li>

</ul>

</div> <!-- box -->

<div class="box">
<a name="bandwidth"></a>
<h3>Bandwidth documents <a href="#bandwidth">#</a>
<span class="request-response">
<a href="bandwidth?limit=4">example request</a>
</span>
</h3>

<p>
Bandwidth documents contain aggregate statistics of a relay's or
bridge's consumed bandwidth for different time intervals.
Bandwidth documents are only updated when a relay or bridge publishes a
new server descriptor, which may take up to 18 hours during normal
operation.
</p>

<h4>Relay bandwidth objects</h4>

<p>
Relay bandwidth objects contain the following key-value pairs:
</p>

<ul class="properties">

<li>
<b>fingerprint</b>
<code class="typeof">string</code>
<span class="required-true">required</span>
<p>
Relay fingerprint consisting of 40 upper-case
hexadecimal characters.
</p>
</li>

<li>
<b>write_history</b>
<code class="typeof">object</code>
<span class="required-false">optional</span>
<p>
Object containing graph history objects with written bytes for different
time periods.
Keys are string representation of the time period covered by the graph
history object.
Keys are fixed strings <strong>"3_days"</strong>,
<strong>"1_week"</strong>, <strong>"1_month"</strong>,
<strong>"3_months"</strong>, <strong>"1_year"</strong>, and
<strong>"5_years"</strong>.
Keys refer to the last known bandwidth history of a relay, not to the time
when the bandwidth document was published.
A graph history object is only contained if the time period it covers is
not already contained in another graph history object with shorter time
period and higher data resolution.
Similarly, a graph history object is excluded if the relay did not provide
bandwidth histories on the required level of detail.
The unit is bytes per second.
Contained graph history objects may contain null values if the relay did
not provide any bandwidth data or only data for less than 20% of a given
time period.
</p>
</li>

<li>
<b>read_history</b>
<code class="typeof">object</code>
<span class="required-false">optional</span>
<p>
Object containing graph history objects with read bytes for different time
periods.
The specification of graph history objects is similar to those in the
<strong>write_history</strong> field.
</p>
</li>

</ul>

<h4>Bridge bandwidth objects</h4>

<p>
Bridge bandwidth objects contain the following key-value pairs:
</p>

<ul class="properties">

<li>
<b>fingerprint</b>
<code class="typeof">string</code>
<span class="required-true">required</span>
<p>
SHA-1 hash of the bridge fingerprint consisting
of 40 upper-case hexadecimal characters.
</p>
</li>

<li>
<b>write_history</b>
<code class="typeof">object</code>
<span class="required-false">optional</span>
<p>
Object containing graph history objects with written bytes for different
time periods.
The specification of graph history objects is similar to those in the
<strong>write_history</strong> field of <strong>relays</strong>.
</p>
</li>

<li>
<b>read_history</b>
<code class="typeof">object</code>
<span class="required-false">optional</span>
<p>
Object containing graph history objects with read bytes for different time
periods.
The specification of graph history objects is similar to those in the
<strong>write_history</strong> field of <strong>relays</strong>.
</p>
</li>

</ul>

</div> <!-- box -->

<div class="box">
<a name="weights"></a>
<h3>Weights documents <a href="#weights">#</a>
<span class="request-response">
<a href="weights?limit=4">example request</a>
</span>
</h3>

<p>
Weights documents contain aggregate statistics of a relay's probability
to be selected by clients for building paths.
Weights documents contain different time intervals and are available for
relays only.
</p>

<h4>Relay weights objects</h4>

<p>
Relay weights objects contain the following key-value pairs: 
</p>

<ul class="properties">

<li>
<b>fingerprint</b>
<code class="typeof">string</code>
<span class="required-true">required</span>
<p>
Relay fingerprint consisting of 40 upper-case
hexadecimal characters.
</p>
</li>

<li>
<b>consensus_weight_fraction</b>
<code class="typeof">object</code>
<span class="required-false">optional</span>
<p>
History object containing the
fraction of this relay's consensus weight compared to the sum of all
consensus weights in the network.
This fraction is a very rough approximation of the probability of this
relay to be selected by clients.
Keys are string representation of the time period covered by the graph
history object.
Keys are fixed strings <strong>"1_week"</strong>,
<strong>"1_month"</strong>, <strong>"3_months"</strong>,
<strong>"1_year"</strong>, and <strong>"5_years"</strong>.
Keys refer to the last known weights history of a relay, not to the time
when the weights document was published.
A graph history object is only contained if the time period it covers is
not already contained in another graph history object with shorter time
period and higher data resolution.
The unit is path-selection probability.
Contained graph history objects may contain null values if the relay was
running less than 20% of a given time period.
</p>
</li>

<li>
<b>guard_probability</b>
<code class="typeof">object</code>
<span class="required-false">optional</span>
<p>
History object containing the probability
of this relay to be selected for the guard position.
This probability is calculated based on consensus weights, relay flags,
and bandwidth weights in the consensus.
Path selection depends on more factors, so that this probability can only
be an approximation.
The specification of this history object is similar to that in the
<strong>consensus_weight_fraction</strong> field above.
</p>
</li>

<li>
<b>middle_probability</b>
<code class="typeof">object</code>
<span class="required-false">optional</span>
<p>
History object containing the probability
of this relay to be selected for the middle position.
This probability is calculated based on consensus weights, relay flags,
and bandwidth weights in the consensus.
Path selection depends on more factors, so that this probability can only
be an approximation.
The specification of this history object is similar to that in the
<strong>consensus_weight_fraction</strong> field above.
</p>
</li>

<li>
<b>exit_probability</b>
<code class="typeof">object</code>
<span class="required-false">optional</span>
<p>
History object containing the probability
of this relay to be selected for the exit position.
This probability is calculated based on consensus weights, relay flags,
and bandwidth weights in the consensus.
Path selection depends on more factors, so that this probability can only
be an approximation.
The specification of this history object is similar to that in the
<strong>consensus_weight_fraction</strong> field above.
</p>
</li>

<li>
<b>consensus_weight</b>
<code class="typeof">object</code>
<span class="required-false">optional</span>
<p>
History object containing the absolute consensus weight of this relay.
The specification of this history object is similar to that in the
<strong>consensus_weight_fraction</strong> field above.
</p>
</li>

</ul>

</div> <!-- box -->

<div class="box">
<a name="clients"></a>
<h3>Clients documents <a href="#clients">#</a>
<span class="request-response">
<a href="clients?limit=4">example request</a>
</span>
</h3>

<p>
Clients documents contain estimates of the average number of clients
connecting to a bridge every day.
There are no clients documents available for relays, just for bridges.
Clients documents contain different time intervals and are available for
bridges only.
</p>

<h4>Bridge clients objects</h4>

<p>
Bridge clients objects contain the following key-value pairs:
</p>

<ul class="properties">

<li>
<b>fingerprint</b>
<code class="typeof">string</code>
<span class="required-true">required</span>
<p>
SHA-1 hash of the bridge fingerprint consisting
of 40 upper-case hexadecimal characters.
</p>
</li>

<li>
<b>average_clients</b>
<code class="typeof">object</code>
<span class="required-false">optional</span>
<p>
Object containing graph history objects with the average number of clients
connecting to this bridge.
Keys are string representation of the time period covered by the graph
history object.
Keys are fixed strings <strong>"1_week"</strong>,
<strong>"1_month"</strong>, <strong>"3_months"</strong>,
<strong>"1_year"</strong>, and <strong>"5_years"</strong>.
Keys refer to the last known clients history of a bridge, not to the time
when the clients document was published.
A graph history object is only contained if the time period it covers
is not already contained in another clients graph object with shorter
time period and higher data resolution.
The unit is number of clients.
Contained graph history objects may contain null values if the bridge did
not report client statistics for at least 50% of a given time period.
Each graph history object contains the following additional key-value
pairs:
</p>

<ul class="properties">

<li>
<b>countries</b>
<code class="typeof">object</code>
<span class="required-false">optional</span>
<p>
Object containing fractions of clients by country in the considered time
period.
Keys are two-letter lower-case country codes as found in a GeoIP database.
Values are numbers between 0 and 1 standing for the fraction of clients by
country.
A country is only included if at least 1% of clients came from this
country.
Omitted if the bridge did not report client statistics by country.
<font color="red"><strong>BETA:</strong> This field breaks compatibility
with the history objects contained in other documents pretty badly.
It might be removed in the future without notice.</font>
</p>
</li>

<li>
<b>transports</b>
<code class="typeof">object</code>
<span class="required-false">optional</span>
<p>
Object containing fractions of clients by transport in the considered time
period.
Keys are transport names, or <strong>"&lt;OR&gt;"</strong> for the default
onion-routing transport protocol.
Values are numbers between 0 and 1 standing for the fraction of clients by
transport.
Omitted if the bridge did not report client statistics by transport.
<font color="red"><strong>BETA:</strong> This field breaks compatibility
with the history objects contained in other documents pretty badly.
It might be removed in the future without notice.</font>
</p>
</li>

<li>
<b>versions</b>
<code class="typeof">object</code>
<span class="required-false">optional</span>
<p>
Object containing fractions of clients by IP version in the considered
time period.
Keys are either <strong>"v4"</strong> for IPv4 or <strong>"v6"</strong>
for IPv6.
Values are numbers between 0 and 1 standing for the fraction of clients by
version.
Omitted if the bridge did not report client statistics by IP version.
<font color="red"><strong>BETA:</strong> This field breaks compatibility
with the history objects contained in other documents pretty badly.
It might be removed in the future without notice.</font>
</p>
</li>

</ul>

</li>

</ul>

</div> <!-- box -->

<div class="box">
<a name="uptime"></a>
<h3>Uptime documents <a href="#uptime">#</a>
<span class="request-response">
<a href="uptime?limit=4">example request</a>
</span>
</h3>

<p>
Uptime documents contain fractional uptimes of relays and bridges.
Uptime documents contain different time intervals and are available for
relays and bridges.
</p>

<h4>Relay uptime objects</h4>

<p>
Relay uptime objects contain the following key-value pairs:
</p>

<ul class="properties">

<li>
<b>fingerprint</b>
<code class="typeof">string</code>
<span class="required-true">required</span>
<p>
Relay fingerprint consisting of 40 upper-case
hexadecimal characters.
</p>
</li>

<li>
<b>uptime</b>
<code class="typeof">object</code>
<span class="required-false">optional</span>
<p>
Object containing graph history objects with the fractional uptime of this
relay.
Keys are string representation of the time period covered by the graph
history object.
Keys are fixed strings <strong>"1_week"</strong>,
<strong>"1_month"</strong>, <strong>"3_months"</strong>,
<strong>"1_year"</strong>, and <strong>"5_years"</strong>.
Keys refer to the last known uptime history of a relay, not to the time
when the uptime document was published.
A graph history object is only contained if the time period it covers is
not already contained in another graph history object with shorter time
period and higher data resolution.
The unit is fractional uptime from 0 to 1.
Contained graph history objects may contain null values if less than 20%
of network statuses have been processed for a given time period.
</p>
</li>

<li>
<b>flags</b>
<code class="typeof">object</code>
<span class="required-false">optional</span>
<p>
Object containing fractional times of this relay having relay flags
assigned.
Keys are flag names like <strong>"Running"</strong> or
<strong>"Exit"</strong>, values are objects similar to the
<strong>uptime</strong> field above, again with keys like
<strong>"1_week"</strong> etc.
If a relay never had a given relay flag assigned, no object is included
for that flag.
</p>
</li>

</ul>

<h4>Bridge uptime objects</h4>

<p>
Bridge uptime objects contain the following key-value pairs:
</p>

<ul class="properties">

<li>
<b>fingerprint</b>
<code class="typeof">string</code>
<span class="required-true">required</span>
<p>
SHA-1 hash of the bridge fingerprint consisting
of 40 upper-case hexadecimal characters.
</p>
</li>

<li>
<b>uptime</b>
<code class="typeof">object</code>
<span class="required-false">optional</span>
<p>
Object containing uptime history objects for different time periods.
The specification of uptime history objects is similar to those in the
<strong>uptime</strong> field of <strong>relays</strong>.
</p>
</li>

</ul>

</div> <!-- box -->

<div class="box">
<a name="examples"></a>
<h3>Example usage <a href="#examples">#</a>
</h3>

<p>
The following examples illustrate how to build requests for some trivial
and some more complex use cases.
While Onionoo is designed mainly for developers and not end users, there
may be cases when it's easier to quickly write a specific query Onionoo
rather than to find an Onionoo client that provides the desired
information.
</p>

<p>
<code>/summary?limit=4</code>
(<a href="/summary?limit=4">view result</a>)
</p>

<p>
This first query returns the first four summary documents that Onionoo can
find.
The <code>limit</code> parameter should always be used while developing
new queries to avoid downloading huge responses.
</p>

<p>
<code>/summary?limit=4&search=moria</code>
(<a href="/summary?limit=4&search=moria">view result</a>)
</p>

<p>
The second query restricts results to relays and bridges containing the
string "moria" in one of a few searched fields.
</p>

<p>
<code>/details?limit=4&search=moria</code>
(<a href="/details?limit=4&search=moria">view result</a>)
</p>

<p>
The third query switches from the short summary documents to the longer
details documents containing, well, more details.
</p>

<p>
<code>/details?limit=4&search=moria&fields=nickname</code>
(<a href="/details?limit=4&search=moria&fields=nickname">view result</a>)
</p>

<p>
The fourth query adds the <code>fields</code> parameter which removes all
fields except the specified ones from the result.
This parameter is only implemented for details documents.
</p>

<p>
<code>/details?limit=4&search=moria&fields=nickname&order=-consensus_weight</code>
(<a href="/details?limit=4&search=moria&fields=nickname&order=-consensus_weight">view result</a>)
</p>

<p>
The fifth query sorts results by relay consensus weight from largest to
smallest.
</p>

<p>
Obviously, this query can be made even more complex by adding more
parameters, and in some cases this is necessary and useful.
Please refer to the protocol specification for details.
</p>

</div> <!-- box -->

</body>
</html>