External API


The external API inside ownCloud allows third party developers to access data provided by ownCloud apps. ownCloud follows the OCS v1.7 specification (draft).


Registering Methods

Methods are registered inside the appinfo/routes.php using :phpOCP\\API


    function($urlParameters) {
      return new \OC_OCS_Result($data);

Returning Data

Once the API backend has matched your URL, your callable function as defined in $action will be executed. This method is passed as array of parameters that you defined in $url. To return data back the the client, you should return an instance of :phpOC_OCS_Result. The API backend will then use this to construct the XML or JSON response.

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 output defaults to XML. If you want to get JSON append this to the URL:


Output from the application is wrapped inside a data element:

Status codes

The status code can be any of the following numbers:

  • 100 - successful

  • 996 - server error

  • 997 - not authorized

  • 998 - not found

  • 999 - unknown error