syncthing-event-api.7 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. .\" Man page generated from reStructuredText.
  2. .
  3. .TH "SYNCTHING-EVENT-API" "7" "June 14, 2015" "v0.11" "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 has been finished or failed for that file/folder. There is
  310. always a last event emitted with no data, which implies all downloads
  311. being 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 FolderRejected
  338. .sp
  339. Emitted when a device sends index information for a folder we do not
  340. have, or have but do not share with the device in question.
  341. .INDENT 0.0
  342. .INDENT 3.5
  343. .sp
  344. .nf
  345. .ft C
  346. {
  347. "id": 27,
  348. "type": "FolderRejected",
  349. "time": "2014\-08\-19T10:41:06.761751399+02:00",
  350. "data": {
  351. "device": "EJHMPAQ\-OGCVORE\-ISB4IS3\-SYYVJXF\-TKJGLTU\-66DIQPF\-GJ5D2GX\-GQ3OWQK",
  352. "folder": "unique"
  353. }
  354. }
  355. .ft P
  356. .fi
  357. .UNINDENT
  358. .UNINDENT
  359. .SS FolderSummary
  360. .sp
  361. The FolderSummary event is emitted when folder contents have changed
  362. locally. This can be used to calculate the current local completion
  363. state.
  364. .INDENT 0.0
  365. .INDENT 3.5
  366. .sp
  367. .nf
  368. .ft C
  369. {
  370. "id": 16,
  371. "type": "FolderSummary",
  372. "time": "2015\-04\-17T14:12:20.460121585+09:00",
  373. "data": {
  374. "folder": "default",
  375. "summary": {
  376. "globalBytes": 0,
  377. "globalDeleted": 0,
  378. "globalFiles": 0,
  379. "ignorePatterns": false,
  380. "inSyncBytes": 0,
  381. "inSyncFiles": 0,
  382. "invalid": "",
  383. "localBytes": 0,
  384. "localDeleted": 0,
  385. "localFiles": 0,
  386. "needBytes": 0,
  387. "needFiles": 0,
  388. "state": "idle",
  389. "stateChanged": "2015\-04\-17T14:12:12.455224687+09:00",
  390. "version": 0
  391. }
  392. }
  393. }
  394. .ft P
  395. .fi
  396. .UNINDENT
  397. .UNINDENT
  398. .SS ItemFinished
  399. .sp
  400. Generated when Syncthing ends synchronizing a file to a newer version. A
  401. successful operation:
  402. .INDENT 0.0
  403. .INDENT 3.5
  404. .sp
  405. .nf
  406. .ft C
  407. {
  408. "id": 93,
  409. "type": "ItemFinished",
  410. "time": "2014\-07\-13T21:22:03.414609034+02:00",
  411. "data": {
  412. "item": "test.txt",
  413. "folder": "default",
  414. "error": null,
  415. "type": "file",
  416. "action": "update"
  417. }
  418. }
  419. .ft P
  420. .fi
  421. .UNINDENT
  422. .UNINDENT
  423. .sp
  424. An unsuccessful operation:
  425. .INDENT 0.0
  426. .INDENT 3.5
  427. .sp
  428. .nf
  429. .ft C
  430. {
  431. "id": 44,
  432. "type": "ItemFinished",
  433. "time": "2015\-05\-27T11:21:05.711133004+02:00",
  434. "data": {
  435. "action": "update",
  436. "error": "open /Users/jb/src/github.com/syncthing/syncthing/test/s2/foo/.syncthing.hej.tmp: permission denied",
  437. "folder": "default",
  438. "item": "foo/hej",
  439. "type": "file"
  440. }
  441. }
  442. .ft P
  443. .fi
  444. .UNINDENT
  445. .UNINDENT
  446. .sp
  447. The \fBaction\fP field is either \fBupdate\fP or \fBdelete\fP\&.
  448. .SS ItemStarted
  449. .sp
  450. Generated when Syncthing begins synchronizing a file to a newer version.
  451. .INDENT 0.0
  452. .INDENT 3.5
  453. .sp
  454. .nf
  455. .ft C
  456. {
  457. "id": 93,
  458. "type": "ItemStarted",
  459. "time": "2014\-07\-13T21:22:03.414609034+02:00",
  460. "data": {
  461. "item": "test.txt",
  462. "folder": "default",
  463. "type": "file",
  464. "action": "update"
  465. }
  466. }
  467. .ft P
  468. .fi
  469. .UNINDENT
  470. .UNINDENT
  471. .sp
  472. The \fBaction\fP field is either \fBupdate\fP or \fBdelete\fP\&.
  473. .SS LocalIndexUpdated
  474. .sp
  475. Generated when the local index information has changed, due to
  476. synchronizing one or more items from the cluster or discovering local
  477. changes during a scan.
  478. .INDENT 0.0
  479. .INDENT 3.5
  480. .sp
  481. .nf
  482. .ft C
  483. {
  484. "id": 59,
  485. "type": "LocalIndexUpdated",
  486. "time": "2014\-07\-17T13:27:28.051369434+02:00",
  487. "data": {
  488. "folder": "default",
  489. "items": 1000,
  490. }
  491. }
  492. .ft P
  493. .fi
  494. .UNINDENT
  495. .UNINDENT
  496. .SS Ping
  497. .sp
  498. The Ping event is generated automatically every 60 seconds. This means
  499. that even in the absence of any other activity, the event polling HTTP
  500. request will return within a minute.
  501. .INDENT 0.0
  502. .INDENT 3.5
  503. .sp
  504. .nf
  505. .ft C
  506. {
  507. "id": 46,
  508. "type": "Ping",
  509. "time": "2014\-07\-13T21:13:18.502171586+02:00",
  510. "data": null
  511. }
  512. .ft P
  513. .fi
  514. .UNINDENT
  515. .UNINDENT
  516. .SS RemoteIndexUpdated
  517. .sp
  518. Generated each time new index information is received from a device.
  519. .INDENT 0.0
  520. .INDENT 3.5
  521. .sp
  522. .nf
  523. .ft C
  524. {
  525. "id": 44,
  526. "type": "RemoteIndexUpdated",
  527. "time": "2014\-07\-13T21:04:35.394184435+02:00",
  528. "data": {
  529. "device": "NFGKEKE\-7Z6RTH7\-I3PRZXS\-DEJF3UJ\-FRWJBFO\-VBBTDND\-4SGNGVZ\-QUQHJAG",
  530. "folder": "lightroom",
  531. "items": 1000
  532. }
  533. }
  534. .ft P
  535. .fi
  536. .UNINDENT
  537. .UNINDENT
  538. .SS Starting
  539. .sp
  540. Emitted exactly once, when Syncthing starts, before parsing
  541. configuration etc.
  542. .INDENT 0.0
  543. .INDENT 3.5
  544. .sp
  545. .nf
  546. .ft C
  547. {
  548. "id": 1,
  549. "type": "Starting",
  550. "time": "2014\-07\-17T13:13:32.044470055+02:00",
  551. "data": {
  552. "home": "/home/jb/.config/syncthing"
  553. }
  554. }
  555. .ft P
  556. .fi
  557. .UNINDENT
  558. .UNINDENT
  559. .SS StartupCompleted
  560. .sp
  561. Emitted exactly once, when initialization is complete and Syncthing is
  562. ready to start exchanging data with other devices.
  563. .INDENT 0.0
  564. .INDENT 3.5
  565. .sp
  566. .nf
  567. .ft C
  568. {
  569. "id": 1,
  570. "type": "StartupComplete",
  571. "time": "2014\-07\-13T21:03:18.383239179+02:00",
  572. "data": null
  573. }
  574. .ft P
  575. .fi
  576. .UNINDENT
  577. .UNINDENT
  578. .SS StateChanged
  579. .sp
  580. Emitted when a folder changes state. Possible states are \fBidle\fP,
  581. \fBscanning\fP, \fBcleaning\fP and \fBsyncing\fP\&. The field \fBduration\fP is
  582. the number of seconds the folder spent in state \fBfrom\fP\&. In the example
  583. below, the folder \fBdefault\fP was in state \fBscanning\fP for 0.198
  584. seconds and is now in state \fBidle\fP\&.
  585. .INDENT 0.0
  586. .INDENT 3.5
  587. .sp
  588. .nf
  589. .ft C
  590. {
  591. "id": 8,
  592. "type": "StateChanged",
  593. "time": "2014\-07\-17T13:14:28.697493016+02:00",
  594. "data": {
  595. "folder": "default",
  596. "from": "scanning",
  597. "duration": 0.19782869900000002,
  598. "to": "idle"
  599. }
  600. }
  601. .ft P
  602. .fi
  603. .UNINDENT
  604. .UNINDENT
  605. .SH AUTHOR
  606. The Syncthing Authors
  607. .SH COPYRIGHT
  608. 2015, The Syncthing Authors
  609. .\" Generated by docutils manpage writer.
  610. .