syncthing-rest-api.7 26 KB

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