syncthing-rest-api.7 26 KB

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