Skip to content
This repository has been archived by the owner on Jul 6, 2020. It is now read-only.

API 1.2

Bernhard Posselt edited this page Sep 2, 2013 · 40 revisions

The News app 1.2 offers a RESTful API

Authentication & Basics

Because REST is stateless you have to send user and password each time you access the API. Therefore running ownCloud with SSL is highly recommended otherwise everyone in your network can log your credentials.

The base URL for all calls is:

https://user:password@yourowncloud.com/index.php/apps/news/api/v1-2/

All defined routes in the Specification are appended to this url. To access all feeds for instance use this url:

https://user:password@yourowncloud.com/index.php/apps/news/api/v1-2/feeds

Accessing API from a web application

News 1.401 implements CORS which allows web applications to access the API. An example request in jQuery would look like this:

$.ajax({
	type: 'GET',
	url: 'https://yourowncloud.com/index.php/apps/news/api/v1-2/version',
	contentType: 'application/json',
	xhrFields: {
		widthCredentials: true
	},
	success: function (response) {
		// handle success
	},
	error: function () {
		// handle errors
	},
	beforeSend: function (xhr) {
		var username = 'john';
		var password = 'doe';
		var auth = btoa(username + ':' + password);
		xhr.setRequestHeader('Authorization', 'Basic ' + auth);
	}
});

Input

In general the input parameters can be in the URL or request body, the App Framework doesnt differentiate between them.

So JSON in the request body like:

{
  "id": 3
}

will be treated the same as

/?id=3

It is recommended though that you use the following convention:

  • GET: parameters in the URL
  • POST: parameters as JSON in the request body
  • PUT: parameters as JSON in the request body
  • DELETE: parameters as JSON in the request body

Output

The output is JSON.

Specification

Clone this wiki locally