syncthing-rest-api.7 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014
  1. .\" Man page generated from reStructuredText.
  2. .
  3. .TH "SYNCTHING-REST-API" "7" "July 17, 2016" "v0.14" "Syncthing"
  4. .SH NAME
  5. syncthing-rest-api \- REST API
  6. .
  7. .nr rst2man-indent-level 0
  8. .
  9. .de1 rstReportMargin
  10. \\$1 \\n[an-margin]
  11. level \\n[rst2man-indent-level]
  12. level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
  13. -
  14. \\n[rst2man-indent0]
  15. \\n[rst2man-indent1]
  16. \\n[rst2man-indent2]
  17. ..
  18. .de1 INDENT
  19. .\" .rstReportMargin pre:
  20. . RS \\$1
  21. . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
  22. . nr rst2man-indent-level +1
  23. .\" .rstReportMargin post:
  24. ..
  25. .de UNINDENT
  26. . RE
  27. .\" indent \\n[an-margin]
  28. .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
  29. .nr rst2man-indent-level -1
  30. .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
  31. .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
  32. ..
  33. .SH DESCRIPTION
  34. .sp
  35. Syncthing exposes a REST interface over HTTP on the GUI port. This is used by
  36. the GUI code (JavaScript) and can be used by other processes wishing to control
  37. Syncthing. In most cases both the input and output data is in JSON format. The
  38. interface is subject to change.
  39. .SH API KEY
  40. .sp
  41. To use the POST methods, or \fIany\fP method when authentication is enabled, an API
  42. key must be set and used. The API key can be generated in the GUI, or set in the
  43. \fBconfiguration/gui/apikey\fP element in the configuration file. To use an API
  44. key, set the request header \fBX\-API\-Key\fP to the API key value. For example,
  45. \fBcurl \-X POST \-H "X\-API\-Key: abc123" http://localhost:8384/rest/...\fP can be
  46. used to invoke authenticated POST methods via \fBcurl\fP\&.
  47. .SH SYSTEM ENDPOINTS
  48. .SS GET /rest/system/config
  49. .sp
  50. Returns the current configuration.
  51. .INDENT 0.0
  52. .INDENT 3.5
  53. .sp
  54. .nf
  55. .ft C
  56. {
  57. {
  58. "version": 15,
  59. "folders": [
  60. {
  61. "id": "GXWxf\-3zgnU",
  62. "label": "MyFolder",
  63. "path": "...",
  64. "type": "readwrite",
  65. "devices": [
  66. {
  67. "deviceID": "..."
  68. }
  69. ],
  70. "rescanIntervalS": 60,
  71. "ignorePerms": false,
  72. "autoNormalize": true,
  73. "minDiskFreePct": 1,
  74. "versioning": {
  75. "type": "",
  76. "params": {}
  77. },
  78. "copiers": 0,
  79. "pullers": 0,
  80. "hashers": 0,
  81. "order": "random",
  82. "ignoreDelete": false,
  83. "scanProgressIntervalS": 0,
  84. "pullerSleepS": 0,
  85. "pullerPauseS": 0,
  86. "maxConflicts": 10,
  87. "disableSparseFiles": false,
  88. "disableTempIndexes": false,
  89. "invalid": ""
  90. }
  91. ],
  92. "devices": [
  93. {
  94. "deviceID": "...",
  95. "name": "Laptop",
  96. "addresses": [
  97. "dynamic",
  98. "tcp://192.168.1.2:22000"
  99. ],
  100. "compression": "metadata",
  101. "certName": "",
  102. "introducer": false
  103. }
  104. ],
  105. "gui": {
  106. "enabled": true,
  107. "address": "127.0.0.1:8384",
  108. "user": "Username",
  109. "password": "$2a$10$ZFws69T4FlvWwsqeIwL.TOo5zOYqsa/.TxlUnsGYS.j3JvjFTmxo6",
  110. "useTLS": false,
  111. "apiKey": "pGahcht56664QU5eoFQW6szbEG6Ec2Cr",
  112. "insecureAdminAccess": false,
  113. "theme": "default"
  114. },
  115. "options": {
  116. "listenAddresses": [
  117. "default"
  118. ],
  119. "globalAnnounceServers": [
  120. "default"
  121. ],
  122. "globalAnnounceEnabled": true,
  123. "localAnnounceEnabled": true,
  124. "localAnnouncePort": 21027,
  125. "localAnnounceMCAddr": "[ff12::8384]:21027",
  126. "maxSendKbps": 0,
  127. "maxRecvKbps": 0,
  128. "reconnectionIntervalS": 60,
  129. "relaysEnabled": true,
  130. "relayReconnectIntervalM": 10,
  131. "startBrowser": false,
  132. "natEnabled": true,
  133. "natLeaseMinutes": 60,
  134. "natRenewalMinutes": 30,
  135. "natTimeoutSeconds": 10,
  136. "urAccepted": \-1,
  137. "urUniqueId": "",
  138. "urURL": "https://data.syncthing.net/newdata",
  139. "urPostInsecurely": false,
  140. "urInitialDelayS": 1800,
  141. "restartOnWakeup": true,
  142. "autoUpgradeIntervalH": 12,
  143. "keepTemporariesH": 24,
  144. "cacheIgnoredFiles": false,
  145. "progressUpdateIntervalS": 5,
  146. "symlinksEnabled": true,
  147. "limitBandwidthInLan": false,
  148. "minHomeDiskFreePct": 1,
  149. "releasesURL": "https://upgrades.syncthing.net/meta.json",
  150. "alwaysLocalNets": [],
  151. "overwriteRemoteDeviceNamesOnConnect": false,
  152. "tempIndexMinBlocks": 10
  153. },
  154. "ignoredDevices": []
  155. }
  156. }
  157. .ft P
  158. .fi
  159. .UNINDENT
  160. .UNINDENT
  161. .SS GET /rest/system/config/insync
  162. .sp
  163. Returns whether the config is in sync, i.e. whether the running
  164. configuration is the same as that on disk.
  165. .INDENT 0.0
  166. .INDENT 3.5
  167. .sp
  168. .nf
  169. .ft C
  170. {
  171. "configInSync": true
  172. }
  173. .ft P
  174. .fi
  175. .UNINDENT
  176. .UNINDENT
  177. .SS POST /rest/system/config
  178. .sp
  179. Post the full contents of the configuration, in the same format as returned by
  180. the corresponding GET request. The configuration will be saved to disk and the
  181. \fBconfigInSync\fP flag set to false. Restart Syncthing to activate.
  182. .SS GET /rest/system/connections
  183. .sp
  184. \fBNOTE:\fP
  185. .INDENT 0.0
  186. .INDENT 3.5
  187. Return format changed in 0.13.0.
  188. .UNINDENT
  189. .UNINDENT
  190. .sp
  191. Returns the list of configured devices and some metadata associated
  192. with them. The list also contains the local device itself as not connected.
  193. .sp
  194. The connection types are \fBTCP (Client)\fP, \fBTCP (Server)\fP, \fBRelay (Client)\fP and \fBRelay (Server)\fP\&.
  195. .INDENT 0.0
  196. .INDENT 3.5
  197. .sp
  198. .nf
  199. .ft C
  200. {
  201. "total" : {
  202. "paused" : false,
  203. "clientVersion" : "",
  204. "at" : "2015\-11\-07T17:29:47.691637262+01:00",
  205. "connected" : false,
  206. "inBytesTotal" : 1479,
  207. "type" : "",
  208. "outBytesTotal" : 1318,
  209. "address" : ""
  210. },
  211. "connections" : {
  212. "YZJBJFX\-RDBL7WY\-6ZGKJ2D\-4MJB4E7\-ZATSDUY\-LD6Y3L3\-MLFUYWE\-AEMXJAC" : {
  213. "connected" : true,
  214. "inBytesTotal" : 556,
  215. "paused" : false,
  216. "at" : "2015\-11\-07T17:29:47.691548971+01:00",
  217. "clientVersion" : "v0.12.1",
  218. "address" : "127.0.0.1:22002",
  219. "type" : "TCP (Client)",
  220. "outBytesTotal" : 550
  221. },
  222. "DOVII4U\-SQEEESM\-VZ2CVTC\-CJM4YN5\-QNV7DCU\-5U3ASRL\-YVFG6TH\-W5DV5AA" : {
  223. "outBytesTotal" : 0,
  224. "type" : "",
  225. "address" : "",
  226. "at" : "0001\-01\-01T00:00:00Z",
  227. "clientVersion" : "",
  228. "paused" : false,
  229. "inBytesTotal" : 0,
  230. "connected" : false
  231. },
  232. "UYGDMA4\-TPHOFO5\-2VQYDCC\-7CWX7XW\-INZINQT\-LE4B42N\-4JUZTSM\-IWCSXA4" : {
  233. "address" : "",
  234. "type" : "",
  235. "outBytesTotal" : 0,
  236. "connected" : false,
  237. "inBytesTotal" : 0,
  238. "paused" : false,
  239. "at" : "0001\-01\-01T00:00:00Z",
  240. "clientVersion" : ""
  241. }
  242. }
  243. }
  244. .ft P
  245. .fi
  246. .UNINDENT
  247. .UNINDENT
  248. .SS GET /rest/system/debug
  249. .sp
  250. New in version 0.12.0.
  251. .sp
  252. Returns the set of debug facilities and which of them are currently enabled.
  253. .INDENT 0.0
  254. .INDENT 3.5
  255. .sp
  256. .nf
  257. .ft C
  258. {
  259. "enabled": [
  260. "beacon"
  261. ],
  262. "facilities": {
  263. "beacon": "Multicast and broadcast discovery",
  264. "config": "Configuration loading and saving",
  265. "connections": "Connection handling",
  266. "db": "The database layer",
  267. "dialer": "Dialing connections",
  268. "discover": "Remote device discovery",
  269. "events": "Event generation and logging",
  270. "http": "REST API",
  271. "main": "Main package",
  272. "model": "The root hub",
  273. "protocol": "The BEP protocol",
  274. "relay": "Relay connection handling",
  275. "scanner": "File change detection and hashing",
  276. "stats": "Persistent device and folder statistics",
  277. "sync": "Mutexes",
  278. "upgrade": "Binary upgrades",
  279. "upnp": "UPnP discovery and port mapping",
  280. "versioner": "File versioning"
  281. }
  282. }
  283. .ft P
  284. .fi
  285. .UNINDENT
  286. .UNINDENT
  287. .SS POST /rest/system/debug
  288. .sp
  289. New in version 0.12.0.
  290. .sp
  291. Enables or disables debugging for specified facilities. Give one or both of
  292. \fBenable\fP and \fBdisable\fP query parameters, with comma separated facility
  293. names. To disable debugging of the beacon and discovery packages, and enable it
  294. for config and db:
  295. .INDENT 0.0
  296. .INDENT 3.5
  297. .sp
  298. .nf
  299. .ft C
  300. $ curl \-H X\-API\-Key:abc123 \-X POST \(aqhttp://localhost:8384/rest/system/debug?disable=beacon,discovery&enable=config,db\(aq
  301. .ft P
  302. .fi
  303. .UNINDENT
  304. .UNINDENT
  305. .SS GET /rest/system/discovery
  306. .sp
  307. Returns the contents of the local discovery cache.
  308. .INDENT 0.0
  309. .INDENT 3.5
  310. .sp
  311. .nf
  312. .ft C
  313. {
  314. "LGFPDIT7SKNNJVJZA4FC7QNCRKCE753K72BW5QD2FOZ7FRFEP57Q": [
  315. "192.162.129.11:22000"
  316. ]
  317. }
  318. .ft P
  319. .fi
  320. .UNINDENT
  321. .UNINDENT
  322. .SS POST /rest/system/discovery
  323. .sp
  324. \fBNOTE:\fP
  325. .INDENT 0.0
  326. .INDENT 3.5
  327. Removed in v0.12.0.
  328. .UNINDENT
  329. .UNINDENT
  330. .sp
  331. Post with the query parameters \fBdevice\fP and \fBaddr\fP to add entries to
  332. the discovery cache.
  333. .INDENT 0.0
  334. .INDENT 3.5
  335. .sp
  336. .nf
  337. .ft C
  338. curl \-X POST http://127.0.0.1:8384/rest/system/discovery?device=LGFPDIT7SKNNJVJZA4FC7QNCRKCE753K72BW5QD2FOZ7FRFEP57Q\e&addr=192.162.129.11:22000
  339. # Or with the X\-API\-Key header:
  340. curl \-X POST \-\-header "X\-API\-Key: TcE28kVPdtJ8COws1JdM0b2nodj77WeQ" http://127.0.0.1:8384/rest/system/discovery?device=LGFPDIT7SKNNJVJZA4FC7QNCRKCE753K72BW5QD2FOZ7FRFEP57Q\e&addr=192.162.129.11:22000
  341. .ft P
  342. .fi
  343. .UNINDENT
  344. .UNINDENT
  345. .SS POST /rest/system/error/clear
  346. .sp
  347. Post with empty to body to remove all recent errors.
  348. .SS GET /rest/system/error
  349. .sp
  350. \fBNOTE:\fP
  351. .INDENT 0.0
  352. .INDENT 3.5
  353. Return format changed in 0.12.0.
  354. .UNINDENT
  355. .UNINDENT
  356. .sp
  357. Returns the list of recent errors.
  358. .INDENT 0.0
  359. .INDENT 3.5
  360. .sp
  361. .nf
  362. .ft C
  363. {
  364. "errors": [
  365. {
  366. "when": "2014\-09\-18T12:59:26.549953186+02:00",
  367. "message": "This is an error string"
  368. }
  369. ]
  370. }
  371. .ft P
  372. .fi
  373. .UNINDENT
  374. .UNINDENT
  375. .SS POST /rest/system/error
  376. .sp
  377. Post with an error message in the body (plain text) to register a new
  378. error. The new error will be displayed on any active GUI clients.
  379. .SS GET /rest/system/log
  380. .sp
  381. New in version 0.12.0.
  382. .sp
  383. Returns the list of recent log entries.
  384. .INDENT 0.0
  385. .INDENT 3.5
  386. .sp
  387. .nf
  388. .ft C
  389. {
  390. "messages": [
  391. {
  392. "when": "2014\-09\-18T12:59:26.549953186+02:00",
  393. "message": "This is a log entry"
  394. }
  395. ]
  396. }
  397. .ft P
  398. .fi
  399. .UNINDENT
  400. .UNINDENT
  401. .SS GET /rest/system/ping
  402. .sp
  403. Returns a \fB{"ping": "pong"}\fP object.
  404. .INDENT 0.0
  405. .INDENT 3.5
  406. .sp
  407. .nf
  408. .ft C
  409. {
  410. "ping": "pong"
  411. }
  412. .ft P
  413. .fi
  414. .UNINDENT
  415. .UNINDENT
  416. .SS POST /rest/system/ping
  417. .sp
  418. Returns a \fB{"ping": "pong"}\fP object.
  419. .SS POST /rest/system/reset
  420. .sp
  421. Post with empty body to erase the current index database and restart
  422. Syncthing. With no query parameters, the entire database is erased from disk.
  423. By specifying the \fBfolder\fP parameter with a valid folder ID, only
  424. information for that folder will be erased:
  425. .INDENT 0.0
  426. .INDENT 3.5
  427. .sp
  428. .nf
  429. .ft C
  430. $ curl \-X POST \-H "X\-API\-Key: abc123" http://localhost:8384/rest/system/reset?folder=default
  431. .ft P
  432. .fi
  433. .UNINDENT
  434. .UNINDENT
  435. .SS POST /rest/system/restart
  436. .sp
  437. Post with empty body to immediately restart Syncthing.
  438. .SS POST /rest/system/shutdown
  439. .sp
  440. Post with empty body to cause Syncthing to exit and not restart.
  441. .SS GET /rest/system/status
  442. .sp
  443. Returns information about current system status and resource usage.
  444. .INDENT 0.0
  445. .INDENT 3.5
  446. .sp
  447. .nf
  448. .ft C
  449. {
  450. "alloc": 30618136,
  451. "connectionServiceStatus": {
  452. "dynamic+https://relays.syncthing.net/endpoint": {
  453. "lanAddresses": [
  454. "relay://23.92.71.120:443/?id=53STGR7\-YBM6FCX\-PAZ2RHM\-YPY6OEJ\-WYHVZO7\-PCKQRCK\-PZLTP7T\-434XCAD&pingInterval=1m0s&networkTimeout=2m0s&sessionLimitBps=0&globalLimitBps=0&statusAddr=:22070&providedBy=canton7"
  455. ],
  456. "wanAddresses": [
  457. "relay://23.92.71.120:443/?id=53STGR7\-YBM6FCX\-PAZ2RHM\-YPY6OEJ\-WYHVZO7\-PCKQRCK\-PZLTP7T\-434XCAD&pingInterval=1m0s&networkTimeout=2m0s&sessionLimitBps=0&globalLimitBps=0&statusAddr=:22070&providedBy=canton7"
  458. ]
  459. },
  460. "tcp://0.0.0.0:22000": {
  461. "lanAddresses": [
  462. "tcp://0.0.0.0:22000"
  463. ],
  464. "wanAddresses": [
  465. "tcp://0.0.0.0:22000"
  466. ]
  467. }
  468. },
  469. "cpuPercent": 0.006944836512046966,
  470. "discoveryEnabled": true,
  471. "discoveryErrors": {
  472. "global@https://discovery\-v4\-1.syncthing.net/v2/": "500 Internal Server Error",
  473. "global@https://discovery\-v4\-2.syncthing.net/v2/": "Post https://discovery\-v4\-2.syncthing.net/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)",
  474. "global@https://discovery\-v4\-3.syncthing.net/v2/": "Post https://discovery\-v4\-3.syncthing.net/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)",
  475. "global@https://discovery\-v6\-1.syncthing.net/v2/": "Post https://discovery\-v6\-1.syncthing.net/v2/: dial tcp [2001:470:28:4d6::5]:443: connect: no route to host",
  476. "global@https://discovery\-v6\-2.syncthing.net/v2/": "Post https://discovery\-v6\-2.syncthing.net/v2/: dial tcp [2604:a880:800:10::182:a001]:443: connect: no route to host",
  477. "global@https://discovery\-v6\-3.syncthing.net/v2/": "Post https://discovery\-v6\-3.syncthing.net/v2/: dial tcp [2400:6180:0:d0::d9:d001]:443: connect: no route to host"
  478. },
  479. "discoveryMethods": 8,
  480. "goroutines": 49,
  481. "myID": "P56IOI7\-MZJNU2Y\-IQGDREY\-DM2MGTI\-MGL3BXN\-PQ6W5BM\-TBBZ4TJ\-XZWICQ2",
  482. "pathSeparator": "/",
  483. "startTime": "2016\-06\-06T19:41:43.039284753+02:00",
  484. "sys": 42092792,
  485. "themes": [
  486. "default",
  487. "dark"
  488. ],
  489. "tilde": "/Users/jb",
  490. "uptime": 2635
  491. }
  492. .ft P
  493. .fi
  494. .UNINDENT
  495. .UNINDENT
  496. .SS GET /rest/system/upgrade
  497. .sp
  498. Checks for a possible upgrade and returns an object describing the
  499. newest version and upgrade possibility.
  500. .INDENT 0.0
  501. .INDENT 3.5
  502. .sp
  503. .nf
  504. .ft C
  505. {
  506. "latest": "v0.10.27",
  507. "newer": false,
  508. "running": "v0.10.27+5\-g36c93b7"
  509. }
  510. .ft P
  511. .fi
  512. .UNINDENT
  513. .UNINDENT
  514. .SS POST /rest/system/upgrade
  515. .sp
  516. Perform an upgrade to the newest released version and restart. Does
  517. nothing if there is no newer version than currently running.
  518. .SS GET /rest/system/version
  519. .sp
  520. Returns the current Syncthing version information.
  521. .INDENT 0.0
  522. .INDENT 3.5
  523. .sp
  524. .nf
  525. .ft C
  526. {
  527. "arch": "amd64",
  528. "longVersion": "syncthing v0.10.27+3\-gea8c3de (go1.4 darwin\-amd64 default) jb@syno 2015\-03\-16 11:01:29 UTC",
  529. "os": "darwin",
  530. "version": "v0.10.27+3\-gea8c3de"
  531. }
  532. .ft P
  533. .fi
  534. .UNINDENT
  535. .UNINDENT
  536. .SH DATABASE ENDPOINTS
  537. .SS GET /rest/db/browse
  538. .sp
  539. Returns the directory tree of the global model. Directories are always
  540. JSON objects (map/dictionary), and files are always arrays of
  541. modification time and size. The first integer is the files modification
  542. time, and the second integer is the file size.
  543. .sp
  544. The call takes one mandatory \fBfolder\fP parameter and two optional
  545. parameters. Optional parameter \fBlevels\fP defines how deep within the
  546. tree we want to dwell down (0 based, defaults to unlimited depth)
  547. Optional parameter \fBprefix\fP defines a prefix within the tree where to
  548. start building the structure.
  549. .INDENT 0.0
  550. .INDENT 3.5
  551. .sp
  552. .nf
  553. .ft C
  554. $ curl \-s http://localhost:8384/rest/db/browse?folder=default | json_pp
  555. {
  556. "directory": {
  557. "file": ["2015\-04\-20T22:20:45+09:00", 130940928],
  558. "subdirectory": {
  559. "another file": ["2015\-04\-20T22:20:45+09:00", 130940928]
  560. }
  561. },
  562. "rootfile": ["2015\-04\-20T22:20:45+09:00", 130940928]
  563. }
  564. $ curl \-s http://localhost:8384/rest/db/browse?folder=default&levels=0 | json_pp
  565. {
  566. "directory": {},
  567. "rootfile": ["2015\-04\-20T22:20:45+09:00", 130940928]
  568. }
  569. $ curl \-s http://localhost:8384/rest/db/browse?folder=default&levels=1 | json_pp
  570. {
  571. "directory": {
  572. "file": ["2015\-04\-20T22:20:45+09:00", 130940928],
  573. "subdirectory": {}
  574. },
  575. "rootfile": ["2015\-04\-20T22:20:45+09:00", 130940928]
  576. }
  577. $ curl \-s http://localhost:8384/rest/db/browse?folder=default&prefix=directory/subdirectory | json_pp
  578. {
  579. "another file": ["2015\-04\-20T22:20:45+09:00", 130940928]
  580. }
  581. $ curl \-s http://localhost:8384/rest/db/browse?folder=default&prefix=directory&levels=0 | json_pp
  582. {
  583. "file": ["2015\-04\-20T22:20:45+09:00", 130940928],
  584. "subdirectory": {}
  585. }
  586. .ft P
  587. .fi
  588. .UNINDENT
  589. .UNINDENT
  590. .sp
  591. \fBNOTE:\fP
  592. .INDENT 0.0
  593. .INDENT 3.5
  594. This is an expensive call, increasing CPU and RAM usage on the device. Use sparingly.
  595. .UNINDENT
  596. .UNINDENT
  597. .SS GET /rest/db/completion
  598. .sp
  599. Returns the completion percentage (0 to 100) for a given device and
  600. folder. Takes \fBdevice\fP and \fBfolder\fP parameters.
  601. .INDENT 0.0
  602. .INDENT 3.5
  603. .sp
  604. .nf
  605. .ft C
  606. {
  607. "completion": 0
  608. }
  609. .ft P
  610. .fi
  611. .UNINDENT
  612. .UNINDENT
  613. .sp
  614. \fBNOTE:\fP
  615. .INDENT 0.0
  616. .INDENT 3.5
  617. This is an expensive call, increasing CPU and RAM usage on the device. Use sparingly.
  618. .UNINDENT
  619. .UNINDENT
  620. .SS GET /rest/db/file
  621. .sp
  622. Returns most data available about a given file, including version and
  623. availability. Takes \fBfolder\fP and \fBfile\fP parameters.
  624. .INDENT 0.0
  625. .INDENT 3.5
  626. .sp
  627. .nf
  628. .ft C
  629. {
  630. "availability": [
  631. "I6KAH76\-66SLLLB\-5PFXSOA\-UFJCDZC\-YAOMLEK\-CP2GB32\-BV5RQST\-3PSROAU"
  632. ],
  633. "global": {
  634. "flags": "0644",
  635. "localVersion": 3,
  636. "modified": "2015\-04\-20T22:20:45+09:00",
  637. "name": "util.go",
  638. "numBlocks": 1,
  639. "size": 9642,
  640. "version": [
  641. "5407294127585413568:1"
  642. ]
  643. },
  644. "local": {
  645. "flags": "0644",
  646. "localVersion": 4,
  647. "modified": "2015\-04\-20T22:20:45+09:00",
  648. "name": "util.go",
  649. "numBlocks": 1,
  650. "size": 9642,
  651. "version": [
  652. "5407294127585413568:1"
  653. ]
  654. }
  655. }
  656. .ft P
  657. .fi
  658. .UNINDENT
  659. .UNINDENT
  660. .SS GET /rest/db/ignores
  661. .sp
  662. Takes one parameter, \fBfolder\fP, and returns the content of the
  663. \fB\&.stignore\fP as the \fBignore\fP field. A second field, \fBexpanded\fP,
  664. provides a list of strings which represent globbing patterns described by gobwas/glob (based on standard wildcards) that match the patterns in \fB\&.stignore\fP and all the includes. If appropriate these globs are prepended by the following modifiers: \fB!\fP to negate the glob, \fB(?i)\fP to do case insensitive matching and \fB(?d)\fP to enable removing of ignored files in an otherwise empty directory.
  665. .INDENT 0.0
  666. .INDENT 3.5
  667. .sp
  668. .nf
  669. .ft C
  670. {
  671. "ignore": [
  672. "(?i)/Backups"
  673. ],
  674. "expanded": [
  675. "(?i)Backups",
  676. "(?i)Backups/**"
  677. ]
  678. }
  679. .ft P
  680. .fi
  681. .UNINDENT
  682. .UNINDENT
  683. .SS POST /rest/db/ignores
  684. .sp
  685. Expects a format similar to the output of \fBGET\fP call, but only
  686. containing the \fBignore\fP field (\fBpatterns\fP field should be omitted).
  687. It takes one parameter, \fBfolder\fP, and either updates the content of
  688. the \fB\&.stignore\fP echoing it back as a response, or returns an error.
  689. .SS GET /rest/db/need
  690. .sp
  691. Takes one mandatory parameter, \fBfolder\fP, and returns lists of files which are
  692. needed by this device in order for it to become in sync.
  693. .sp
  694. Furthermore takes an optional \fBpage\fP and \fBperpage\fP arguments for pagination.
  695. Pagination happens, across the union of all needed files, that is \- across all
  696. 3 sections of the response.
  697. For example, given the current need state is as follows:
  698. .INDENT 0.0
  699. .IP 1. 3
  700. \fBprogress\fP has 15 items
  701. .IP 2. 3
  702. \fBqueued\fP has 3 items
  703. .IP 3. 3
  704. \fBrest\fP has 12 items
  705. .UNINDENT
  706. .sp
  707. If you issue a query with \fBpage=1\fP and \fBperpage=10\fP, only the \fBprogress\fP
  708. section in the response will have 10 items. If you issue a request query with
  709. \fBpage=2\fP and \fBperpage=10\fP, \fBprogress\fP section will have the last 5 items,
  710. \fBqueued\fP section will have all 3 items, and \fBrest\fP section will have first
  711. 2 items. If you issue a query for \fBpage=3\fP and \fBperpage=10\fP, you will only
  712. have the last 10 items of the \fBrest\fP section.
  713. .sp
  714. In all these calls, \fBtotal\fP will be 30 to indicate the total number of
  715. available items.
  716. .INDENT 0.0
  717. .INDENT 3.5
  718. .sp
  719. .nf
  720. .ft C
  721. {
  722. # Files currently being downloaded
  723. "progress": [
  724. {
  725. "flags": "0755",
  726. "localVersion": 6,
  727. "modified": "2015\-04\-20T23:06:12+09:00",
  728. "name": "ls",
  729. "size": 34640,
  730. "version": [
  731. "5157751870738175669:1"
  732. ]
  733. }
  734. ],
  735. # Files queued to be downloaded next (as per array order)
  736. "queued": [
  737. ...
  738. ],
  739. # Files to be downloaded after all queued files will be downloaded.
  740. # This happens when we start downloading files, and new files get added while we are downloading.
  741. "rest": [
  742. ...
  743. ],
  744. "page": 1,
  745. "perpage": 100,
  746. "total": 2000
  747. }
  748. .ft P
  749. .fi
  750. .UNINDENT
  751. .UNINDENT
  752. .sp
  753. \fBNOTE:\fP
  754. .INDENT 0.0
  755. .INDENT 3.5
  756. This is an expensive call, increasing CPU and RAM usage on the device. Use sparingly.
  757. .UNINDENT
  758. .UNINDENT
  759. .SS POST /rest/db/override
  760. .sp
  761. Request override of a master folder.
  762. Takes the mandatory parameter \fIfolder\fP (folder ID).
  763. .INDENT 0.0
  764. .INDENT 3.5
  765. .sp
  766. .nf
  767. .ft C
  768. curl \-X POST http://127.0.0.1:8384/rest/db/override?folder=default
  769. .ft P
  770. .fi
  771. .UNINDENT
  772. .UNINDENT
  773. .SS POST /rest/db/prio
  774. .sp
  775. Moves the file to the top of the download queue.
  776. .INDENT 0.0
  777. .INDENT 3.5
  778. .sp
  779. .nf
  780. .ft C
  781. curl \-X POST http://127.0.0.1:8384/rest/db/prio?folder=default&file=foo/bar
  782. .ft P
  783. .fi
  784. .UNINDENT
  785. .UNINDENT
  786. .sp
  787. Response contains the same output as \fBGET /rest/db/need\fP
  788. .SS POST /rest/db/scan
  789. .sp
  790. Request immediate rescan of a folder, or a specific path within a folder.
  791. Takes the mandatory parameter \fIfolder\fP (folder ID), an optional parameter
  792. \fBsub\fP (path relative to the folder root) and an optional parameter \fBnext\fP\&. If
  793. \fBsub\fP is omitted or empty, the entire folder is scanned for changes, otherwise
  794. only the given path (and children, in case it\(aqs a directory) is scanned. The
  795. \fBnext\fP argument delays Syncthing\(aqs automated rescan interval for a given
  796. amount of seconds.
  797. .sp
  798. Requesting scan of a path that no longer exists, but previously did, is
  799. valid and will result in Syncthing noticing the deletion of the path in
  800. question.
  801. .sp
  802. Returns status 200 and no content upon success, or status 500 and a
  803. plain text error if an error occurred during scanning.
  804. .INDENT 0.0
  805. .INDENT 3.5
  806. .sp
  807. .nf
  808. .ft C
  809. curl \-X POST http://127.0.0.1:8384/rest/db/scan?folder=default&sub=foo/bar
  810. .ft P
  811. .fi
  812. .UNINDENT
  813. .UNINDENT
  814. .SS GET /rest/db/status
  815. .sp
  816. Returns information about the current status of a folder.
  817. .sp
  818. Parameters: \fBfolder\fP, the ID of a folder.
  819. .INDENT 0.0
  820. .INDENT 3.5
  821. .sp
  822. .nf
  823. .ft C
  824. {
  825. # latest version according to cluster:
  826. "globalBytes": 13173473780,
  827. "globalDeleted": 1847,
  828. "globalFiles": 42106,
  829. # what we have locally:
  830. "localBytes": 13173473780,
  831. "localDeleted": 1847,
  832. "localFiles": 42106,
  833. # which part of what we have locally is the latest cluster version:
  834. "inSyncBytes": 13173473780,
  835. "inSyncFiles": 42106,
  836. # which part of what we have locally should be fetched from the cluster:
  837. "needBytes": 0,
  838. "needFiles": 0,
  839. # various other metadata
  840. "ignorePatterns": true,
  841. "invalid": "",
  842. "state": "idle",
  843. "stateChanged": "2015\-03\-16T21:47:28.750853241+01:00",
  844. "version": 71989
  845. }
  846. .ft P
  847. .fi
  848. .UNINDENT
  849. .UNINDENT
  850. .sp
  851. \fBNOTE:\fP
  852. .INDENT 0.0
  853. .INDENT 3.5
  854. This is an expensive call, increasing CPU and RAM usage on the device. Use sparingly.
  855. .UNINDENT
  856. .UNINDENT
  857. .SH STATISTICS ENDPOINTS
  858. .SS GET /rest/stats/device
  859. .sp
  860. Returns general statistics about devices. Currently, only contains the
  861. time the device was last seen.
  862. .INDENT 0.0
  863. .INDENT 3.5
  864. .sp
  865. .nf
  866. .ft C
  867. $ curl \-s http://localhost:8384/rest/stats/device | json
  868. {
  869. "P56IOI7\-MZJNU2Y\-IQGDREY\-DM2MGTI\-MGL3BXN\-PQ6W5BM\-TBBZ4TJ\-XZWICQ2": {
  870. "lastSeen" : "2015\-04\-18T11:21:31.3256277+01:00"
  871. }
  872. }
  873. .ft P
  874. .fi
  875. .UNINDENT
  876. .UNINDENT
  877. .SS GET /rest/stats/folder
  878. .sp
  879. Returns general statistics about folders. Currently contains the
  880. last scan time and the last synced file.
  881. .INDENT 0.0
  882. .INDENT 3.5
  883. .sp
  884. .nf
  885. .ft C
  886. $ curl \-s http://localhost:8384/rest/stats/folder | json
  887. {
  888. "folderid" : {
  889. "lastScan": "2016\-06\-02T13:28:01.288181412\-04:00",
  890. "lastFile" : {
  891. "filename" : "file/name",
  892. "at" : "2015\-04\-16T22:04:18.3066971+01:00"
  893. }
  894. }
  895. }
  896. .ft P
  897. .fi
  898. .UNINDENT
  899. .UNINDENT
  900. .SH MISC SERVICES ENDPOINTS
  901. .SS GET /rest/svc/deviceid
  902. .sp
  903. Verifies and formats a device ID. Accepts all currently valid formats
  904. (52 or 56 characters with or without separators, upper or lower case,
  905. with trivial substitutions). Takes one parameter, \fBid\fP, and returns
  906. either a valid device ID in modern format, or an error.
  907. .INDENT 0.0
  908. .INDENT 3.5
  909. .sp
  910. .nf
  911. .ft C
  912. $ curl \-s http://localhost:8384/rest/svc/deviceid?id=1234 | json
  913. {
  914. "error": "device ID invalid: incorrect length"
  915. }
  916. $ curl \-s http://localhost:8384/rest/svc/deviceid?id=p56ioi7m\-\-zjnu2iq\-gdr\-eydm\-2mgtmgl3bxnpq6w5btbbz4tjxzwicq | json
  917. {
  918. "id": "P56IOI7\-MZJNU2Y\-IQGDREY\-DM2MGTI\-MGL3BXN\-PQ6W5BM\-TBBZ4TJ\-XZWICQ2"
  919. }
  920. .ft P
  921. .fi
  922. .UNINDENT
  923. .UNINDENT
  924. .SS GET /rest/svc/lang
  925. .sp
  926. Returns a list of canonicalized localization codes, as picked up from
  927. the \fBAccept\-Language\fP header sent by the browser.
  928. .INDENT 0.0
  929. .INDENT 3.5
  930. .sp
  931. .nf
  932. .ft C
  933. ["sv_sv","sv","en_us","en"]
  934. .ft P
  935. .fi
  936. .UNINDENT
  937. .UNINDENT
  938. .SS GET /rest/svc/report
  939. .sp
  940. Returns the data sent in the anonymous usage report.
  941. .INDENT 0.0
  942. .INDENT 3.5
  943. .sp
  944. .nf
  945. .ft C
  946. {
  947. "folderMaxMiB" : 0,
  948. "platform" : "linux\-amd64",
  949. "totMiB" : 0,
  950. "longVersion" : "syncthing v0.12.2 \e"Beryllium Bedbug\e" (go1.4.3 linux\-amd64 default) unknown\[email protected] 2015\-11\-09 13:23:26 UTC",
  951. "upgradeAllowedManual" : true,
  952. "totFiles" : 3,
  953. "folderUses" : {
  954. "ignorePerms" : 0,
  955. "autoNormalize" : 0,
  956. "readonly" : 0,
  957. "ignoreDelete" : 0
  958. },
  959. "memoryUsageMiB" : 13,
  960. "version" : "v0.12.2",
  961. "sha256Perf" : 27.28,
  962. "numFolders" : 2,
  963. "memorySize" : 1992,
  964. "announce" : {
  965. "defaultServersIP" : 0,
  966. "otherServers" : 0,
  967. "globalEnabled" : false,
  968. "defaultServersDNS" : 1,
  969. "localEnabled" : false
  970. },
  971. "usesRateLimit" : false,
  972. "numCPU" : 2,
  973. "uniqueID" : "",
  974. "urVersion" : 2,
  975. "rescanIntvs" : [
  976. 60,
  977. 60
  978. ],
  979. "numDevices" : 2,
  980. "folderMaxFiles" : 3,
  981. "relays" : {
  982. "defaultServers" : 1,
  983. "enabled" : true,
  984. "otherServers" : 0
  985. },
  986. "deviceUses" : {
  987. "compressMetadata" : 1,
  988. "customCertName" : 0,
  989. "staticAddr" : 1,
  990. "compressAlways" : 0,
  991. "compressNever" : 1,
  992. "introducer" : 0,
  993. "dynamicAddr" : 1
  994. },
  995. "upgradeAllowedAuto" : false
  996. }
  997. .ft P
  998. .fi
  999. .UNINDENT
  1000. .UNINDENT
  1001. .SH AUTHOR
  1002. The Syncthing Authors
  1003. .SH COPYRIGHT
  1004. 2015, The Syncthing Authors
  1005. .\" Generated by docutils manpage writer.
  1006. .