OCS Recipient API

The OCS Recipient API is a new OCS endpoint that is used by the share dialog autocomplete process, when you pick a user or group to share to.

The base URL for all calls to the share API is: <owncloud_base_url>/ocs/v1.php/apps/files_sharing/api/v1/sharees?format=json

Get Shares Recipients

Get All Shares

Get all shares from the user.

  • Syntax: /shares
  • Method: GET

Query Attributes

Attribute Type Description Required Default
format string The response format. Can be either xml or json   xml
search string The search string    
itemType string The type which is shared. Can be either file or folder Yes  
shareType integer
Any one of:
  • 0 (user)
  • 1 (group)
  • 6 (remote)
   
page integer The page number in the results to be returned   1
perPage integer The number of items per page Yes 200

Status Codes

Code Description
100 Successful
400 Failure due to invalid query parameters

Example Request Response Payloads

{
	"ocs": {
		"meta": {
			"status": "ok",
			"statuscode": 100,
			"message": "OK",
			"totalitems": "",
			"itemsperpage": ""
		},
		"data": {
			"exact": {
				"users": [],
				"groups": [],
				"remotes": []
			},
			"users": [{
				"label": "admin",
				"value": {
					"shareType": 0,
					"shareWith": "admin"
				}
			}, {
				"label": "user",
				"value": {
					"shareType": 0,
					"shareWith": "user"
				}
			}],
			"groups": [{
				"label": "admin",
				"value": {
					"shareType": 1,
					"shareWith": "admin"
				}
			}, {
				"label": "share1",
				"value": {
					"shareType": 1,
					"shareWith": "share1"
				}
			}, {
				"label": "share2",
				"value": {
					"shareType": 1,
					"shareWith": "share2"
				}
			}, {
				"label": "share3",
				"value": {
					"shareType": 1,
					"shareWith": "share3"
				}
			}, {
				"label": "share4",
				"value": {
					"shareType": 1,
					"shareWith": "share4"
				}
			}],
			"remotes": []
		}
	}
}

Code Example

Curl

#!/bin/bash

##
## Variable Declaration
##
SERVER_URI=https://your.owncloud.install.com/owncloud
API_PATH=ocs/v1.php/apps/files_sharing/api/v1

curl --user your.username:your.password "$SERVER_URI/$API_PATH/shares/115470" \
     --request DELETE 

PHP

<?php

use GuzzleHttp\Client;

require_once ('vendor/autoload.php');

// Configure the basic client
$client = new Client([
    'base_uri' => 'https://your.owncloud.install.com/owncloud/ocs/v1.php/apps/files_sharing/api/v1/',
]);

try {
    $response = $client->delete('shares/115468', [
        'auth' => ['your.username', 'your.password'],
        'debug' => true,
    ]);
    print $response->getBody()->getContents();
} catch (\GuzzleHttp\Exception\ClientException $e) {
    print $e->getMessage();
}

Ruby

require 'net/http'
require 'uri'

base_uri = 'https://your.owncloud.install.com/owncloud/ocs/v1.php/apps/files_sharing/api/v1'
uri = URI("#{base_uri}/shares/115468")

Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
  req = Net::HTTP::Delete.new uri
  req.basic_auth 'your.username', 'your.password'
  res = http.request req

  puts res.body
end

Go

package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
)

func main() {
	serverUri := "https://your.owncloud.install.com/owncloud/ocs/v1.php/apps/files_sharing/api/v1"
	username := "your.username"
	passwd := "your.password"

	client := &http.Client{}

	// Build the core request object
	req, _ := http.NewRequest(
		"DELETE",
		fmt.Sprintf("%s/%s", serverUri, "shares/115470"),
		nil,
	)
	req.SetBasicAuth(username, passwd)

	resp, err := client.Do(req)
	if err != nil {
		log.Fatal(err)
	}

	bodyText, err := ioutil.ReadAll(resp.Body)
	fmt.Println(string(bodyText))
}
All documentation licensed under the Creative Commons Attribution 3.0 Unported license.