-
Notifications
You must be signed in to change notification settings - Fork 85
API Documentation
The API is quite simple at the moment. There are only three API calls that can be found here: https://github.com/e-alfred/ocdownloader/blob/master/controller/lib/api.php
In detail, these are the calls (Basic Auth is always used as required by Nextcloud itself):
https://localhost/index.php/apps/ocdownloader/api/version?format=json
XHR.setRequestHeader ('OCS-APIREQUEST', 'true');
XHR.setRequestHeader ('Content-type', 'application/x-www-form-urlencoded');
XHR.setRequestHeader ('Authorization', 'Basic ' + btoa(Username + ':' + Passwd));
POST request, currently only checks if the server is active and responds with a HTTP 200 response code, AddonVersion
and your numeric version string should be sent in the body of the request. The JSON encoded response should look like this:
{
"RESULT": true
}
https://localhost/index.php/apps/ocdownloader/api/queue/get?format=json
XHR.setRequestHeader ('OCS-APIREQUEST', 'true');
XHR.setRequestHeader ('Content-type', 'application/x-www-form-urlencoded');
XHR.setRequestHeader ('Authorization', 'Basic ' + btoa(Username + ':' + Passwd));
GET request, this returns a JSON encoded response of all files downloaded by ocDownloader:
{
"ERROR": false,
"MESSAGE": null,
"QUEUE": [
{
"GID": "b9e4d3d593e143b0",
"PROGRESSVAL": 100,
"PROGRESS": {
"Message": null,
"ProgressString": "1.28 MB(100%)",
"NumSeeders": null,
"UploadLength": null,
"Ratio": null
},
"STATUS": {
"Value": "Complete",
"Seeding": false
},
"STATUSID": 0,
"SPEED": "--",
"FILENAME": "Setup_23117_x64_free.msi",
"PROTO": "HTTPS",
"ISTORRENT": false
},
{
"GID": "3cb8f8676deeff50",
"PROGRESSVAL": 100,
"PROGRESS": {
"Message": null,
"ProgressString": "1.28 MB(100%)",
"NumSeeders": null,
"UploadLength": null,
"Ratio": null
},
"STATUS": {
"Value": "Complete",
"Seeding": false
},
"STATUSID": 0,
"SPEED": "--",
"FILENAME": "Setup_23117_x86_free.msi",
"PROTO": "HTTPS",
"ISTORRENT": false
},
...
https://localhost/index.php/apps/ocdownloader/api/add?format=json
XHR.setRequestHeader ('OCS-APIREQUEST', 'true');
XHR.setRequestHeader ('Content-type', 'application/x-www-form-urlencoded');
XHR.setRequestHeader ('Authorization', 'Basic ' + btoa(Username + ':' + Passwd));
POST request, the URL that should be downloaded by ocDownloader is sent as an encoded URI in the body of the request.
The response is a JSON encoded response:
{
"ERROR": false,
"FILENAME": "com.tttdevs.stncbookmarks_1.apk"
}
{
"ERROR": true,
"MESSAGE": "InvalidURL"
}