syncthing-rest-api - REST API
Syncthing exposes a REST interface over HTTP on the GUI port. This is used by the GUI code (JavaScript) and can be used by other processes wishing to control Syncthing. In most cases both the input and output data is in JSON format. The interface is subject to change.
To use the POST methods, or any method when authentication is enabled, an API key must be set and used. The API key can be generated in the GUI, or set in the configuration/gui/apikey element in the configuration file. To use an API key, set the request header X-API-Key to the API key value. For example, curl -X POST -H "X-API-Key: abc123" http://localhost:8384/rest/... can be used to invoke authenticated POST methods via curl.
GET /rest/system/config Returns the current configuration. { { "version": 15, "folders": [ { "id": "GXWxf-3zgnU", "label": "MyFolder", "path": "...", "type": "readwrite", "devices": [ { "deviceID": "..." } ], "rescanIntervalS": 60, "ignorePerms": false, "autoNormalize": true, "minDiskFreePct": 1, "versioning": { "type": "", "params": {} }, "copiers": 0, "pullers": 0, "hashers": 0, "order": "random", "ignoreDelete": false, "scanProgressIntervalS": 0, "pullerSleepS": 0, "pullerPauseS": 0, "maxConflicts": 10, "disableSparseFiles": false, "disableTempIndexes": false, "invalid": "" } ], "devices": [ { "deviceID": "...", "name": "Laptop", "addresses": [ "dynamic", "tcp://192.168.1.2:22000" ], "compression": "metadata", "certName": "", "introducer": false } ], "gui": { "enabled": true, "address": "127.0.0.1:8384", "user": "Username", "password": "$2a$10$ZFws69T4FlvWwsqeIwL.TOo5zOYqsa/.TxlUnsGYS.j3JvjFTmxo6", "useTLS": false, "apiKey": "pGahcht56664QU5eoFQW6szbEG6Ec2Cr", "insecureAdminAccess": false, "theme": "default" }, "options": { "listenAddresses": [ "default" ], "globalAnnounceServers": [ "default" ], "globalAnnounceEnabled": true, "localAnnounceEnabled": true, "localAnnouncePort": 21027, "localAnnounceMCAddr": "[ff12::8384]:21027", "maxSendKbps": 0, "maxRecvKbps": 0, "reconnectionIntervalS": 60, "relaysEnabled": true, "relayReconnectIntervalM": 10, "startBrowser": false, "natEnabled": true, "natLeaseMinutes": 60, "natRenewalMinutes": 30, "natTimeoutSeconds": 10, "urAccepted": -1, "urUniqueId": "", "urURL": "https://data.syncthing.net/newdata", "urPostInsecurely": false, "urInitialDelayS": 1800, "restartOnWakeup": true, "autoUpgradeIntervalH": 12, "keepTemporariesH": 24, "cacheIgnoredFiles": false, "progressUpdateIntervalS": 5, "symlinksEnabled": true, "limitBandwidthInLan": false, "minHomeDiskFreePct": 1, "releasesURL": "https://upgrades.syncthing.net/meta.json", "alwaysLocalNets": [], "overwriteRemoteDeviceNamesOnConnect": false, "tempIndexMinBlocks": 10 }, "ignoredDevices": [] } } GET /rest/system/config/insync Returns whether the config is in sync, i.e. whether the running configuration is the same as that on disk. { "configInSync": true } POST /rest/system/config Post the full contents of the configuration, in the same format as returned by the corresponding GET request. The configuration will be saved to disk and the configInSync flag set to false. Restart Syncthing to activate. GET /rest/system/connections NOTE: Return format changed in 0.13.0. Returns the list of configured devices and some metadata associated with them. The list also contains the local device itself as not connected. The connection types are TCP (Client), TCP (Server), Relay (Client) and Relay (Server). { "total" : { "paused" : false, "clientVersion" : "", "at" : "2015-11-07T17:29:47.691637262+01:00", "connected" : false, "inBytesTotal" : 1479, "type" : "", "outBytesTotal" : 1318, "address" : "" }, "connections" : { "YZJBJFX-RDBL7WY-6ZGKJ2D-4MJB4E7-ZATSDUY-LD6Y3L3-MLFUYWE-AEMXJAC" : { "connected" : true, "inBytesTotal" : 556, "paused" : false, "at" : "2015-11-07T17:29:47.691548971+01:00", "clientVersion" : "v0.12.1", "address" : "127.0.0.1:22002", "type" : "TCP (Client)", "outBytesTotal" : 550 }, "DOVII4U-SQEEESM-VZ2CVTC-CJM4YN5-QNV7DCU-5U3ASRL-YVFG6TH-W5DV5AA" : { "outBytesTotal" : 0, "type" : "", "address" : "", "at" : "0001-01-01T00:00:00Z", "clientVersion" : "", "paused" : false, "inBytesTotal" : 0, "connected" : false }, "UYGDMA4-TPHOFO5-2VQYDCC-7CWX7XW-INZINQT-LE4B42N-4JUZTSM-IWCSXA4" : { "address" : "", "type" : "", "outBytesTotal" : 0, "connected" : false, "inBytesTotal" : 0, "paused" : false, "at" : "0001-01-01T00:00:00Z", "clientVersion" : "" } } } GET /rest/system/debug New in version 0.12.0. Returns the set of debug facilities and which of them are currently enabled. { "enabled": [ "beacon" ], "facilities": { "beacon": "Multicast and broadcast discovery", "config": "Configuration loading and saving", "connections": "Connection handling", "db": "The database layer", "dialer": "Dialing connections", "discover": "Remote device discovery", "events": "Event generation and logging", "http": "REST API", "main": "Main package", "model": "The root hub", "protocol": "The BEP protocol", "relay": "Relay connection handling", "scanner": "File change detection and hashing", "stats": "Persistent device and folder statistics", "sync": "Mutexes", "upgrade": "Binary upgrades", "upnp": "UPnP discovery and port mapping", "versioner": "File versioning" } } POST /rest/system/debug New in version 0.12.0. Enables or disables debugging for specified facilities. Give one or both of enable and disable query parameters, with comma separated facility names. To disable debugging of the beacon and discovery packages, and enable it for config and db: $ curl -H X-API-Key:abc123 -X POST 'http://localhost:8384/rest/system/debug?disable=beacon,discovery&enable=config,db' GET /rest/system/discovery Returns the contents of the local discovery cache. { "LGFPDIT7SKNNJVJZA4FC7QNCRKCE753K72BW5QD2FOZ7FRFEP57Q": [ "192.162.129.11:22000" ] } POST /rest/system/discovery NOTE: Removed in v0.12.0. Post with the query parameters device and addr to add entries to the discovery cache. curl -X POST http://127.0.0.1:8384/rest/system/discovery?device=LGFPDIT7SKNNJVJZA4FC7QNCRKCE753K72BW5QD2FOZ7FRFEP57Q\&addr=192.162.129.11:22000 # Or with the X-API-Key header: curl -X POST --header "X-API-Key: TcE28kVPdtJ8COws1JdM0b2nodj77WeQ" http://127.0.0.1:8384/rest/system/discovery?device=LGFPDIT7SKNNJVJZA4FC7QNCRKCE753K72BW5QD2FOZ7FRFEP57Q\&addr=192.162.129.11:22000 POST /rest/system/error/clear Post with empty to body to remove all recent errors. GET /rest/system/error NOTE: Return format changed in 0.12.0. Returns the list of recent errors. { "errors": [ { "when": "2014-09-18T12:59:26.549953186+02:00", "message": "This is an error string" } ] } POST /rest/system/error Post with an error message in the body (plain text) to register a new error. The new error will be displayed on any active GUI clients. GET /rest/system/log New in version 0.12.0. Returns the list of recent log entries. { "messages": [ { "when": "2014-09-18T12:59:26.549953186+02:00", "message": "This is a log entry" } ] } GET /rest/system/ping Returns a {"ping": "pong"} object. { "ping": "pong" } POST /rest/system/ping Returns a {"ping": "pong"} object. POST /rest/system/reset Post with empty body to erase the current index database and restart Syncthing. With no query parameters, the entire database is erased from disk. By specifying the folder parameter with a valid folder ID, only information for that folder will be erased: $ curl -X POST -H "X-API-Key: abc123" http://localhost:8384/rest/system/reset?folder=default POST /rest/system/restart Post with empty body to immediately restart Syncthing. POST /rest/system/shutdown Post with empty body to cause Syncthing to exit and not restart. GET /rest/system/status Returns information about current system status and resource usage. { "alloc": 30618136, "connectionServiceStatus": { "dynamic+https://relays.syncthing.net/endpoint": { "lanAddresses": [ "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" ], "wanAddresses": [ "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" ] }, "tcp://0.0.0.0:22000": { "lanAddresses": [ "tcp://0.0.0.0:22000" ], "wanAddresses": [ "tcp://0.0.0.0:22000" ] } }, "cpuPercent": 0.006944836512046966, "discoveryEnabled": true, "discoveryErrors": { "global@https://discovery-v4-1.syncthing.net/v2/": "500 Internal Server Error", "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)", "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)", "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", "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", "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" }, "discoveryMethods": 8, "goroutines": 49, "myID": "P56IOI7-MZJNU2Y-IQGDREY-DM2MGTI-MGL3BXN-PQ6W5BM-TBBZ4TJ-XZWICQ2", "pathSeparator": "/", "startTime": "2016-06-06T19:41:43.039284753+02:00", "sys": 42092792, "themes": [ "default", "dark" ], "tilde": "/Users/jb", "uptime": 2635 } GET /rest/system/upgrade Checks for a possible upgrade and returns an object describing the newest version and upgrade possibility. { "latest": "v0.10.27", "newer": false, "running": "v0.10.27+5-g36c93b7" } POST /rest/system/upgrade Perform an upgrade to the newest released version and restart. Does nothing if there is no newer version than currently running. GET /rest/system/version Returns the current Syncthing version information. { "arch": "amd64", "longVersion": "syncthing v0.10.27+3-gea8c3de (go1.4 darwin-amd64 default) jb@syno 2015-03-16 11:01:29 UTC", "os": "darwin", "version": "v0.10.27+3-gea8c3de" }
GET /rest/db/browse Returns the directory tree of the global model. Directories are always JSON objects (map/dictionary), and files are always arrays of modification time and size. The first integer is the files modification time, and the second integer is the file size. The call takes one mandatory folder parameter and two optional parameters. Optional parameter levels defines how deep within the tree we want to dwell down (0 based, defaults to unlimited depth) Optional parameter prefix defines a prefix within the tree where to start building the structure. $ curl -s http://localhost:8384/rest/db/browse?folder=default | json_pp { "directory": { "file": ["2015-04-20T22:20:45+09:00", 130940928], "subdirectory": { "another file": ["2015-04-20T22:20:45+09:00", 130940928] } }, "rootfile": ["2015-04-20T22:20:45+09:00", 130940928] } $ curl -s http://localhost:8384/rest/db/browse?folder=default&levels=0 | json_pp { "directory": {}, "rootfile": ["2015-04-20T22:20:45+09:00", 130940928] } $ curl -s http://localhost:8384/rest/db/browse?folder=default&levels=1 | json_pp { "directory": { "file": ["2015-04-20T22:20:45+09:00", 130940928], "subdirectory": {} }, "rootfile": ["2015-04-20T22:20:45+09:00", 130940928] } $ curl -s http://localhost:8384/rest/db/browse?folder=default&prefix=directory/subdirectory | json_pp { "another file": ["2015-04-20T22:20:45+09:00", 130940928] } $ curl -s http://localhost:8384/rest/db/browse?folder=default&prefix=directory&levels=0 | json_pp { "file": ["2015-04-20T22:20:45+09:00", 130940928], "subdirectory": {} } NOTE: This is an expensive call, increasing CPU and RAM usage on the device. Use sparingly. GET /rest/db/completion Returns the completion percentage (0 to 100) for a given device and folder. Takes device and folder parameters. { "completion": 0 } NOTE: This is an expensive call, increasing CPU and RAM usage on the device. Use sparingly. GET /rest/db/file Returns most data available about a given file, including version and availability. Takes folder and file parameters. { "availability": [ "I6KAH76-66SLLLB-5PFXSOA-UFJCDZC-YAOMLEK-CP2GB32-BV5RQST-3PSROAU" ], "global": { "flags": "0644", "localVersion": 3, "modified": "2015-04-20T22:20:45+09:00", "name": "util.go", "numBlocks": 1, "size": 9642, "version": [ "5407294127585413568:1" ] }, "local": { "flags": "0644", "localVersion": 4, "modified": "2015-04-20T22:20:45+09:00", "name": "util.go", "numBlocks": 1, "size": 9642, "version": [ "5407294127585413568:1" ] } } GET /rest/db/ignores Takes one parameter, folder, and returns the content of the .stignore as the ignore field. A second field, expanded, provides a list of strings which represent globbing patterns described by gobwas/glob (based on standard wildcards) that match the patterns in .stignore and all the includes. If appropriate these globs are prepended by the following modifiers: ! to negate the glob, (?i) to do case insensitive matching and (?d) to enable removing of ignored files in an otherwise empty directory. { "ignore": [ "(?i)/Backups" ], "expanded": [ "(?i)Backups", "(?i)Backups/**" ] } POST /rest/db/ignores Expects a format similar to the output of GET call, but only containing the ignore field (patterns field should be omitted). It takes one parameter, folder, and either updates the content of the .stignore echoing it back as a response, or returns an error. GET /rest/db/need Takes one mandatory parameter, folder, and returns lists of files which are needed by this device in order for it to become in sync. Furthermore takes an optional page and perpage arguments for pagination. Pagination happens, across the union of all needed files, that is - across all 3 sections of the response. For example, given the current need state is as follows: 1. progress has 15 items 2. queued has 3 items 3. rest has 12 items If you issue a query with page=1 and perpage=10, only the progress section in the response will have 10 items. If you issue a request query with page=2 and perpage=10, progress section will have the last 5 items, queued section will have all 3 items, and rest section will have first 2 items. If you issue a query for page=3 and perpage=10, you will only have the last 10 items of the rest section. In all these calls, total will be 30 to indicate the total number of available items. { # Files currently being downloaded "progress": [ { "flags": "0755", "localVersion": 6, "modified": "2015-04-20T23:06:12+09:00", "name": "ls", "size": 34640, "version": [ "5157751870738175669:1" ] } ], # Files queued to be downloaded next (as per array order) "queued": [ ... ], # Files to be downloaded after all queued files will be downloaded. # This happens when we start downloading files, and new files get added while we are downloading. "rest": [ ... ], "page": 1, "perpage": 100, "total": 2000 } NOTE: This is an expensive call, increasing CPU and RAM usage on the device. Use sparingly. POST /rest/db/override Request override of a master folder. Takes the mandatory parameter folder (folder ID). curl -X POST http://127.0.0.1:8384/rest/db/override?folder=default POST /rest/db/prio Moves the file to the top of the download queue. curl -X POST http://127.0.0.1:8384/rest/db/prio?folder=default&file=foo/bar Response contains the same output as GET /rest/db/need POST /rest/db/scan Request immediate rescan of a folder, or a specific path within a folder. Takes the mandatory parameter folder (folder ID), an optional parameter sub (path relative to the folder root) and an optional parameter next. If sub is omitted or empty, the entire folder is scanned for changes, otherwise only the given path (and children, in case it's a directory) is scanned. The next argument delays Syncthing's automated rescan interval for a given amount of seconds. Requesting scan of a path that no longer exists, but previously did, is valid and will result in Syncthing noticing the deletion of the path in question. Returns status 200 and no content upon success, or status 500 and a plain text error if an error occurred during scanning. curl -X POST http://127.0.0.1:8384/rest/db/scan?folder=default&sub=foo/bar GET /rest/db/status Returns information about the current status of a folder. Parameters: folder, the ID of a folder. { # latest version according to cluster: "globalBytes": 13173473780, "globalDeleted": 1847, "globalFiles": 42106, # what we have locally: "localBytes": 13173473780, "localDeleted": 1847, "localFiles": 42106, # which part of what we have locally is the latest cluster version: "inSyncBytes": 13173473780, "inSyncFiles": 42106, # which part of what we have locally should be fetched from the cluster: "needBytes": 0, "needFiles": 0, # various other metadata "ignorePatterns": true, "invalid": "", "state": "idle", "stateChanged": "2015-03-16T21:47:28.750853241+01:00", "version": 71989 } NOTE: This is an expensive call, increasing CPU and RAM usage on the device. Use sparingly.
GET /rest/stats/device Returns general statistics about devices. Currently, only contains the time the device was last seen. $ curl -s http://localhost:8384/rest/stats/device | json { "P56IOI7-MZJNU2Y-IQGDREY-DM2MGTI-MGL3BXN-PQ6W5BM-TBBZ4TJ-XZWICQ2": { "lastSeen" : "2015-04-18T11:21:31.3256277+01:00" } } GET /rest/stats/folder Returns general statistics about folders. Currently contains the last scan time and the last synced file. $ curl -s http://localhost:8384/rest/stats/folder | json { "folderid" : { "lastScan": "2016-06-02T13:28:01.288181412-04:00", "lastFile" : { "filename" : "file/name", "at" : "2015-04-16T22:04:18.3066971+01:00" } } }
GET /rest/svc/deviceid Verifies and formats a device ID. Accepts all currently valid formats (52 or 56 characters with or without separators, upper or lower case, with trivial substitutions). Takes one parameter, id, and returns either a valid device ID in modern format, or an error. $ curl -s http://localhost:8384/rest/svc/deviceid?id=1234 | json { "error": "device ID invalid: incorrect length" } $ curl -s http://localhost:8384/rest/svc/deviceid?id=p56ioi7m--zjnu2iq-gdr-eydm-2mgtmgl3bxnpq6w5btbbz4tjxzwicq | json { "id": "P56IOI7-MZJNU2Y-IQGDREY-DM2MGTI-MGL3BXN-PQ6W5BM-TBBZ4TJ-XZWICQ2" } GET /rest/svc/lang Returns a list of canonicalized localization codes, as picked up from the Accept-Language header sent by the browser. ["sv_sv","sv","en_us","en"] GET /rest/svc/report Returns the data sent in the anonymous usage report. { "folderMaxMiB" : 0, "platform" : "linux-amd64", "totMiB" : 0, "longVersion" : "syncthing v0.12.2 \"Beryllium Bedbug\" (go1.4.3 linux-amd64 default) unknown-user@build2.syncthing.net 2015-11-09 13:23:26 UTC", "upgradeAllowedManual" : true, "totFiles" : 3, "folderUses" : { "ignorePerms" : 0, "autoNormalize" : 0, "readonly" : 0, "ignoreDelete" : 0 }, "memoryUsageMiB" : 13, "version" : "v0.12.2", "sha256Perf" : 27.28, "numFolders" : 2, "memorySize" : 1992, "announce" : { "defaultServersIP" : 0, "otherServers" : 0, "globalEnabled" : false, "defaultServersDNS" : 1, "localEnabled" : false }, "usesRateLimit" : false, "numCPU" : 2, "uniqueID" : "", "urVersion" : 2, "rescanIntvs" : [ 60, 60 ], "numDevices" : 2, "folderMaxFiles" : 3, "relays" : { "defaultServers" : 1, "enabled" : true, "otherServers" : 0 }, "deviceUses" : { "compressMetadata" : 1, "customCertName" : 0, "staticAddr" : 1, "compressAlways" : 0, "compressNever" : 1, "introducer" : 0, "dynamicAddr" : 1 }, "upgradeAllowedAuto" : false }
The Syncthing Authors
2015, The Syncthing Authors
Personal Opportunity - Free software gives you access to billions of dollars of software at no cost. Use this software for your business, personal use or to develop a profitable skill. Access to source code provides access to a level of capabilities/information that companies protect though copyrights. Open source is a core component of the Internet and it is available to you. Leverage the billions of dollars in resources and capabilities to build a career, establish a business or change the world. The potential is endless for those who understand the opportunity.
Business Opportunity - Goldman Sachs, IBM and countless large corporations are leveraging open source to reduce costs, develop products and increase their bottom lines. Learn what these companies know about open source and how open source can give you the advantage.
Free Software provides computer programs and capabilities at no cost but more importantly, it provides the freedom to run, edit, contribute to, and share the software. The importance of free software is a matter of access, not price. Software at no cost is a benefit but ownership rights to the software and source code is far more significant.
Free Office Software - The Libre Office suite provides top desktop productivity tools for free. This includes, a word processor, spreadsheet, presentation engine, drawing and flowcharting, database and math applications. Libre Office is available for Linux or Windows.
The Free Books Library is a collection of thousands of the most popular public domain books in an online readable format. The collection includes great classical literature and more recent works where the U.S. copyright has expired. These books are yours to read and use without restrictions.
Source Code - Want to change a program or know how it works? Open Source provides the source code for its programs so that anyone can use, modify or learn how to write those programs themselves. Visit the GNU source code repositories to download the source.
Study at Harvard, Stanford or MIT - Open edX provides free online courses from Harvard, MIT, Columbia, UC Berkeley and other top Universities. Hundreds of courses for almost all major subjects and course levels. Open edx also offers some paid courses and selected certifications.
Linux Manual Pages - A man or manual page is a form of software documentation found on Linux/Unix operating systems. Topics covered include computer programs (including library and system calls), formal standards and conventions, and even abstract concepts.