syncthing-event-api.7 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. .\" Man page generated from reStructuredText.
  2. .
  3. .TH "SYNCTHING-EVENT-API" "7" "January 30, 2016" "v0.12" "Syncthing"
  4. .SH NAME
  5. syncthing-event-api \- Event 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 provides a simple long polling interface for exposing events from the
  36. core utility towards a GUI.
  37. .sp
  38. To receive events, perform a HTTP GET of \fB/rest/events?since=<lastSeenID>\fP,
  39. where \fB<lastSeenID>\fP is the ID of the last event you\(aqve already seen or zero.
  40. Syncthing returns a JSON encoded array of event objects, starting at the event
  41. just after the one with the last seen ID. There is a limit to the number of
  42. events buffered, so if the rate of events is high or the time between polling
  43. calls is long some events might be missed. This can be detected by noting a
  44. discontinuity in the event IDs.
  45. .sp
  46. If no new events are produced since \fB<lastSeenID>\fP, the HTTP call blocks and
  47. waits for new events to happen before returning, or if no new events are
  48. produced within 60 seconds, times out.
  49. .sp
  50. To receive only a limited number of events, add the \fBlimit=n\fP parameter with a
  51. suitable value for \fBn\fP and only the \fIlast\fP \fBn\fP events will be returned. This
  52. can be used to catch up with the latest event ID after a disconnection for
  53. example: \fB/rest/events?since=0&limit=1\fP\&.
  54. .SH EVENT STRUCTURE
  55. .sp
  56. Each event is represented by an object similar to the following:
  57. .INDENT 0.0
  58. .INDENT 3.5
  59. .sp
  60. .nf
  61. .ft C
  62. {
  63. "id": 2,
  64. "type": "DeviceConnected",
  65. "time": "2014\-07\-13T21:04:33.687836696+02:00",
  66. "data": {
  67. "addr": "172.16.32.25:22000",
  68. "id": "NFGKEKE\-7Z6RTH7\-I3PRZXS\-DEJF3UJ\-FRWJBFO\-VBBTDND\-4SGNGVZ\-QUQHJAG"
  69. }
  70. }
  71. .ft P
  72. .fi
  73. .UNINDENT
  74. .UNINDENT
  75. .sp
  76. The top level keys \fBid\fP, \fBtime\fP, \fBtype\fP and \fBdata\fP are always present,
  77. though \fBdata\fP may be \fBnull\fP\&.
  78. .INDENT 0.0
  79. .TP
  80. .B id
  81. A monotonically increasing integer. The first event generated has id \fB1\fP,
  82. the next has id \fB2\fP etc.
  83. .TP
  84. .B time
  85. The time the event was generated.
  86. .TP
  87. .B type
  88. Indicates the type of (i.e. reason for) the event and is one of the event
  89. types below.
  90. .TP
  91. .B data
  92. An object containing optional extra information; the exact structure is
  93. determined by the event type.
  94. .UNINDENT
  95. .SH EVENTS
  96. .SS ConfigSaved
  97. .sp
  98. Emitted after the config has been saved by the user or by Syncthing
  99. itself.
  100. .INDENT 0.0
  101. .INDENT 3.5
  102. .sp
  103. .nf
  104. .ft C
  105. {
  106. "id": 50,
  107. "type": "ConfigSaved",
  108. "time": "2014\-12\-13T00:09:13.5166486Z",
  109. "data":{
  110. "Version": 7,
  111. "Options": { ... },
  112. "GUI": { ... },
  113. "Devices": [ ... ],
  114. "Folders": [ ... ]
  115. }
  116. }
  117. .ft P
  118. .fi
  119. .UNINDENT
  120. .UNINDENT
  121. .SS DeviceConnected
  122. .sp
  123. Generated each time a connection to a device has been established.
  124. .INDENT 0.0
  125. .INDENT 3.5
  126. .sp
  127. .nf
  128. .ft C
  129. {
  130. "id": 2,
  131. "type": "DeviceConnected",
  132. "time": "2014\-07\-13T21:04:33.687836696+02:00",
  133. "data": {
  134. "addr": "172.16.32.25:22000",
  135. "id": "NFGKEKE\-7Z6RTH7\-I3PRZXS\-DEJF3UJ\-FRWJBFO\-VBBTDND\-4SGNGVZ\-QUQHJAG"
  136. }
  137. }
  138. .ft P
  139. .fi
  140. .UNINDENT
  141. .UNINDENT
  142. .SS DeviceDisconnected
  143. .sp
  144. Generated each time a connection to a device has been terminated.
  145. .INDENT 0.0
  146. .INDENT 3.5
  147. .sp
  148. .nf
  149. .ft C
  150. {
  151. "id": 48,
  152. "type": "DeviceDisconnected",
  153. "time": "2014\-07\-13T21:18:52.859929215+02:00",
  154. "data": {
  155. "error": "unexpected EOF",
  156. "id": "NFGKEKE\-7Z6RTH7\-I3PRZXS\-DEJF3UJ\-FRWJBFO\-VBBTDND\-4SGNGVZ\-QUQHJAG"
  157. }
  158. }
  159. .ft P
  160. .fi
  161. .UNINDENT
  162. .UNINDENT
  163. .sp
  164. \fBNOTE:\fP
  165. .INDENT 0.0
  166. .INDENT 3.5
  167. The error key contains the cause for disconnection, which might not
  168. necessarily be an error as such. Specifically, "EOF" and "unexpected
  169. EOF" both signify TCP connection termination, either due to the other
  170. device restarting or going offline or due to a network change.
  171. .UNINDENT
  172. .UNINDENT
  173. .SS DeviceDiscovered
  174. .sp
  175. Emitted when a new device is discovered using local discovery.
  176. .INDENT 0.0
  177. .INDENT 3.5
  178. .sp
  179. .nf
  180. .ft C
  181. {
  182. "id": 13,
  183. "type": "DeviceDiscovered",
  184. "time": "2014\-07\-17T13:28:05.043465207+02:00",
  185. "data": {
  186. "addrs": [
  187. "172.16.32.25:22000"
  188. ],
  189. "device": "NFGKEKE\-7Z6RTH7\-I3PRZXS\-DEJF3UJ\-FRWJBFO\-VBBTDND\-4SGNGVZ\-QUQHJAG"
  190. }
  191. }
  192. .ft P
  193. .fi
  194. .UNINDENT
  195. .UNINDENT
  196. .SS DeviceRejected
  197. .sp
  198. Emitted when there is a connection from a device we are not configured
  199. to talk to.
  200. .INDENT 0.0
  201. .INDENT 3.5
  202. .sp
  203. .nf
  204. .ft C
  205. {
  206. "id": 24,
  207. "type": "DeviceRejected",
  208. "time": "2014\-08\-19T10:43:00.562821045+02:00",
  209. "data": {
  210. "address": "127.0.0.1:51807",
  211. "device": "EJHMPAQ\-OGCVORE\-ISB4IS3\-SYYVJXF\-TKJGLTU\-66DIQPF\-GJ5D2GX\-GQ3OWQK"
  212. }
  213. }
  214. .ft P
  215. .fi
  216. .UNINDENT
  217. .UNINDENT
  218. .SS DownloadProgress
  219. .sp
  220. Emitted during file downloads for each folder for each file. By default
  221. only a single file in a folder is handled at the same time, but custom
  222. configuration can cause multiple files to be shown.
  223. .INDENT 0.0
  224. .INDENT 3.5
  225. .sp
  226. .nf
  227. .ft C
  228. {
  229. "id": 221,
  230. "type": "DownloadProgress",
  231. "time": "2014\-12\-13T00:26:12.9876937Z",
  232. "data": {
  233. "folder1": {
  234. "file1": {
  235. "Total": 800,
  236. "Pulling": 2,
  237. "CopiedFromOrigin": 0,
  238. "Reused": 633,
  239. "CopiedFromElsewhere": 0,
  240. "Pulled": 38,
  241. "BytesTotal": 104792064,
  242. "BytesDone": 87883776
  243. },
  244. "dir\e\efile2": {
  245. "Total": 80,
  246. "Pulling": 2,
  247. "CopiedFromOrigin": 0,
  248. "Reused": 0,
  249. "CopiedFromElsewhere": 0,
  250. "Pulled": 32,
  251. "BytesTotal": 10420224,
  252. "BytesDone": 4128768
  253. }
  254. },
  255. "folder2": {
  256. "file3": {
  257. "Total": 800,
  258. "Pulling": 2,
  259. "CopiedFromOrigin": 0,
  260. "Reused": 633,
  261. "CopiedFromElsewhere": 0,
  262. "Pulled": 38,
  263. "BytesTotal": 104792064,
  264. "BytesDone": 87883776
  265. },
  266. "dir\e\efile4": {
  267. "Total": 80,
  268. "Pulling": 2,
  269. "CopiedFromOrigin": 0,
  270. "Reused": 0,
  271. "CopiedFromElsewhere": 0,
  272. "Pulled": 32,
  273. "BytesTotal": 10420224,
  274. "BytesDone": 4128768
  275. }
  276. }
  277. }
  278. }
  279. .ft P
  280. .fi
  281. .UNINDENT
  282. .UNINDENT
  283. .INDENT 0.0
  284. .IP \(bu 2
  285. \fBTotal\fP \- total number of blocks in the file
  286. .IP \(bu 2
  287. \fBPulling\fP \- number of blocks currently being downloaded
  288. .IP \(bu 2
  289. \fBCopiedFromOrigin\fP \- number of blocks copied from the file we are
  290. about to replace
  291. .IP \(bu 2
  292. \fBReused\fP \- number of blocks reused from a previous temporary file
  293. .IP \(bu 2
  294. \fBCopiedFromElsewhere\fP \- number of blocks copied from other files or
  295. potentially other folders
  296. .IP \(bu 2
  297. \fBPulled\fP \- number of blocks actually downloaded so far
  298. .IP \(bu 2
  299. \fBBytesTotal\fP \- approximate total file size
  300. .IP \(bu 2
  301. \fBBytesDone\fP \- approximate number of bytes already handled (already
  302. reused, copied or pulled)
  303. .UNINDENT
  304. .sp
  305. Where block size is 128KB.
  306. .sp
  307. Files/folders appearing in the event data imply that the download has
  308. been started for that file/folder, where disappearing implies that the
  309. downloads have been finished or failed for that file/folder. There is
  310. always a last event emitted with no data, which implies all downloads
  311. have finished/failed.
  312. .SS FolderCompletion
  313. .sp
  314. The \fBFolderCompletion\fP event is emitted when the local or remote
  315. contents for a folder changes. It contains the completion percentage for
  316. a given remote device and is emitted once per currently connected remote
  317. device.
  318. .INDENT 0.0
  319. .INDENT 3.5
  320. .sp
  321. .nf
  322. .ft C
  323. {
  324. "id": 84,
  325. "type": "FolderCompletion",
  326. "time": "2015\-04\-17T14:14:27.043576583+09:00",
  327. "data": {
  328. "completion": 100,
  329. "device": "I6KAH76\-66SLLLB\-5PFXSOA\-UFJCDZC\-YAOMLEK\-CP2GB32\-BV5RQST\-3PSROAU",
  330. "folder": "default"
  331. }
  332. }
  333. .ft P
  334. .fi
  335. .UNINDENT
  336. .UNINDENT
  337. .SS FolderErrors
  338. .sp
  339. The \fBFolderErrors\fP event is emitted when a folder cannot be successfully
  340. synchronized. The event contains the ID of the affected folder and a list of
  341. errors for files or directories therein. This list of errors is obsolete once
  342. the folder changes state to \fBsyncing\fP \- if errors remain after the next
  343. synchronization attempt, a new \fBFolderErrors\fP event is emitted.
  344. .INDENT 0.0
  345. .INDENT 3.5
  346. .sp
  347. .nf
  348. .ft C
  349. {
  350. "id": 132,
  351. "type": "FolderErrors",
  352. "time": "2015\-06\-26T13:39:24.697401384+02:00",
  353. "data": {
  354. "errors": [
  355. {
  356. "error": "open /Users/jb/src/github.com/syncthing/syncthing/test/s2/h2j/.syncthing.aslkjd.tmp: permission denied",
  357. "path": "h2j/aslkjd"
  358. }
  359. ],
  360. "folder": "default"
  361. }
  362. }
  363. .ft P
  364. .fi
  365. .UNINDENT
  366. .UNINDENT
  367. .sp
  368. New in version 0.11.12.
  369. .sp
  370. \fBSEE ALSO:\fP
  371. .INDENT 0.0
  372. .INDENT 3.5
  373. The statechanged event.
  374. .UNINDENT
  375. .UNINDENT
  376. .SS FolderRejected
  377. .sp
  378. Emitted when a device sends index information for a folder we do not
  379. have, or have but do not share with the device in question.
  380. .INDENT 0.0
  381. .INDENT 3.5
  382. .sp
  383. .nf
  384. .ft C
  385. {
  386. "id": 27,
  387. "type": "FolderRejected",
  388. "time": "2014\-08\-19T10:41:06.761751399+02:00",
  389. "data": {
  390. "device": "EJHMPAQ\-OGCVORE\-ISB4IS3\-SYYVJXF\-TKJGLTU\-66DIQPF\-GJ5D2GX\-GQ3OWQK",
  391. "folder": "unique"
  392. }
  393. }
  394. .ft P
  395. .fi
  396. .UNINDENT
  397. .UNINDENT
  398. .SS FolderSummary
  399. .sp
  400. The FolderSummary event is emitted when folder contents have changed
  401. locally. This can be used to calculate the current local completion
  402. state.
  403. .INDENT 0.0
  404. .INDENT 3.5
  405. .sp
  406. .nf
  407. .ft C
  408. {
  409. "id": 16,
  410. "type": "FolderSummary",
  411. "time": "2015\-04\-17T14:12:20.460121585+09:00",
  412. "data": {
  413. "folder": "default",
  414. "summary": {
  415. "globalBytes": 0,
  416. "globalDeleted": 0,
  417. "globalFiles": 0,
  418. "ignorePatterns": false,
  419. "inSyncBytes": 0,
  420. "inSyncFiles": 0,
  421. "invalid": "",
  422. "localBytes": 0,
  423. "localDeleted": 0,
  424. "localFiles": 0,
  425. "needBytes": 0,
  426. "needFiles": 0,
  427. "state": "idle",
  428. "stateChanged": "2015\-04\-17T14:12:12.455224687+09:00",
  429. "version": 0
  430. }
  431. }
  432. }
  433. .ft P
  434. .fi
  435. .UNINDENT
  436. .UNINDENT
  437. .SS ItemFinished
  438. .sp
  439. Generated when Syncthing ends synchronizing a file to a newer version. A
  440. successful operation:
  441. .INDENT 0.0
  442. .INDENT 3.5
  443. .sp
  444. .nf
  445. .ft C
  446. {
  447. "id": 93,
  448. "type": "ItemFinished",
  449. "time": "2014\-07\-13T21:22:03.414609034+02:00",
  450. "data": {
  451. "item": "test.txt",
  452. "folder": "default",
  453. "error": null,
  454. "type": "file",
  455. "action": "update"
  456. }
  457. }
  458. .ft P
  459. .fi
  460. .UNINDENT
  461. .UNINDENT
  462. .sp
  463. An unsuccessful operation:
  464. .INDENT 0.0
  465. .INDENT 3.5
  466. .sp
  467. .nf
  468. .ft C
  469. {
  470. "id": 44,
  471. "type": "ItemFinished",
  472. "time": "2015\-05\-27T11:21:05.711133004+02:00",
  473. "data": {
  474. "action": "update",
  475. "error": "open /Users/jb/src/github.com/syncthing/syncthing/test/s2/foo/.syncthing.hej.tmp: permission denied",
  476. "folder": "default",
  477. "item": "foo/hej",
  478. "type": "file"
  479. }
  480. }
  481. .ft P
  482. .fi
  483. .UNINDENT
  484. .UNINDENT
  485. .sp
  486. The \fBaction\fP field is either \fBupdate\fP (contents changed), \fBmetadata\fP (file metadata changed but not contents), or \fBdelete\fP\&.
  487. .sp
  488. New in version 0.11.10: The \fBmetadata\fP action.
  489. .SS ItemStarted
  490. .sp
  491. Generated when Syncthing begins synchronizing a file to a newer version.
  492. .INDENT 0.0
  493. .INDENT 3.5
  494. .sp
  495. .nf
  496. .ft C
  497. {
  498. "id": 93,
  499. "type": "ItemStarted",
  500. "time": "2014\-07\-13T21:22:03.414609034+02:00",
  501. "data": {
  502. "item": "test.txt",
  503. "folder": "default",
  504. "type": "file",
  505. "action": "update"
  506. }
  507. }
  508. .ft P
  509. .fi
  510. .UNINDENT
  511. .UNINDENT
  512. .sp
  513. The \fBaction\fP field is either \fBupdate\fP (contents changed), \fBmetadata\fP (file metadata changed but not contents), or \fBdelete\fP\&.
  514. .sp
  515. New in version 0.11.10: The \fBmetadata\fP action.
  516. .SS LocalIndexUpdated
  517. .sp
  518. Generated when the local index information has changed, due to
  519. synchronizing one or more items from the cluster or discovering local
  520. changes during a scan.
  521. .INDENT 0.0
  522. .INDENT 3.5
  523. .sp
  524. .nf
  525. .ft C
  526. {
  527. "id": 59,
  528. "type": "LocalIndexUpdated",
  529. "time": "2014\-07\-17T13:27:28.051369434+02:00",
  530. "data": {
  531. "folder": "default",
  532. "items": 1000,
  533. }
  534. }
  535. .ft P
  536. .fi
  537. .UNINDENT
  538. .UNINDENT
  539. .SS Ping
  540. .sp
  541. The Ping event is generated automatically every 60 seconds. This means
  542. that even in the absence of any other activity, the event polling HTTP
  543. request will return within a minute.
  544. .INDENT 0.0
  545. .INDENT 3.5
  546. .sp
  547. .nf
  548. .ft C
  549. {
  550. "id": 46,
  551. "type": "Ping",
  552. "time": "2014\-07\-13T21:13:18.502171586+02:00",
  553. "data": null
  554. }
  555. .ft P
  556. .fi
  557. .UNINDENT
  558. .UNINDENT
  559. .SS RemoteIndexUpdated
  560. .sp
  561. Generated each time new index information is received from a device.
  562. .INDENT 0.0
  563. .INDENT 3.5
  564. .sp
  565. .nf
  566. .ft C
  567. {
  568. "id": 44,
  569. "type": "RemoteIndexUpdated",
  570. "time": "2014\-07\-13T21:04:35.394184435+02:00",
  571. "data": {
  572. "device": "NFGKEKE\-7Z6RTH7\-I3PRZXS\-DEJF3UJ\-FRWJBFO\-VBBTDND\-4SGNGVZ\-QUQHJAG",
  573. "folder": "lightroom",
  574. "items": 1000
  575. }
  576. }
  577. .ft P
  578. .fi
  579. .UNINDENT
  580. .UNINDENT
  581. .SS Starting
  582. .sp
  583. Emitted exactly once, when Syncthing starts, before parsing
  584. configuration etc.
  585. .INDENT 0.0
  586. .INDENT 3.5
  587. .sp
  588. .nf
  589. .ft C
  590. {
  591. "id": 1,
  592. "type": "Starting",
  593. "time": "2014\-07\-17T13:13:32.044470055+02:00",
  594. "data": {
  595. "home": "/home/jb/.config/syncthing"
  596. }
  597. }
  598. .ft P
  599. .fi
  600. .UNINDENT
  601. .UNINDENT
  602. .SS StartupComplete
  603. .sp
  604. Emitted exactly once, when initialization is complete and Syncthing is
  605. ready to start exchanging data with other devices.
  606. .INDENT 0.0
  607. .INDENT 3.5
  608. .sp
  609. .nf
  610. .ft C
  611. {
  612. "id": 1,
  613. "type": "StartupComplete",
  614. "time": "2014\-07\-13T21:03:18.383239179+02:00",
  615. "data": null
  616. }
  617. .ft P
  618. .fi
  619. .UNINDENT
  620. .UNINDENT
  621. .SS StateChanged
  622. .sp
  623. Emitted when a folder changes state. Possible states are \fBidle\fP,
  624. \fBscanning\fP, \fBsyncing\fP and \fBerror\fP\&. The field \fBduration\fP is
  625. the number of seconds the folder spent in state \fBfrom\fP\&. In the example
  626. below, the folder \fBdefault\fP was in state \fBscanning\fP for 0.198
  627. seconds and is now in state \fBidle\fP\&.
  628. .INDENT 0.0
  629. .INDENT 3.5
  630. .sp
  631. .nf
  632. .ft C
  633. {
  634. "id": 8,
  635. "type": "StateChanged",
  636. "time": "2014\-07\-17T13:14:28.697493016+02:00",
  637. "data": {
  638. "folder": "default",
  639. "from": "scanning",
  640. "duration": 0.19782869900000002,
  641. "to": "idle"
  642. }
  643. }
  644. .ft P
  645. .fi
  646. .UNINDENT
  647. .UNINDENT
  648. .SH AUTHOR
  649. The Syncthing Authors
  650. .SH COPYRIGHT
  651. 2015, The Syncthing Authors
  652. .\" Generated by docutils manpage writer.
  653. .