syncthing-rest-api.7 24 KB

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