syncthing-rest-api.7 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115
  1. .\" Man page generated from reStructuredText.
  2. .
  3. .TH "SYNCTHING-REST-API" "7" "Mar 04, 2018" "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. .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 AP 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": "readwrite",
  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. }
  198. }
  199. .ft P
  200. .fi
  201. .UNINDENT
  202. .UNINDENT
  203. .SS GET /rest/system/config/insync
  204. .sp
  205. Returns whether the config is in sync, i.e. whether the running
  206. configuration is the same as that on disk.
  207. .INDENT 0.0
  208. .INDENT 3.5
  209. .sp
  210. .nf
  211. .ft C
  212. {
  213. "configInSync": true
  214. }
  215. .ft P
  216. .fi
  217. .UNINDENT
  218. .UNINDENT
  219. .SS POST /rest/system/config
  220. .sp
  221. Post the full contents of the configuration, in the same format as returned by
  222. the corresponding GET request. The configuration will be saved to disk and the
  223. \fBconfigInSync\fP flag set to false. Restart Syncthing to activate.
  224. .SS GET /rest/system/connections
  225. .sp
  226. \fBNOTE:\fP
  227. .INDENT 0.0
  228. .INDENT 3.5
  229. Return format changed in 0.13.0.
  230. .UNINDENT
  231. .UNINDENT
  232. .sp
  233. Returns the list of configured devices and some metadata associated
  234. with them. The list also contains the local device itself as not connected.
  235. .sp
  236. The connection types are \fBTCP (Client)\fP, \fBTCP (Server)\fP, \fBRelay (Client)\fP and \fBRelay (Server)\fP\&.
  237. .INDENT 0.0
  238. .INDENT 3.5
  239. .sp
  240. .nf
  241. .ft C
  242. {
  243. "total" : {
  244. "paused" : false,
  245. "clientVersion" : "",
  246. "at" : "2015\-11\-07T17:29:47.691637262+01:00",
  247. "connected" : false,
  248. "inBytesTotal" : 1479,
  249. "type" : "",
  250. "outBytesTotal" : 1318,
  251. "address" : ""
  252. },
  253. "connections" : {
  254. "YZJBJFX\-RDBL7WY\-6ZGKJ2D\-4MJB4E7\-ZATSDUY\-LD6Y3L3\-MLFUYWE\-AEMXJAC" : {
  255. "connected" : true,
  256. "inBytesTotal" : 556,
  257. "paused" : false,
  258. "at" : "2015\-11\-07T17:29:47.691548971+01:00",
  259. "clientVersion" : "v0.12.1",
  260. "address" : "127.0.0.1:22002",
  261. "type" : "TCP (Client)",
  262. "outBytesTotal" : 550
  263. },
  264. "DOVII4U\-SQEEESM\-VZ2CVTC\-CJM4YN5\-QNV7DCU\-5U3ASRL\-YVFG6TH\-W5DV5AA" : {
  265. "outBytesTotal" : 0,
  266. "type" : "",
  267. "address" : "",
  268. "at" : "0001\-01\-01T00:00:00Z",
  269. "clientVersion" : "",
  270. "paused" : false,
  271. "inBytesTotal" : 0,
  272. "connected" : false
  273. },
  274. "UYGDMA4\-TPHOFO5\-2VQYDCC\-7CWX7XW\-INZINQT\-LE4B42N\-4JUZTSM\-IWCSXA4" : {
  275. "address" : "",
  276. "type" : "",
  277. "outBytesTotal" : 0,
  278. "connected" : false,
  279. "inBytesTotal" : 0,
  280. "paused" : false,
  281. "at" : "0001\-01\-01T00:00:00Z",
  282. "clientVersion" : ""
  283. }
  284. }
  285. }
  286. .ft P
  287. .fi
  288. .UNINDENT
  289. .UNINDENT
  290. .SS GET /rest/system/debug
  291. .sp
  292. New in version 0.12.0.
  293. .sp
  294. Returns the set of debug facilities and which of them are currently enabled.
  295. .INDENT 0.0
  296. .INDENT 3.5
  297. .sp
  298. .nf
  299. .ft C
  300. {
  301. "enabled": [
  302. "beacon"
  303. ],
  304. "facilities": {
  305. "beacon": "Multicast and broadcast discovery",
  306. "config": "Configuration loading and saving",
  307. "connections": "Connection handling",
  308. "db": "The database layer",
  309. "dialer": "Dialing connections",
  310. "discover": "Remote device discovery",
  311. "events": "Event generation and logging",
  312. "http": "REST API",
  313. "main": "Main package",
  314. "model": "The root hub",
  315. "protocol": "The BEP protocol",
  316. "relay": "Relay connection handling",
  317. "scanner": "File change detection and hashing",
  318. "stats": "Persistent device and folder statistics",
  319. "sync": "Mutexes",
  320. "upgrade": "Binary upgrades",
  321. "upnp": "UPnP discovery and port mapping",
  322. "versioner": "File versioning"
  323. }
  324. }
  325. .ft P
  326. .fi
  327. .UNINDENT
  328. .UNINDENT
  329. .SS POST /rest/system/debug
  330. .sp
  331. New in version 0.12.0.
  332. .sp
  333. Enables or disables debugging for specified facilities. Give one or both of
  334. \fBenable\fP and \fBdisable\fP query parameters, with comma separated facility
  335. names. To disable debugging of the beacon and discovery packages, and enable it
  336. for config and db:
  337. .INDENT 0.0
  338. .INDENT 3.5
  339. .sp
  340. .nf
  341. .ft C
  342. $ curl \-H X\-API\-Key:abc123 \-X POST \(aqhttp://localhost:8384/rest/system/debug?disable=beacon,discovery&enable=config,db\(aq
  343. .ft P
  344. .fi
  345. .UNINDENT
  346. .UNINDENT
  347. .SS GET /rest/system/discovery
  348. .sp
  349. Returns the contents of the local discovery cache.
  350. .INDENT 0.0
  351. .INDENT 3.5
  352. .sp
  353. .nf
  354. .ft C
  355. {
  356. "LGFPDIT7SKNNJVJZA4FC7QNCRKCE753K72BW5QD2FOZ7FRFEP57Q": [
  357. "192.162.129.11:22000"
  358. ]
  359. }
  360. .ft P
  361. .fi
  362. .UNINDENT
  363. .UNINDENT
  364. .SS POST /rest/system/discovery
  365. .sp
  366. \fBNOTE:\fP
  367. .INDENT 0.0
  368. .INDENT 3.5
  369. Removed in v0.12.0.
  370. .UNINDENT
  371. .UNINDENT
  372. .sp
  373. Post with the query parameters \fBdevice\fP and \fBaddr\fP to add entries to
  374. the discovery cache.
  375. .INDENT 0.0
  376. .INDENT 3.5
  377. .sp
  378. .nf
  379. .ft C
  380. curl \-X POST http://127.0.0.1:8384/rest/system/discovery?device=LGFPDIT7SKNNJVJZA4FC7QNCRKCE753K72BW5QD2FOZ7FRFEP57Q\e&addr=192.162.129.11:22000
  381. # Or with the X\-API\-Key header:
  382. 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
  383. .ft P
  384. .fi
  385. .UNINDENT
  386. .UNINDENT
  387. .SS POST /rest/system/error/clear
  388. .sp
  389. Post with empty to body to remove all recent errors.
  390. .SS GET /rest/system/error
  391. .sp
  392. \fBNOTE:\fP
  393. .INDENT 0.0
  394. .INDENT 3.5
  395. Return format changed in 0.12.0.
  396. .UNINDENT
  397. .UNINDENT
  398. .sp
  399. Returns the list of recent errors.
  400. .INDENT 0.0
  401. .INDENT 3.5
  402. .sp
  403. .nf
  404. .ft C
  405. {
  406. "errors": [
  407. {
  408. "when": "2014\-09\-18T12:59:26.549953186+02:00",
  409. "message": "This is an error string"
  410. }
  411. ]
  412. }
  413. .ft P
  414. .fi
  415. .UNINDENT
  416. .UNINDENT
  417. .SS POST /rest/system/error
  418. .sp
  419. Post with an error message in the body (plain text) to register a new
  420. error. The new error will be displayed on any active GUI clients.
  421. .SS GET /rest/system/log
  422. .sp
  423. New in version 0.12.0.
  424. .sp
  425. Returns the list of recent log entries.
  426. .INDENT 0.0
  427. .INDENT 3.5
  428. .sp
  429. .nf
  430. .ft C
  431. {
  432. "messages": [
  433. {
  434. "when": "2014\-09\-18T12:59:26.549953186+02:00",
  435. "message": "This is a log entry"
  436. }
  437. ]
  438. }
  439. .ft P
  440. .fi
  441. .UNINDENT
  442. .UNINDENT
  443. .SS POST /rest/system/pause
  444. .sp
  445. Pause the given device or all devices.
  446. .sp
  447. Takes the optional parameter \fBdevice\fP (device ID). When omitted,
  448. pauses all devices. Returns status 200 and no content upon success, or status
  449. 500 and a plain text error on failure.
  450. .SS GET /rest/system/ping
  451. .sp
  452. Returns a \fB{"ping": "pong"}\fP object.
  453. .INDENT 0.0
  454. .INDENT 3.5
  455. .sp
  456. .nf
  457. .ft C
  458. {
  459. "ping": "pong"
  460. }
  461. .ft P
  462. .fi
  463. .UNINDENT
  464. .UNINDENT
  465. .SS POST /rest/system/ping
  466. .sp
  467. Returns a \fB{"ping": "pong"}\fP object.
  468. .SS POST /rest/system/reset
  469. .sp
  470. Post with empty body to erase the current index database and restart
  471. Syncthing. With no query parameters, the entire database is erased from disk.
  472. By specifying the \fBfolder\fP parameter with a valid folder ID, only
  473. information for that folder will be erased:
  474. .INDENT 0.0
  475. .INDENT 3.5
  476. .sp
  477. .nf
  478. .ft C
  479. $ curl \-X POST \-H "X\-API\-Key: abc123" http://localhost:8384/rest/system/reset?folder=default
  480. .ft P
  481. .fi
  482. .UNINDENT
  483. .UNINDENT
  484. .SS POST /rest/system/restart
  485. .sp
  486. Post with empty body to immediately restart Syncthing.
  487. .SS POST /rest/system/resume
  488. .sp
  489. Resume the given device or all devices.
  490. .sp
  491. Takes the optional parameter \fBdevice\fP (device ID). When omitted,
  492. resumes all devices. Returns status 200 and no content upon success, or status
  493. 500 and a plain text error on failure.
  494. .SS POST /rest/system/shutdown
  495. .sp
  496. Post with empty body to cause Syncthing to exit and not restart.
  497. .SS GET /rest/system/status
  498. .sp
  499. Returns information about current system status and resource usage.
  500. .INDENT 0.0
  501. .INDENT 3.5
  502. .sp
  503. .nf
  504. .ft C
  505. {
  506. "alloc": 30618136,
  507. "connectionServiceStatus": {
  508. "dynamic+https://relays.syncthing.net/endpoint": {
  509. "lanAddresses": [
  510. "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"
  511. ],
  512. "wanAddresses": [
  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. },
  516. "tcp://0.0.0.0:22000": {
  517. "lanAddresses": [
  518. "tcp://0.0.0.0:22000"
  519. ],
  520. "wanAddresses": [
  521. "tcp://0.0.0.0:22000"
  522. ]
  523. }
  524. },
  525. "cpuPercent": 0.006944836512046966,
  526. "discoveryEnabled": true,
  527. "discoveryErrors": {
  528. "global@https://discovery\-v4\-1.syncthing.net/v2/": "500 Internal Server Error",
  529. "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)",
  530. "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)",
  531. "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",
  532. "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",
  533. "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"
  534. },
  535. "discoveryMethods": 8,
  536. "goroutines": 49,
  537. "myID": "P56IOI7\-MZJNU2Y\-IQGDREY\-DM2MGTI\-MGL3BXN\-PQ6W5BM\-TBBZ4TJ\-XZWICQ2",
  538. "pathSeparator": "/",
  539. "startTime": "2016\-06\-06T19:41:43.039284753+02:00",
  540. "sys": 42092792,
  541. "themes": [
  542. "default",
  543. "dark"
  544. ],
  545. "tilde": "/Users/jb",
  546. "uptime": 2635
  547. }
  548. .ft P
  549. .fi
  550. .UNINDENT
  551. .UNINDENT
  552. .SS GET /rest/system/upgrade
  553. .sp
  554. Checks for a possible upgrade and returns an object describing the
  555. newest version and upgrade possibility.
  556. .INDENT 0.0
  557. .INDENT 3.5
  558. .sp
  559. .nf
  560. .ft C
  561. {
  562. "latest": "v0.10.27",
  563. "newer": false,
  564. "running": "v0.10.27+5\-g36c93b7"
  565. }
  566. .ft P
  567. .fi
  568. .UNINDENT
  569. .UNINDENT
  570. .SS POST /rest/system/upgrade
  571. .sp
  572. Perform an upgrade to the newest released version and restart. Does
  573. nothing if there is no newer version than currently running.
  574. .SS GET /rest/system/version
  575. .sp
  576. Returns the current Syncthing version information.
  577. .INDENT 0.0
  578. .INDENT 3.5
  579. .sp
  580. .nf
  581. .ft C
  582. {
  583. "arch": "amd64",
  584. "longVersion": "syncthing v0.10.27+3\-gea8c3de (go1.4 darwin\-amd64 default) jb@syno 2015\-03\-16 11:01:29 UTC",
  585. "os": "darwin",
  586. "version": "v0.10.27+3\-gea8c3de"
  587. }
  588. .ft P
  589. .fi
  590. .UNINDENT
  591. .UNINDENT
  592. .SH DATABASE ENDPOINTS
  593. .SS GET /rest/db/browse
  594. .sp
  595. Returns the directory tree of the global model. Directories are always
  596. JSON objects (map/dictionary), and files are always arrays of
  597. modification time and size. The first integer is the files modification
  598. time, and the second integer is the file size.
  599. .sp
  600. The call takes one mandatory \fBfolder\fP parameter and two optional
  601. parameters. Optional parameter \fBlevels\fP defines how deep within the
  602. tree we want to dwell down (0 based, defaults to unlimited depth)
  603. Optional parameter \fBprefix\fP defines a prefix within the tree where to
  604. start building the structure.
  605. .INDENT 0.0
  606. .INDENT 3.5
  607. .sp
  608. .nf
  609. .ft C
  610. $ curl \-s http://localhost:8384/rest/db/browse?folder=default | json_pp
  611. {
  612. "directory": {
  613. "file": ["2015\-04\-20T22:20:45+09:00", 130940928],
  614. "subdirectory": {
  615. "another file": ["2015\-04\-20T22:20:45+09:00", 130940928]
  616. }
  617. },
  618. "rootfile": ["2015\-04\-20T22:20:45+09:00", 130940928]
  619. }
  620. $ curl \-s http://localhost:8384/rest/db/browse?folder=default&levels=0 | json_pp
  621. {
  622. "directory": {},
  623. "rootfile": ["2015\-04\-20T22:20:45+09:00", 130940928]
  624. }
  625. $ curl \-s http://localhost:8384/rest/db/browse?folder=default&levels=1 | json_pp
  626. {
  627. "directory": {
  628. "file": ["2015\-04\-20T22:20:45+09:00", 130940928],
  629. "subdirectory": {}
  630. },
  631. "rootfile": ["2015\-04\-20T22:20:45+09:00", 130940928]
  632. }
  633. $ curl \-s http://localhost:8384/rest/db/browse?folder=default&prefix=directory/subdirectory | json_pp
  634. {
  635. "another file": ["2015\-04\-20T22:20:45+09:00", 130940928]
  636. }
  637. $ curl \-s http://localhost:8384/rest/db/browse?folder=default&prefix=directory&levels=0 | json_pp
  638. {
  639. "file": ["2015\-04\-20T22:20:45+09:00", 130940928],
  640. "subdirectory": {}
  641. }
  642. .ft P
  643. .fi
  644. .UNINDENT
  645. .UNINDENT
  646. .sp
  647. \fBNOTE:\fP
  648. .INDENT 0.0
  649. .INDENT 3.5
  650. This is an expensive call, increasing CPU and RAM usage on the device. Use sparingly.
  651. .UNINDENT
  652. .UNINDENT
  653. .SS GET /rest/db/completion
  654. .sp
  655. Returns the completion percentage (0 to 100) for a given device and
  656. folder. Takes \fBdevice\fP and \fBfolder\fP parameters.
  657. .INDENT 0.0
  658. .INDENT 3.5
  659. .sp
  660. .nf
  661. .ft C
  662. {
  663. "completion": 100,
  664. "globalBytes": 156793013575,
  665. "needBytes": 0,
  666. "needDeletes": 0
  667. }
  668. .ft P
  669. .fi
  670. .UNINDENT
  671. .UNINDENT
  672. .sp
  673. \fBNOTE:\fP
  674. .INDENT 0.0
  675. .INDENT 3.5
  676. This is an expensive call, increasing CPU and RAM usage on the device. Use sparingly.
  677. .UNINDENT
  678. .UNINDENT
  679. .SS GET /rest/db/file
  680. .sp
  681. Returns most data available about a given file, including version and
  682. availability. Takes \fBfolder\fP and \fBfile\fP parameters.
  683. .INDENT 0.0
  684. .INDENT 3.5
  685. .sp
  686. .nf
  687. .ft C
  688. {
  689. "availability": [
  690. "I6KAH76\-66SLLLB\-5PFXSOA\-UFJCDZC\-YAOMLEK\-CP2GB32\-BV5RQST\-3PSROAU"
  691. ],
  692. "global": {
  693. "flags": "0644",
  694. "sequence": 3,
  695. "modified": "2015\-04\-20T22:20:45+09:00",
  696. "name": "util.go",
  697. "numBlocks": 1,
  698. "size": 9642,
  699. "version": [
  700. "5407294127585413568:1"
  701. ]
  702. },
  703. "local": {
  704. "flags": "0644",
  705. "sequence": 4,
  706. "modified": "2015\-04\-20T22:20:45+09:00",
  707. "name": "util.go",
  708. "numBlocks": 1,
  709. "size": 9642,
  710. "version": [
  711. "5407294127585413568:1"
  712. ]
  713. }
  714. }
  715. .ft P
  716. .fi
  717. .UNINDENT
  718. .UNINDENT
  719. .SS GET /rest/db/ignores
  720. .sp
  721. Takes one parameter, \fBfolder\fP, and returns the content of the
  722. \fB\&.stignore\fP as the \fBignore\fP field. A second field, \fBexpanded\fP,
  723. 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.
  724. .INDENT 0.0
  725. .INDENT 3.5
  726. .sp
  727. .nf
  728. .ft C
  729. {
  730. "ignore": [
  731. "(?i)/Backups"
  732. ],
  733. "expanded": [
  734. "(?i)Backups",
  735. "(?i)Backups/**"
  736. ]
  737. }
  738. .ft P
  739. .fi
  740. .UNINDENT
  741. .UNINDENT
  742. .SS POST /rest/db/ignores
  743. .sp
  744. Expects a format similar to the output of \fBGET\fP call, but only
  745. containing the \fBignore\fP field (\fBexpanded\fP field should be omitted).
  746. It takes one parameter, \fBfolder\fP, and either updates the content of
  747. the \fB\&.stignore\fP echoing it back as a response, or returns an error.
  748. .SS GET /rest/db/need
  749. .sp
  750. Takes one mandatory parameter, \fBfolder\fP, and returns lists of files which are
  751. needed by this device in order for it to become in sync.
  752. .sp
  753. Furthermore takes an optional \fBpage\fP and \fBperpage\fP arguments for pagination.
  754. Pagination happens, across the union of all needed files, that is \- across all
  755. 3 sections of the response.
  756. For example, given the current need state is as follows:
  757. .INDENT 0.0
  758. .IP 1. 3
  759. \fBprogress\fP has 15 items
  760. .IP 2. 3
  761. \fBqueued\fP has 3 items
  762. .IP 3. 3
  763. \fBrest\fP has 12 items
  764. .UNINDENT
  765. .sp
  766. If you issue a query with \fBpage=1\fP and \fBperpage=10\fP, only the \fBprogress\fP
  767. section in the response will have 10 items. If you issue a request query with
  768. \fBpage=2\fP and \fBperpage=10\fP, \fBprogress\fP section will have the last 5 items,
  769. \fBqueued\fP section will have all 3 items, and \fBrest\fP section will have first
  770. 2 items. If you issue a query for \fBpage=3\fP and \fBperpage=10\fP, you will only
  771. have the last 10 items of the \fBrest\fP section.
  772. .sp
  773. In all these calls, \fBtotal\fP will be 30 to indicate the total number of
  774. available items.
  775. .INDENT 0.0
  776. .INDENT 3.5
  777. .sp
  778. .nf
  779. .ft C
  780. {
  781. # Files currently being downloaded
  782. "progress": [
  783. {
  784. "flags": "0755",
  785. "sequence": 6,
  786. "modified": "2015\-04\-20T23:06:12+09:00",
  787. "name": "ls",
  788. "size": 34640,
  789. "version": [
  790. "5157751870738175669:1"
  791. ]
  792. }
  793. ],
  794. # Files queued to be downloaded next (as per array order)
  795. "queued": [
  796. ...
  797. ],
  798. # Files to be downloaded after all queued files will be downloaded.
  799. # This happens when we start downloading files, and new files get added while we are downloading.
  800. "rest": [
  801. ...
  802. ],
  803. "page": 1,
  804. "perpage": 100,
  805. "total": 2000
  806. }
  807. .ft P
  808. .fi
  809. .UNINDENT
  810. .UNINDENT
  811. .sp
  812. \fBNOTE:\fP
  813. .INDENT 0.0
  814. .INDENT 3.5
  815. This is an expensive call, increasing CPU and RAM usage on the device. Use sparingly.
  816. .UNINDENT
  817. .UNINDENT
  818. .SS POST /rest/db/override
  819. .sp
  820. Request override of a send\-only folder.
  821. Takes the mandatory parameter \fIfolder\fP (folder ID).
  822. .INDENT 0.0
  823. .INDENT 3.5
  824. .sp
  825. .nf
  826. .ft C
  827. curl \-X POST http://127.0.0.1:8384/rest/db/override?folder=default
  828. .ft P
  829. .fi
  830. .UNINDENT
  831. .UNINDENT
  832. .SS POST /rest/db/prio
  833. .sp
  834. Moves the file to the top of the download queue.
  835. .INDENT 0.0
  836. .INDENT 3.5
  837. .sp
  838. .nf
  839. .ft C
  840. curl \-X POST http://127.0.0.1:8384/rest/db/prio?folder=default&file=foo/bar
  841. .ft P
  842. .fi
  843. .UNINDENT
  844. .UNINDENT
  845. .sp
  846. Response contains the same output as \fBGET /rest/db/need\fP
  847. .SS POST /rest/db/scan
  848. .sp
  849. Request immediate scan. Takes the optional parameters \fBfolder\fP (folder ID),
  850. \fBsub\fP (path relative to the folder root) and \fBnext\fP (time in seconds). If
  851. \fBfolder\fP is omitted or empty all folders are scanned. If \fBsub\fP is given,
  852. only this path (and children, in case it’s a directory) is scanned. The \fBnext\fP
  853. argument delays Syncthing’s automated rescan interval for a given amount of
  854. seconds.
  855. .sp
  856. Requesting scan of a path that no longer exists, but previously did, is
  857. valid and will result in Syncthing noticing the deletion of the path in
  858. question.
  859. .sp
  860. Returns status 200 and no content upon success, or status 500 and a
  861. plain text error if an error occurred during scanning.
  862. .INDENT 0.0
  863. .INDENT 3.5
  864. .sp
  865. .nf
  866. .ft C
  867. curl \-X POST http://127.0.0.1:8384/rest/db/scan?folder=default&sub=foo/bar
  868. .ft P
  869. .fi
  870. .UNINDENT
  871. .UNINDENT
  872. .SS GET /rest/db/status
  873. .sp
  874. Returns information about the current status of a folder.
  875. .sp
  876. Parameters: \fBfolder\fP, the ID of a folder.
  877. .INDENT 0.0
  878. .INDENT 3.5
  879. .sp
  880. .nf
  881. .ft C
  882. {
  883. # latest version according to cluster:
  884. "globalBytes": 13173473780,
  885. "globalDeleted": 1847,
  886. "globalFiles": 42106,
  887. # what we have locally:
  888. "localBytes": 13173473780,
  889. "localDeleted": 1847,
  890. "localFiles": 42106,
  891. # which part of what we have locally is the latest cluster version:
  892. "inSyncBytes": 13173473780,
  893. "inSyncFiles": 42106,
  894. # which part of what we have locally should be fetched from the cluster:
  895. "needBytes": 0,
  896. "needFiles": 0,
  897. # various other metadata
  898. "ignorePatterns": true,
  899. "invalid": "",
  900. "state": "idle",
  901. "stateChanged": "2015\-03\-16T21:47:28.750853241+01:00",
  902. "version": 71989
  903. }
  904. .ft P
  905. .fi
  906. .UNINDENT
  907. .UNINDENT
  908. .sp
  909. \fBNOTE:\fP
  910. .INDENT 0.0
  911. .INDENT 3.5
  912. This is an expensive call, increasing CPU and RAM usage on the device. Use sparingly.
  913. .UNINDENT
  914. .UNINDENT
  915. .SH EVENT ENDPOINTS
  916. .SS GET /rest/events
  917. .sp
  918. To receive events, perform a HTTP GET of \fB/rest/events\fP\&.
  919. .sp
  920. To filter the event list, in effect creating a specific subscription for
  921. only the desired event types, add a parameter
  922. \fBevents=EventTypeA,EventTypeB,...\fP where the event types are any of the event\-types\&.
  923. .sp
  924. The optional parameter \fBsince=<lastSeenID>\fP sets the ID of the last event
  925. you’ve already seen. Syncthing returns a JSON encoded array of event objects,
  926. starting at the event just after the one with this last seen ID. The default
  927. value is 0, which returns all events. There is a limit to the number of events
  928. buffered, so if the rate of events is high or the time between polling calls is
  929. long some events might be missed. This can be detected by noting a discontinuity
  930. in the event IDs.
  931. .sp
  932. If no new events are produced since \fB<lastSeenID>\fP, the HTTP call blocks and
  933. waits for new events to happen before returning. By default it times out after
  934. 60 seconds returning an empty array. The time out duration can be customized
  935. with the optional parameter \fBtimeout=seconds\fP\&.
  936. .sp
  937. To receive only a limited number of events, add the \fBlimit=n\fP parameter with a
  938. suitable value for \fBn\fP and only the \fIlast\fP \fBn\fP events will be returned. This
  939. can be used to catch up with the latest event ID after a disconnection for
  940. example: \fB/rest/events?since=0&limit=1\fP\&.
  941. .SH STATISTICS ENDPOINTS
  942. .SS GET /rest/stats/device
  943. .sp
  944. Returns general statistics about devices. Currently, only contains the
  945. time the device was last seen.
  946. .INDENT 0.0
  947. .INDENT 3.5
  948. .sp
  949. .nf
  950. .ft C
  951. $ curl \-s http://localhost:8384/rest/stats/device | json
  952. {
  953. "P56IOI7\-MZJNU2Y\-IQGDREY\-DM2MGTI\-MGL3BXN\-PQ6W5BM\-TBBZ4TJ\-XZWICQ2": {
  954. "lastSeen" : "2015\-04\-18T11:21:31.3256277+01:00"
  955. }
  956. }
  957. .ft P
  958. .fi
  959. .UNINDENT
  960. .UNINDENT
  961. .SS GET /rest/stats/folder
  962. .sp
  963. Returns general statistics about folders. Currently contains the
  964. last scan time and the last synced file.
  965. .INDENT 0.0
  966. .INDENT 3.5
  967. .sp
  968. .nf
  969. .ft C
  970. $ curl \-s http://localhost:8384/rest/stats/folder | json
  971. {
  972. "folderid" : {
  973. "lastScan": "2016\-06\-02T13:28:01.288181412\-04:00",
  974. "lastFile" : {
  975. "filename" : "file/name",
  976. "at" : "2015\-04\-16T22:04:18.3066971+01:00"
  977. }
  978. }
  979. }
  980. .ft P
  981. .fi
  982. .UNINDENT
  983. .UNINDENT
  984. .SH MISC SERVICES ENDPOINTS
  985. .SS GET /rest/svc/deviceid
  986. .sp
  987. Verifies and formats a device ID. Accepts all currently valid formats
  988. (52 or 56 characters with or without separators, upper or lower case,
  989. with trivial substitutions). Takes one parameter, \fBid\fP, and returns
  990. either a valid device ID in modern format, or an error.
  991. .INDENT 0.0
  992. .INDENT 3.5
  993. .sp
  994. .nf
  995. .ft C
  996. $ curl \-s http://localhost:8384/rest/svc/deviceid?id=1234 | json
  997. {
  998. "error": "device ID invalid: incorrect length"
  999. }
  1000. $ curl \-s http://localhost:8384/rest/svc/deviceid?id=p56ioi7m\-\-zjnu2iq\-gdr\-eydm\-2mgtmgl3bxnpq6w5btbbz4tjxzwicq | json
  1001. {
  1002. "id": "P56IOI7\-MZJNU2Y\-IQGDREY\-DM2MGTI\-MGL3BXN\-PQ6W5BM\-TBBZ4TJ\-XZWICQ2"
  1003. }
  1004. .ft P
  1005. .fi
  1006. .UNINDENT
  1007. .UNINDENT
  1008. .SS GET /rest/svc/lang
  1009. .sp
  1010. Returns a list of canonicalized localization codes, as picked up from
  1011. the \fBAccept\-Language\fP header sent by the browser.
  1012. .INDENT 0.0
  1013. .INDENT 3.5
  1014. .sp
  1015. .nf
  1016. .ft C
  1017. ["sv_sv","sv","en_us","en"]
  1018. .ft P
  1019. .fi
  1020. .UNINDENT
  1021. .UNINDENT
  1022. .SS GET /rest/svc/random/string
  1023. .sp
  1024. Returns a strong random generated string (alphanumeric) of the specified length. Takes the \fBlength\fP parameter.
  1025. .INDENT 0.0
  1026. .INDENT 3.5
  1027. .sp
  1028. .nf
  1029. .ft C
  1030. {
  1031. "random": "FdPaEaZQ56sXEKYNxpgF"
  1032. }
  1033. .ft P
  1034. .fi
  1035. .UNINDENT
  1036. .UNINDENT
  1037. .SS GET /rest/svc/report
  1038. .sp
  1039. Returns the data sent in the anonymous usage report.
  1040. .INDENT 0.0
  1041. .INDENT 3.5
  1042. .sp
  1043. .nf
  1044. .ft C
  1045. {
  1046. "folderMaxMiB" : 0,
  1047. "platform" : "linux\-amd64",
  1048. "totMiB" : 0,
  1049. "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",
  1050. "upgradeAllowedManual" : true,
  1051. "totFiles" : 3,
  1052. "folderUses" : {
  1053. "ignorePerms" : 0,
  1054. "autoNormalize" : 0,
  1055. "readonly" : 0,
  1056. "ignoreDelete" : 0
  1057. },
  1058. "memoryUsageMiB" : 13,
  1059. "version" : "v0.12.2",
  1060. "sha256Perf" : 27.28,
  1061. "numFolders" : 2,
  1062. "memorySize" : 1992,
  1063. "announce" : {
  1064. "defaultServersIP" : 0,
  1065. "otherServers" : 0,
  1066. "globalEnabled" : false,
  1067. "defaultServersDNS" : 1,
  1068. "localEnabled" : false
  1069. },
  1070. "usesRateLimit" : false,
  1071. "numCPU" : 2,
  1072. "uniqueID" : "",
  1073. "urVersion" : 2,
  1074. "rescanIntvs" : [
  1075. 60,
  1076. 60
  1077. ],
  1078. "numDevices" : 2,
  1079. "folderMaxFiles" : 3,
  1080. "relays" : {
  1081. "defaultServers" : 1,
  1082. "enabled" : true,
  1083. "otherServers" : 0
  1084. },
  1085. "deviceUses" : {
  1086. "compressMetadata" : 1,
  1087. "customCertName" : 0,
  1088. "staticAddr" : 1,
  1089. "compressAlways" : 0,
  1090. "compressNever" : 1,
  1091. "introducer" : 0,
  1092. "dynamicAddr" : 1
  1093. },
  1094. "upgradeAllowedAuto" : false
  1095. }
  1096. .ft P
  1097. .fi
  1098. .UNINDENT
  1099. .UNINDENT
  1100. .SH AUTHOR
  1101. The Syncthing Authors
  1102. .SH COPYRIGHT
  1103. 2014-2018, The Syncthing Authors
  1104. .\" Generated by docutils manpage writer.
  1105. .