syncthing-rest-api.7 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207
  1. .\" Man page generated from reStructuredText.
  2. .
  3. .TH "SYNCTHING-REST-API" "7" "Mar 22, 2019" "v1" "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. .sp
  34. Syncthing exposes a REST interface over HTTP on the GUI port. This is used by
  35. the GUI (from Javascript) and can be used by other processes wishing to control
  36. Syncthing. In most cases both the input and output data is in JSON format. The
  37. interface is subject to change.
  38. .SH API KEY
  39. .sp
  40. To use the REST API an API key must be set and used. The API key can be
  41. generated in the GUI, or set in the \fBconfiguration/gui/apikey\fP element in
  42. the configuration file. To use an API key, set the request header
  43. \fBX\-API\-Key\fP to the API key value. For example, \fBcurl \-X POST \-H
  44. "X\-API\-Key: abc123" http://localhost:8384/rest/...\fP can be used to invoke
  45. with \fBcurl\fP\&.
  46. .SH SYSTEM ENDPOINTS
  47. .SS GET /rest/system/browse
  48. .sp
  49. Returns a list of directories matching the path given by the optional parameter
  50. \fBcurrent\fP\&. The path can use \fI\%patterns as described in Go’s filepath package\fP <\fBhttps://golang.org/pkg/path/filepath/#Match\fP>\&. A ‘*’ will always be appended
  51. to the given path (e.g. \fB/tmp/\fP matches all its subdirectories). If the option
  52. \fBcurrent\fP is not given, filesystem root paths are returned.
  53. .INDENT 0.0
  54. .INDENT 3.5
  55. .sp
  56. .nf
  57. .ft C
  58. $ curl \-H "X\-API\-Key: yourkey" localhost:8384/rest/system/browse | json_pp
  59. [
  60. "/"
  61. ]
  62. $ curl \-H "X\-API\-Key: yourkey" localhost:8384/rest/system/browse?current=/var/ | json_pp
  63. [
  64. "/var/backups/",
  65. "/var/cache/",
  66. "/var/lib/",
  67. "/var/local/",
  68. "/var/lock/",
  69. "/var/log/",
  70. "/var/mail/",
  71. "/var/opt/",
  72. "/var/run/",
  73. "/var/spool/",
  74. "/var/tmp/"
  75. ]
  76. $ curl \-H "X\-API\-Key: yourkey" localhost:8384/rest/system/browse?current=/var/*o | json_pp
  77. [
  78. "/var/local/",
  79. "/var/lock/",
  80. "/var/log/",
  81. "/var/opt/",
  82. "/var/spool/"
  83. ]
  84. .ft P
  85. .fi
  86. .UNINDENT
  87. .UNINDENT
  88. .SS GET /rest/system/config
  89. .sp
  90. Returns the current configuration.
  91. .INDENT 0.0
  92. .INDENT 3.5
  93. .sp
  94. .nf
  95. .ft C
  96. {
  97. {
  98. "version": 15,
  99. "folders": [
  100. {
  101. "id": "GXWxf\-3zgnU",
  102. "label": "MyFolder",
  103. "path": "...",
  104. "type": "sendreceive",
  105. "devices": [
  106. {
  107. "deviceID": "..."
  108. }
  109. ],
  110. "rescanIntervalS": 60,
  111. "ignorePerms": false,
  112. "autoNormalize": true,
  113. "minDiskFreePct": 1,
  114. "versioning": {
  115. "type": "simple",
  116. "params": {
  117. "keep": "5"
  118. }
  119. },
  120. "copiers": 0,
  121. "pullers": 0,
  122. "hashers": 0,
  123. "order": "random",
  124. "ignoreDelete": false,
  125. "scanProgressIntervalS": 0,
  126. "pullerSleepS": 0,
  127. "pullerPauseS": 0,
  128. "maxConflicts": 10,
  129. "disableSparseFiles": false,
  130. "disableTempIndexes": false,
  131. "fsync": false,
  132. "invalid": ""
  133. }
  134. ],
  135. "devices": [
  136. {
  137. "deviceID": "...",
  138. "name": "Laptop",
  139. "addresses": [
  140. "dynamic",
  141. "tcp://192.168.1.2:22000"
  142. ],
  143. "compression": "metadata",
  144. "certName": "",
  145. "introducer": false
  146. }
  147. ],
  148. "gui": {
  149. "enabled": true,
  150. "address": "127.0.0.1:8384",
  151. "user": "Username",
  152. "password": "$2a$10$ZFws69T4FlvWwsqeIwL.TOo5zOYqsa/.TxlUnsGYS.j3JvjFTmxo6",
  153. "useTLS": false,
  154. "apiKey": "pGahcht56664QU5eoFQW6szbEG6Ec2Cr",
  155. "insecureAdminAccess": false,
  156. "theme": "default"
  157. },
  158. "options": {
  159. "listenAddresses": [
  160. "default"
  161. ],
  162. "globalAnnounceServers": [
  163. "default"
  164. ],
  165. "globalAnnounceEnabled": true,
  166. "localAnnounceEnabled": true,
  167. "localAnnouncePort": 21027,
  168. "localAnnounceMCAddr": "[ff12::8384]:21027",
  169. "maxSendKbps": 0,
  170. "maxRecvKbps": 0,
  171. "reconnectionIntervalS": 60,
  172. "relaysEnabled": true,
  173. "relayReconnectIntervalM": 10,
  174. "startBrowser": false,
  175. "natEnabled": true,
  176. "natLeaseMinutes": 60,
  177. "natRenewalMinutes": 30,
  178. "natTimeoutSeconds": 10,
  179. "urAccepted": \-1,
  180. "urUniqueId": "",
  181. "urURL": "https://data.syncthing.net/newdata",
  182. "urPostInsecurely": false,
  183. "urInitialDelayS": 1800,
  184. "restartOnWakeup": true,
  185. "autoUpgradeIntervalH": 12,
  186. "keepTemporariesH": 24,
  187. "cacheIgnoredFiles": false,
  188. "progressUpdateIntervalS": 5,
  189. "limitBandwidthInLan": false,
  190. "minHomeDiskFreePct": 1,
  191. "releasesURL": "https://upgrades.syncthing.net/meta.json",
  192. "alwaysLocalNets": [],
  193. "overwriteRemoteDeviceNamesOnConnect": false,
  194. "tempIndexMinBlocks": 10
  195. },
  196. "ignoredDevices": [],
  197. "ignoredFolders": []
  198. }
  199. }
  200. .ft P
  201. .fi
  202. .UNINDENT
  203. .UNINDENT
  204. .SS GET /rest/system/config/insync
  205. .sp
  206. Returns whether the config is in sync, i.e. whether the running
  207. configuration is the same as that on disk.
  208. .INDENT 0.0
  209. .INDENT 3.5
  210. .sp
  211. .nf
  212. .ft C
  213. {
  214. "configInSync": true
  215. }
  216. .ft P
  217. .fi
  218. .UNINDENT
  219. .UNINDENT
  220. .SS POST /rest/system/config
  221. .sp
  222. Post the full contents of the configuration, in the same format as returned by
  223. the corresponding GET request. The configuration will be saved to disk and the
  224. \fBconfigInSync\fP flag set to false. Restart Syncthing to activate.
  225. .SS GET /rest/system/connections
  226. .sp
  227. \fBNOTE:\fP
  228. .INDENT 0.0
  229. .INDENT 3.5
  230. Return format changed in 0.13.0.
  231. .UNINDENT
  232. .UNINDENT
  233. .sp
  234. Returns the list of configured devices and some metadata associated
  235. with them. The list also contains the local device itself as not connected.
  236. .sp
  237. The connection types are \fBTCP (Client)\fP, \fBTCP (Server)\fP, \fBRelay (Client)\fP and \fBRelay (Server)\fP\&.
  238. .INDENT 0.0
  239. .INDENT 3.5
  240. .sp
  241. .nf
  242. .ft C
  243. {
  244. "total" : {
  245. "paused" : false,
  246. "clientVersion" : "",
  247. "at" : "2015\-11\-07T17:29:47.691637262+01:00",
  248. "connected" : false,
  249. "inBytesTotal" : 1479,
  250. "type" : "",
  251. "outBytesTotal" : 1318,
  252. "address" : ""
  253. },
  254. "connections" : {
  255. "YZJBJFX\-RDBL7WY\-6ZGKJ2D\-4MJB4E7\-ZATSDUY\-LD6Y3L3\-MLFUYWE\-AEMXJAC" : {
  256. "connected" : true,
  257. "inBytesTotal" : 556,
  258. "paused" : false,
  259. "at" : "2015\-11\-07T17:29:47.691548971+01:00",
  260. "clientVersion" : "v0.12.1",
  261. "address" : "127.0.0.1:22002",
  262. "type" : "TCP (Client)",
  263. "outBytesTotal" : 550
  264. },
  265. "DOVII4U\-SQEEESM\-VZ2CVTC\-CJM4YN5\-QNV7DCU\-5U3ASRL\-YVFG6TH\-W5DV5AA" : {
  266. "outBytesTotal" : 0,
  267. "type" : "",
  268. "address" : "",
  269. "at" : "0001\-01\-01T00:00:00Z",
  270. "clientVersion" : "",
  271. "paused" : false,
  272. "inBytesTotal" : 0,
  273. "connected" : false
  274. },
  275. "UYGDMA4\-TPHOFO5\-2VQYDCC\-7CWX7XW\-INZINQT\-LE4B42N\-4JUZTSM\-IWCSXA4" : {
  276. "address" : "",
  277. "type" : "",
  278. "outBytesTotal" : 0,
  279. "connected" : false,
  280. "inBytesTotal" : 0,
  281. "paused" : false,
  282. "at" : "0001\-01\-01T00:00:00Z",
  283. "clientVersion" : ""
  284. }
  285. }
  286. }
  287. .ft P
  288. .fi
  289. .UNINDENT
  290. .UNINDENT
  291. .SS GET /rest/system/debug
  292. .sp
  293. New in version 0.12.0.
  294. .sp
  295. Returns the set of debug facilities and which of them are currently enabled.
  296. .INDENT 0.0
  297. .INDENT 3.5
  298. .sp
  299. .nf
  300. .ft C
  301. {
  302. "enabled": [
  303. "beacon"
  304. ],
  305. "facilities": {
  306. "beacon": "Multicast and broadcast discovery",
  307. "config": "Configuration loading and saving",
  308. "connections": "Connection handling",
  309. "db": "The database layer",
  310. "dialer": "Dialing connections",
  311. "discover": "Remote device discovery",
  312. "events": "Event generation and logging",
  313. "http": "REST API",
  314. "main": "Main package",
  315. "model": "The root hub",
  316. "protocol": "The BEP protocol",
  317. "relay": "Relay connection handling",
  318. "scanner": "File change detection and hashing",
  319. "stats": "Persistent device and folder statistics",
  320. "sync": "Mutexes",
  321. "upgrade": "Binary upgrades",
  322. "upnp": "UPnP discovery and port mapping",
  323. "versioner": "File versioning"
  324. }
  325. }
  326. .ft P
  327. .fi
  328. .UNINDENT
  329. .UNINDENT
  330. .SS POST /rest/system/debug
  331. .sp
  332. New in version 0.12.0.
  333. .sp
  334. Enables or disables debugging for specified facilities. Give one or both of
  335. \fBenable\fP and \fBdisable\fP query parameters, with comma separated facility
  336. names. To disable debugging of the beacon and discovery packages, and enable it
  337. for config and db:
  338. .INDENT 0.0
  339. .INDENT 3.5
  340. .sp
  341. .nf
  342. .ft C
  343. $ curl \-H X\-API\-Key:abc123 \-X POST \(aqhttp://localhost:8384/rest/system/debug?disable=beacon,discovery&enable=config,db\(aq
  344. .ft P
  345. .fi
  346. .UNINDENT
  347. .UNINDENT
  348. .SS GET /rest/system/discovery
  349. .sp
  350. Returns the contents of the local discovery cache.
  351. .INDENT 0.0
  352. .INDENT 3.5
  353. .sp
  354. .nf
  355. .ft C
  356. {
  357. "LGFPDIT7SKNNJVJZA4FC7QNCRKCE753K72BW5QD2FOZ7FRFEP57Q": [
  358. "192.162.129.11:22000"
  359. ]
  360. }
  361. .ft P
  362. .fi
  363. .UNINDENT
  364. .UNINDENT
  365. .SS POST /rest/system/discovery
  366. .sp
  367. \fBNOTE:\fP
  368. .INDENT 0.0
  369. .INDENT 3.5
  370. Removed in v0.12.0.
  371. .UNINDENT
  372. .UNINDENT
  373. .sp
  374. Post with the query parameters \fBdevice\fP and \fBaddr\fP to add entries to
  375. the discovery cache.
  376. .INDENT 0.0
  377. .INDENT 3.5
  378. .sp
  379. .nf
  380. .ft C
  381. curl \-X POST http://127.0.0.1:8384/rest/system/discovery?device=LGFPDIT7SKNNJVJZA4FC7QNCRKCE753K72BW5QD2FOZ7FRFEP57Q\e&addr=192.162.129.11:22000
  382. # Or with the X\-API\-Key header:
  383. 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
  384. .ft P
  385. .fi
  386. .UNINDENT
  387. .UNINDENT
  388. .SS POST /rest/system/error/clear
  389. .sp
  390. Post with empty to body to remove all recent errors.
  391. .SS GET /rest/system/error
  392. .sp
  393. \fBNOTE:\fP
  394. .INDENT 0.0
  395. .INDENT 3.5
  396. Return format changed in 0.12.0.
  397. .UNINDENT
  398. .UNINDENT
  399. .sp
  400. Returns the list of recent errors.
  401. .INDENT 0.0
  402. .INDENT 3.5
  403. .sp
  404. .nf
  405. .ft C
  406. {
  407. "errors": [
  408. {
  409. "when": "2014\-09\-18T12:59:26.549953186+02:00",
  410. "message": "This is an error string"
  411. }
  412. ]
  413. }
  414. .ft P
  415. .fi
  416. .UNINDENT
  417. .UNINDENT
  418. .SS POST /rest/system/error
  419. .sp
  420. Post with an error message in the body (plain text) to register a new
  421. error. The new error will be displayed on any active GUI clients.
  422. .SS GET /rest/system/log
  423. .sp
  424. New in version 0.12.0.
  425. .sp
  426. Returns the list of recent log entries.
  427. .INDENT 0.0
  428. .INDENT 3.5
  429. .sp
  430. .nf
  431. .ft C
  432. {
  433. "messages": [
  434. {
  435. "when": "2014\-09\-18T12:59:26.549953186+02:00",
  436. "message": "This is a log entry"
  437. }
  438. ]
  439. }
  440. .ft P
  441. .fi
  442. .UNINDENT
  443. .UNINDENT
  444. .SS POST /rest/system/pause
  445. .sp
  446. Pause the given device or all devices.
  447. .sp
  448. Takes the optional parameter \fBdevice\fP (device ID). When omitted,
  449. pauses all devices. Returns status 200 and no content upon success, or status
  450. 500 and a plain text error on failure.
  451. .SS GET /rest/system/ping
  452. .sp
  453. Returns a \fB{"ping": "pong"}\fP object.
  454. .INDENT 0.0
  455. .INDENT 3.5
  456. .sp
  457. .nf
  458. .ft C
  459. {
  460. "ping": "pong"
  461. }
  462. .ft P
  463. .fi
  464. .UNINDENT
  465. .UNINDENT
  466. .SS POST /rest/system/ping
  467. .sp
  468. Returns a \fB{"ping": "pong"}\fP object.
  469. .SS POST /rest/system/reset
  470. .sp
  471. Post with empty body to erase the current index database and restart
  472. Syncthing. With no query parameters, the entire database is erased from disk.
  473. By specifying the \fBfolder\fP parameter with a valid folder ID, only
  474. information for that folder will be erased:
  475. .INDENT 0.0
  476. .INDENT 3.5
  477. .sp
  478. .nf
  479. .ft C
  480. $ curl \-X POST \-H "X\-API\-Key: abc123" http://localhost:8384/rest/system/reset?folder=default
  481. .ft P
  482. .fi
  483. .UNINDENT
  484. .UNINDENT
  485. .sp
  486. \fBCaution\fP: See \fB\-reset\-database\fP for \fB\&.stfolder\fP creation side\-effect and caution regarding mountpoints.
  487. .SS POST /rest/system/restart
  488. .sp
  489. Post with empty body to immediately restart Syncthing.
  490. .SS POST /rest/system/resume
  491. .sp
  492. Resume the given device or all devices.
  493. .sp
  494. Takes the optional parameter \fBdevice\fP (device ID). When omitted,
  495. resumes all devices. Returns status 200 and no content upon success, or status
  496. 500 and a plain text error on failure.
  497. .SS POST /rest/system/shutdown
  498. .sp
  499. Post with empty body to cause Syncthing to exit and not restart.
  500. .SS GET /rest/system/status
  501. .sp
  502. Returns information about current system status and resource usage.
  503. .INDENT 0.0
  504. .INDENT 3.5
  505. .sp
  506. .nf
  507. .ft C
  508. {
  509. "alloc": 30618136,
  510. "connectionServiceStatus": {
  511. "dynamic+https://relays.syncthing.net/endpoint": {
  512. "lanAddresses": [
  513. "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"
  514. ],
  515. "wanAddresses": [
  516. "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"
  517. ]
  518. },
  519. "tcp://0.0.0.0:22000": {
  520. "lanAddresses": [
  521. "tcp://0.0.0.0:22000"
  522. ],
  523. "wanAddresses": [
  524. "tcp://0.0.0.0:22000"
  525. ]
  526. }
  527. },
  528. "cpuPercent": 0.006944836512046966,
  529. "discoveryEnabled": true,
  530. "discoveryErrors": {
  531. "global@https://discovery\-v4\-1.syncthing.net/v2/": "500 Internal Server Error",
  532. "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)",
  533. "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)",
  534. "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",
  535. "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",
  536. "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"
  537. },
  538. "discoveryMethods": 8,
  539. "goroutines": 49,
  540. "myID": "P56IOI7\-MZJNU2Y\-IQGDREY\-DM2MGTI\-MGL3BXN\-PQ6W5BM\-TBBZ4TJ\-XZWICQ2",
  541. "pathSeparator": "/",
  542. "startTime": "2016\-06\-06T19:41:43.039284753+02:00",
  543. "sys": 42092792,
  544. "themes": [
  545. "default",
  546. "dark"
  547. ],
  548. "tilde": "/Users/jb",
  549. "uptime": 2635
  550. }
  551. .ft P
  552. .fi
  553. .UNINDENT
  554. .UNINDENT
  555. .SS GET /rest/system/upgrade
  556. .sp
  557. Checks for a possible upgrade and returns an object describing the
  558. newest version and upgrade possibility.
  559. .INDENT 0.0
  560. .INDENT 3.5
  561. .sp
  562. .nf
  563. .ft C
  564. {
  565. "latest": "v0.14.47",
  566. "majorNewer": false,
  567. "newer": true,
  568. "running": "v0.14.46"
  569. }
  570. .ft P
  571. .fi
  572. .UNINDENT
  573. .UNINDENT
  574. .SS POST /rest/system/upgrade
  575. .sp
  576. Perform an upgrade to the newest released version and restart. Does
  577. nothing if there is no newer version than currently running.
  578. .SS GET /rest/system/version
  579. .sp
  580. Returns the current Syncthing version information.
  581. .INDENT 0.0
  582. .INDENT 3.5
  583. .sp
  584. .nf
  585. .ft C
  586. {
  587. "arch": "amd64",
  588. "longVersion": "syncthing v0.10.27+3\-gea8c3de (go1.4 darwin\-amd64 default) jb@syno 2015\-03\-16 11:01:29 UTC",
  589. "os": "darwin",
  590. "version": "v0.10.27+3\-gea8c3de"
  591. }
  592. .ft P
  593. .fi
  594. .UNINDENT
  595. .UNINDENT
  596. .SH DATABASE ENDPOINTS
  597. .SS GET /rest/db/browse
  598. .sp
  599. Returns the directory tree of the global model. Directories are always
  600. JSON objects (map/dictionary), and files are always arrays of
  601. modification time and size. The first integer is the files modification
  602. time, and the second integer is the file size.
  603. .sp
  604. The call takes one mandatory \fBfolder\fP parameter and two optional
  605. parameters. Optional parameter \fBlevels\fP defines how deep within the
  606. tree we want to dwell down (0 based, defaults to unlimited depth)
  607. Optional parameter \fBprefix\fP defines a prefix within the tree where to
  608. start building the structure.
  609. .INDENT 0.0
  610. .INDENT 3.5
  611. .sp
  612. .nf
  613. .ft C
  614. $ curl \-s http://localhost:8384/rest/db/browse?folder=default | json_pp
  615. {
  616. "directory": {
  617. "file": ["2015\-04\-20T22:20:45+09:00", 130940928],
  618. "subdirectory": {
  619. "another file": ["2015\-04\-20T22:20:45+09:00", 130940928]
  620. }
  621. },
  622. "rootfile": ["2015\-04\-20T22:20:45+09:00", 130940928]
  623. }
  624. $ curl \-s http://localhost:8384/rest/db/browse?folder=default&levels=0 | json_pp
  625. {
  626. "directory": {},
  627. "rootfile": ["2015\-04\-20T22:20:45+09:00", 130940928]
  628. }
  629. $ curl \-s http://localhost:8384/rest/db/browse?folder=default&levels=1 | json_pp
  630. {
  631. "directory": {
  632. "file": ["2015\-04\-20T22:20:45+09:00", 130940928],
  633. "subdirectory": {}
  634. },
  635. "rootfile": ["2015\-04\-20T22:20:45+09:00", 130940928]
  636. }
  637. $ curl \-s http://localhost:8384/rest/db/browse?folder=default&prefix=directory/subdirectory | json_pp
  638. {
  639. "another file": ["2015\-04\-20T22:20:45+09:00", 130940928]
  640. }
  641. $ curl \-s http://localhost:8384/rest/db/browse?folder=default&prefix=directory&levels=0 | json_pp
  642. {
  643. "file": ["2015\-04\-20T22:20:45+09:00", 130940928],
  644. "subdirectory": {}
  645. }
  646. .ft P
  647. .fi
  648. .UNINDENT
  649. .UNINDENT
  650. .sp
  651. \fBNOTE:\fP
  652. .INDENT 0.0
  653. .INDENT 3.5
  654. This is an expensive call, increasing CPU and RAM usage on the device. Use sparingly.
  655. .UNINDENT
  656. .UNINDENT
  657. .SS GET /rest/db/completion
  658. .sp
  659. Returns the completion percentage (0 to 100) for a given device and
  660. folder. Takes \fBdevice\fP and \fBfolder\fP parameters.
  661. .INDENT 0.0
  662. .INDENT 3.5
  663. .sp
  664. .nf
  665. .ft C
  666. {
  667. "completion": 100,
  668. "globalBytes": 156793013575,
  669. "needBytes": 0,
  670. "needDeletes": 0
  671. }
  672. .ft P
  673. .fi
  674. .UNINDENT
  675. .UNINDENT
  676. .sp
  677. \fBNOTE:\fP
  678. .INDENT 0.0
  679. .INDENT 3.5
  680. This is an expensive call, increasing CPU and RAM usage on the device. Use sparingly.
  681. .UNINDENT
  682. .UNINDENT
  683. .SS GET /rest/db/file
  684. .sp
  685. Returns most data available about a given file, including version and
  686. availability. Takes \fBfolder\fP and \fBfile\fP parameters.
  687. .INDENT 0.0
  688. .INDENT 3.5
  689. .sp
  690. .nf
  691. .ft C
  692. {
  693. "availability": [
  694. {
  695. "id": "ITZRNXE\-YNROGBZ\-HXTH5P7\-VK5NYE5\-QHRQGE2\-7JQ6VNJ\-KZUEDIU\-5PPR5AM",
  696. "fromTemporary": false
  697. }
  698. ],
  699. "global": {
  700. "deleted": false,
  701. "ignored": false,
  702. "invalid": false,
  703. "localFlags": 0,
  704. "modified": "2018\-08\-18T12:21:13.836784059+02:00",
  705. "modifiedBy": "SYNO4VL",
  706. "mustRescan": false,
  707. "name": "testfile",
  708. "noPermissions": false,
  709. "numBlocks": 1,
  710. "permissions": "0755",
  711. "sequence": 107499,
  712. "size": 1234,
  713. "type": 0,
  714. "version": [
  715. "SYNO4VL:1"
  716. ]
  717. },
  718. "local": {
  719. "deleted": false,
  720. "ignored": false,
  721. "invalid": false,
  722. "localFlags": 0,
  723. "modified": "2018\-08\-18T12:21:13.836784059+02:00",
  724. "modifiedBy": "SYNO4VL",
  725. "mustRescan": false,
  726. "name": "testfile",
  727. "noPermissions": false,
  728. "numBlocks": 1,
  729. "permissions": "0755",
  730. "sequence": 111038,
  731. "size": 1234,
  732. "type": 0,
  733. "version": [
  734. "SYNO4VL:1"
  735. ]
  736. }
  737. }
  738. .ft P
  739. .fi
  740. .UNINDENT
  741. .UNINDENT
  742. .SS GET /rest/db/ignores
  743. .sp
  744. Takes one parameter, \fBfolder\fP, and returns the content of the
  745. \fB\&.stignore\fP as the \fBignore\fP field. A second field, \fBexpanded\fP,
  746. 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.
  747. .INDENT 0.0
  748. .INDENT 3.5
  749. .sp
  750. .nf
  751. .ft C
  752. {
  753. "ignore": [
  754. "(?i)/Backups"
  755. ],
  756. "expanded": [
  757. "(?i)Backups",
  758. "(?i)Backups/**"
  759. ]
  760. }
  761. .ft P
  762. .fi
  763. .UNINDENT
  764. .UNINDENT
  765. .SS POST /rest/db/ignores
  766. .sp
  767. Expects a format similar to the output of \fBGET\fP call, but only
  768. containing the \fBignore\fP field (\fBexpanded\fP field should be omitted).
  769. It takes one parameter, \fBfolder\fP, and either updates the content of
  770. the \fB\&.stignore\fP echoing it back as a response, or returns an error.
  771. .SS GET /rest/db/need
  772. .sp
  773. Takes one mandatory parameter, \fBfolder\fP, and returns lists of files which are
  774. needed by this device in order for it to become in sync.
  775. .sp
  776. Furthermore takes an optional \fBpage\fP and \fBperpage\fP arguments for pagination.
  777. Pagination happens, across the union of all needed files, that is \- across all
  778. 3 sections of the response.
  779. For example, given the current need state is as follows:
  780. .INDENT 0.0
  781. .IP 1. 3
  782. \fBprogress\fP has 15 items
  783. .IP 2. 3
  784. \fBqueued\fP has 3 items
  785. .IP 3. 3
  786. \fBrest\fP has 12 items
  787. .UNINDENT
  788. .sp
  789. If you issue a query with \fBpage=1\fP and \fBperpage=10\fP, only the \fBprogress\fP
  790. section in the response will have 10 items. If you issue a request query with
  791. \fBpage=2\fP and \fBperpage=10\fP, \fBprogress\fP section will have the last 5 items,
  792. \fBqueued\fP section will have all 3 items, and \fBrest\fP section will have first
  793. 2 items. If you issue a query for \fBpage=3\fP and \fBperpage=10\fP, you will only
  794. have the last 10 items of the \fBrest\fP section.
  795. .sp
  796. In all these calls, \fBtotal\fP will be 30 to indicate the total number of
  797. available items.
  798. .INDENT 0.0
  799. .INDENT 3.5
  800. .sp
  801. .nf
  802. .ft C
  803. {
  804. # Files currently being downloaded
  805. "progress": [
  806. {
  807. "flags": "0755",
  808. "sequence": 6,
  809. "modified": "2015\-04\-20T23:06:12+09:00",
  810. "name": "ls",
  811. "size": 34640,
  812. "version": [
  813. "5157751870738175669:1"
  814. ]
  815. }
  816. ],
  817. # Files queued to be downloaded next (as per array order)
  818. "queued": [
  819. ...
  820. ],
  821. # Files to be downloaded after all queued files will be downloaded.
  822. # This happens when we start downloading files, and new files get added while we are downloading.
  823. "rest": [
  824. ...
  825. ],
  826. "page": 1,
  827. "perpage": 100,
  828. "total": 2000
  829. }
  830. .ft P
  831. .fi
  832. .UNINDENT
  833. .UNINDENT
  834. .sp
  835. \fBNOTE:\fP
  836. .INDENT 0.0
  837. .INDENT 3.5
  838. This is an expensive call, increasing CPU and RAM usage on the device. Use sparingly.
  839. .UNINDENT
  840. .UNINDENT
  841. .SS POST /rest/db/override
  842. .sp
  843. Request override of a send only folder. Override means to make the local
  844. version latest, overriding changes made on other devices. This API call does
  845. nothing if the folder is not a send only folder.
  846. .sp
  847. Takes the mandatory parameter \fIfolder\fP (folder ID).
  848. .INDENT 0.0
  849. .INDENT 3.5
  850. .sp
  851. .nf
  852. .ft C
  853. curl \-X POST \-H X\-API\-key:... http://127.0.0.1:8384/rest/db/override?folder=default
  854. .ft P
  855. .fi
  856. .UNINDENT
  857. .UNINDENT
  858. .SS POST /rest/db/prio
  859. .sp
  860. Moves the file to the top of the download queue.
  861. .INDENT 0.0
  862. .INDENT 3.5
  863. .sp
  864. .nf
  865. .ft C
  866. curl \-X POST http://127.0.0.1:8384/rest/db/prio?folder=default&file=foo/bar
  867. .ft P
  868. .fi
  869. .UNINDENT
  870. .UNINDENT
  871. .sp
  872. Response contains the same output as \fBGET /rest/db/need\fP
  873. .SS POST /rest/db/revert
  874. .sp
  875. New in version 0.14.50.
  876. .sp
  877. Request revert of a receive only folder. Reverting a folder means to undo
  878. all local changes. This API call does nothing if the folder is not a receive
  879. only folder.
  880. .sp
  881. Takes the mandatory parameter \fIfolder\fP (folder ID).
  882. .INDENT 0.0
  883. .INDENT 3.5
  884. .sp
  885. .nf
  886. .ft C
  887. curl \-X POST \-H X\-API\-Key:... http://127.0.0.1:8384/rest/db/revert?folder=default
  888. .ft P
  889. .fi
  890. .UNINDENT
  891. .UNINDENT
  892. .SS POST /rest/db/scan
  893. .sp
  894. Request immediate scan. Takes the optional parameters \fBfolder\fP (folder ID),
  895. \fBsub\fP (path relative to the folder root) and \fBnext\fP (time in seconds). If
  896. \fBfolder\fP is omitted or empty all folders are scanned. If \fBsub\fP is given,
  897. only this path (and children, in case it’s a directory) is scanned. The \fBnext\fP
  898. argument delays Syncthing’s automated rescan interval for a given amount of
  899. seconds.
  900. .sp
  901. Requesting scan of a path that no longer exists, but previously did, is
  902. valid and will result in Syncthing noticing the deletion of the path in
  903. question.
  904. .sp
  905. Returns status 200 and no content upon success, or status 500 and a
  906. plain text error if an error occurred during scanning.
  907. .INDENT 0.0
  908. .INDENT 3.5
  909. .sp
  910. .nf
  911. .ft C
  912. curl \-X POST http://127.0.0.1:8384/rest/db/scan?folder=default&sub=foo/bar
  913. .ft P
  914. .fi
  915. .UNINDENT
  916. .UNINDENT
  917. .SS GET /rest/db/status
  918. .sp
  919. Returns information about the current status of a folder.
  920. .sp
  921. Parameters: \fBfolder\fP, the ID of a folder.
  922. .INDENT 0.0
  923. .INDENT 3.5
  924. .sp
  925. .nf
  926. .ft C
  927. {
  928. "globalBytes": 0,
  929. "globalDeleted": 0,
  930. "globalDirectories": 0,
  931. "globalFiles": 0,
  932. "globalSymlinks": 0,
  933. "ignorePatterns": false,
  934. "inSyncBytes": 0,
  935. "inSyncFiles": 0,
  936. "invalid": "",
  937. "localBytes": 0,
  938. "localDeleted": 0,
  939. "localDirectories": 0,
  940. "localFiles": 0,
  941. "localSymlinks": 0,
  942. "needBytes": 0,
  943. "needDeletes": 0,
  944. "needDirectories": 0,
  945. "needFiles": 0,
  946. "needSymlinks": 0,
  947. "pullErrors": 0,
  948. "receiveOnlyChangedBytes": 0,
  949. "receiveOnlyChangedDeletes": 0,
  950. "receiveOnlyChangedDirectories": 0,
  951. "receiveOnlyChangedFiles": 0,
  952. "receiveOnlyChangedSymlinks": 0,
  953. "sequence": 0,
  954. "state": "idle",
  955. "stateChanged": "2018\-08\-08T07:04:57.301064781+02:00",
  956. "version": 0
  957. }
  958. .ft P
  959. .fi
  960. .UNINDENT
  961. .UNINDENT
  962. .sp
  963. The various fields have the following meaning:
  964. .INDENT 0.0
  965. .TP
  966. .B global*:
  967. Data in the cluster latest version.
  968. .TP
  969. .B inSync*:
  970. Data that is locally the same as the cluster latest version.
  971. .TP
  972. .B local*:
  973. Data that is locally present, regardless of whether it’s the same or different version as the cluster latest version.
  974. .TP
  975. .B need*:
  976. Data that is needed to become up to date with the cluster latest version (i.e., data that is out of sync).
  977. .TP
  978. .B receiveOnlyChanged*:
  979. Data that has changed locally in a receive only folder, and thus not been sent to the cluster.
  980. .TP
  981. .B invalid:
  982. Deprecated, always empty.
  983. .TP
  984. .B pullErrors:
  985. The number of files that failed to sync during the last sync operations.
  986. .TP
  987. .B sequence:
  988. The current folder sequence number.
  989. .TP
  990. .B state:
  991. The current folder state.
  992. .TP
  993. .B stateChanged:
  994. When the folder state last changed.
  995. .TP
  996. .B version:
  997. Deprecated, equivalent to the sequence number.
  998. .UNINDENT
  999. .sp
  1000. \fBNOTE:\fP
  1001. .INDENT 0.0
  1002. .INDENT 3.5
  1003. This is an expensive call, increasing CPU and RAM usage on the device. Use sparingly.
  1004. .UNINDENT
  1005. .UNINDENT
  1006. .SH EVENT ENDPOINTS
  1007. .SS GET /rest/events
  1008. .sp
  1009. To receive events, perform a HTTP GET of \fB/rest/events\fP\&.
  1010. .sp
  1011. To filter the event list, in effect creating a specific subscription for
  1012. only the desired event types, add a parameter
  1013. \fBevents=EventTypeA,EventTypeB,...\fP where the event types are any of the event\-types\&.
  1014. .sp
  1015. The optional parameter \fBsince=<lastSeenID>\fP sets the ID of the last event
  1016. you’ve already seen. Syncthing returns a JSON encoded array of event objects,
  1017. starting at the event just after the one with this last seen ID. The default
  1018. value is 0, which returns all events. There is a limit to the number of events
  1019. buffered, so if the rate of events is high or the time between polling calls is
  1020. long some events might be missed. This can be detected by noting a discontinuity
  1021. in the event IDs.
  1022. .sp
  1023. If no new events are produced since \fB<lastSeenID>\fP, the HTTP call blocks and
  1024. waits for new events to happen before returning. By default it times out after
  1025. 60 seconds returning an empty array. The time out duration can be customized
  1026. with the optional parameter \fBtimeout=seconds\fP\&.
  1027. .sp
  1028. To receive only a limited number of events, add the \fBlimit=n\fP parameter with a
  1029. suitable value for \fBn\fP and only the \fIlast\fP \fBn\fP events will be returned. This
  1030. can be used to catch up with the latest event ID after a disconnection for
  1031. example: \fB/rest/events?since=0&limit=1\fP\&.
  1032. .SH STATISTICS ENDPOINTS
  1033. .SS GET /rest/stats/device
  1034. .sp
  1035. Returns general statistics about devices. Currently, only contains the
  1036. time the device was last seen.
  1037. .INDENT 0.0
  1038. .INDENT 3.5
  1039. .sp
  1040. .nf
  1041. .ft C
  1042. $ curl \-s http://localhost:8384/rest/stats/device | json
  1043. {
  1044. "P56IOI7\-MZJNU2Y\-IQGDREY\-DM2MGTI\-MGL3BXN\-PQ6W5BM\-TBBZ4TJ\-XZWICQ2": {
  1045. "lastSeen" : "2015\-04\-18T11:21:31.3256277+01:00"
  1046. }
  1047. }
  1048. .ft P
  1049. .fi
  1050. .UNINDENT
  1051. .UNINDENT
  1052. .SS GET /rest/stats/folder
  1053. .sp
  1054. Returns general statistics about folders. Currently contains the
  1055. last scan time and the last synced file.
  1056. .INDENT 0.0
  1057. .INDENT 3.5
  1058. .sp
  1059. .nf
  1060. .ft C
  1061. $ curl \-s http://localhost:8384/rest/stats/folder | json
  1062. {
  1063. "folderid" : {
  1064. "lastScan": "2016\-06\-02T13:28:01.288181412\-04:00",
  1065. "lastFile" : {
  1066. "filename" : "file/name",
  1067. "at" : "2015\-04\-16T22:04:18.3066971+01:00"
  1068. }
  1069. }
  1070. }
  1071. .ft P
  1072. .fi
  1073. .UNINDENT
  1074. .UNINDENT
  1075. .SH MISC SERVICES ENDPOINTS
  1076. .SS GET /rest/svc/deviceid
  1077. .sp
  1078. Verifies and formats a device ID. Accepts all currently valid formats
  1079. (52 or 56 characters with or without separators, upper or lower case,
  1080. with trivial substitutions). Takes one parameter, \fBid\fP, and returns
  1081. either a valid device ID in modern format, or an error.
  1082. .INDENT 0.0
  1083. .INDENT 3.5
  1084. .sp
  1085. .nf
  1086. .ft C
  1087. $ curl \-s http://localhost:8384/rest/svc/deviceid?id=1234 | json
  1088. {
  1089. "error": "device ID invalid: incorrect length"
  1090. }
  1091. $ curl \-s http://localhost:8384/rest/svc/deviceid?id=p56ioi7m\-\-zjnu2iq\-gdr\-eydm\-2mgtmgl3bxnpq6w5btbbz4tjxzwicq | json
  1092. {
  1093. "id": "P56IOI7\-MZJNU2Y\-IQGDREY\-DM2MGTI\-MGL3BXN\-PQ6W5BM\-TBBZ4TJ\-XZWICQ2"
  1094. }
  1095. .ft P
  1096. .fi
  1097. .UNINDENT
  1098. .UNINDENT
  1099. .SS GET /rest/svc/lang
  1100. .sp
  1101. Returns a list of canonicalized localization codes, as picked up from
  1102. the \fBAccept\-Language\fP header sent by the browser.
  1103. .INDENT 0.0
  1104. .INDENT 3.5
  1105. .sp
  1106. .nf
  1107. .ft C
  1108. ["sv_sv","sv","en_us","en"]
  1109. .ft P
  1110. .fi
  1111. .UNINDENT
  1112. .UNINDENT
  1113. .SS GET /rest/svc/random/string
  1114. .sp
  1115. Returns a strong random generated string (alphanumeric) of the specified length. Takes the \fBlength\fP parameter.
  1116. .INDENT 0.0
  1117. .INDENT 3.5
  1118. .sp
  1119. .nf
  1120. .ft C
  1121. {
  1122. "random": "FdPaEaZQ56sXEKYNxpgF"
  1123. }
  1124. .ft P
  1125. .fi
  1126. .UNINDENT
  1127. .UNINDENT
  1128. .SS GET /rest/svc/report
  1129. .sp
  1130. Returns the data sent in the anonymous usage report.
  1131. .INDENT 0.0
  1132. .INDENT 3.5
  1133. .sp
  1134. .nf
  1135. .ft C
  1136. {
  1137. "folderMaxMiB" : 0,
  1138. "platform" : "linux\-amd64",
  1139. "totMiB" : 0,
  1140. "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",
  1141. "upgradeAllowedManual" : true,
  1142. "totFiles" : 3,
  1143. "folderUses" : {
  1144. "ignorePerms" : 0,
  1145. "autoNormalize" : 0,
  1146. "sendonly" : 0,
  1147. "ignoreDelete" : 0
  1148. },
  1149. "memoryUsageMiB" : 13,
  1150. "version" : "v0.12.2",
  1151. "sha256Perf" : 27.28,
  1152. "numFolders" : 2,
  1153. "memorySize" : 1992,
  1154. "announce" : {
  1155. "defaultServersIP" : 0,
  1156. "otherServers" : 0,
  1157. "globalEnabled" : false,
  1158. "defaultServersDNS" : 1,
  1159. "localEnabled" : false
  1160. },
  1161. "usesRateLimit" : false,
  1162. "numCPU" : 2,
  1163. "uniqueID" : "",
  1164. "urVersion" : 2,
  1165. "rescanIntvs" : [
  1166. 60,
  1167. 60
  1168. ],
  1169. "numDevices" : 2,
  1170. "folderMaxFiles" : 3,
  1171. "relays" : {
  1172. "defaultServers" : 1,
  1173. "enabled" : true,
  1174. "otherServers" : 0
  1175. },
  1176. "deviceUses" : {
  1177. "compressMetadata" : 1,
  1178. "customCertName" : 0,
  1179. "staticAddr" : 1,
  1180. "compressAlways" : 0,
  1181. "compressNever" : 1,
  1182. "introducer" : 0,
  1183. "dynamicAddr" : 1
  1184. },
  1185. "upgradeAllowedAuto" : false
  1186. }
  1187. .ft P
  1188. .fi
  1189. .UNINDENT
  1190. .UNINDENT
  1191. .SH AUTHOR
  1192. The Syncthing Authors
  1193. .SH COPYRIGHT
  1194. 2014-2019, The Syncthing Authors
  1195. .\" Generated by docutils manpage writer.
  1196. .