Browsing folders and files

Libraries and folders

Libraries within ShareBase are containers for folders and can only contain folders. Folders are containers for documents and for other folders.

Each ShareBase user gets access to their own personal library called My Library. A user can freely create folders in their personal library, create documents within those folders, and share those folders and documents with other users. Unless a user chooses to share folders and files from their personal library, no other user has access to their personal library.

A user may also be assigned rights to additional libraries configured by their site administrator. These libraries are called corporate libraries.

Retrieving a list of libraries

You can retrieve a list of libraries a user has rights to, which includes both corporate libraries shared with the user as well as the current user's personal library. To retrieve the list of libraries, issue the following GET request:

GET /api/libraries

This will return a response body like the following:

[
    {
        "LibraryId": 1,
        "LibraryName": "My Library",
        "IsPrivate" : true,
        "Links": {
          "Self": "https://app.sharebase.com/sharebaseapi/api/libraries/1",
          "Folders": "https://app.sharebase.com/sharebaseapi/api/libraries/1/folders"
        }
    },
    {
        "LibraryId": 2,
        "LibraryName": "ShareBase Public API",
        "IsPrivate" : false,
        "Links": {
          "Self": "https://app.sharebase.com/sharebaseapi/api/libraries/2",
          "Folders": "https://app.sharebase.com/sharebaseapi/api/libraries/2/folders"
        }
    }
]

A library has the following properties:

  • LibraryId: a numeric uniquely identifying the library
  • LibraryName: the name of the library
  • IsPrivate: true if the library is a private, user library; false if the library is a corporate library
  • Links
  • Self: a reference to the library itself
  • Folders: returns the list of root folders in the library

To retrieve a single library you can issue the following GET request:

GET /api/libraries/{libraryId}

Where:

  • libraryId: the ID of the library to retrieve

Retrieving an array of folders in a library

You can retrieve an array of folders at the root of a library by issuing the following GET request:

GET /api/libraries/{libraryId}/folders

Where:

  • libraryId: the ID of the library containing the folders

Alternatively, if you have a library object, you can issue a GET to the URL in library.Links.Folders.

This will return a response body like the following:

{
    "FolderId": 1,
    "FolderName": "My Documents",
    "LibraryId": 1,
    "Links": {
        "Self": "https://app.sharebase.com/sharebaseapi/api/folders/1",
        "Documents": "https://app.sharebase.com/sharebaseapi/api/folders/1/documents",
        "Folders": "https://app.sharebase.com/sharebaseapi/api/folders/1/folders",
        "Shares": "https://app.sharebase.com/sharebaseapi/api/folders/1/share"
    },
    "Embedded": {
        "Folders": [],
        "Documents": []
    }
}

A folder has the following properties:

  • FolderId: a numeric uniquely identifying the folder
  • FolderName: the name of the folder
  • Links:
  • Self: a reference to the folder itself
  • Documents: returns a list of documents within the folder
  • Folders: returns a list of folders within the folder
  • Shares: returns a list of shares for the folder
  • Embedded:
  • Documents: a list of embedded document objects that are child documents of this folder
  • Folders: a list of embedded folder objects that are child folders of this folder

To retrieve a single folder object, issue the following GET request:

GET /api/folders/{folderId}

Where:

  • folderId: the ID of the folder to retrieve

Embedding folders and documents

When issuing a request for a single folder, you can request that the response embeds the first level of child folders and documents within the resulting object. This can be used as an optimization so that you do not have to make multiple round trips. This is helpful in implementing a user interface that displays the contents of a single folder.

To request a folder and embed its child folders and documents using the embed parameter, specify either f, d or both f and d separated by a comma.

GET /api/folders/{folderId}?embed={f,d}

Where:

  • folderId: the folder you are requesting
  • embed: parameter specifying whether to embed child folders and/or documents
  • f: embed child folders
  • d: embed documents
  • f,d: embed both child folders and documents

This will return a response body like the following:

{
    "FolderId": 2,
    "FolderName": "Dev Education",
    "LibraryId": 1,
    "Links": {
        "Self": "https://app.sharebase.com/sharebaseapi/api/folders/2",
        "Documents": "https://app.sharebase.com/sharebaseapi/api/folders/2/documents",
        "Folders": "https://app.sharebase.com/sharebaseapi/api/folders/2/folders",
        "Shares": "https://app.sharebase.com/sharebaseapi/api/folders/2/share"
    },
    "Embedded": {
        "Folders": [
            {
                "FolderId": 3,
                "FolderName": "Minutes",
                "Links": {
                    "Self": "https://app.sharebase.com/sharebaseapi/api/folders/3",
                    "Documents": "https://app.sharebase.com/sharebaseapi/api/folders/3/documents",
                    "Folders": "https://app.sharebase.com/sharebaseapi/api/folders/3/folders",
                    "Shares": "https://app.sharebase.com/sharebaseapi/api/folders/3/share"
                },
                "Embedded": {
                    "Folders": [],
                    "Documents": []
                }
            }
        ],
        "Documents": [
            {
                "DocumentId": 1,
                "DocumentName": "Dev Education Agenda February 2016.docx",
                "DateModified": "2016-02-08T19:25:51.667Z",
                "Links": {
                    "Self": "https://app.sharebase.com/sharebaseapi/api/documents/1",
                    "Content": "https://app.sharebase.com/sharebaseapi/api/documents/1/content",
                    "Revisions": "https://app.sharebase.com/sharebaseapi/api/documents/1/revisions"
                }
            }
        ]
    }
}

Retrieving an array of folders in a folder

To retrieve an array of folders within a folder, issue the following GET request:

GET /api/folders/{folderId}/folders

Where:

  • folderId: the ID of the folder containing the folders

Alternatively, if you already have a folder object, you can issue a GET to the URL in folder.Links.folders

Retrieving an array of documents in a folder

To retrieve an array of documents contained in a folder, issue the following GET request:

GET /api/folders/{folderId}/documents

Where:

  • folderId: the ID of the folder containing the documents

This will return a response body like the following:

[
    {
        "DocumentId": 1,
        "DocumentName": "Dev Education Agenda February 2016.docx",
        "DateModified": "2016-02-08T19:25:51.667Z",
        "Links": {
            "Self": "https://app.sharebase.com/sharebaseapi/api/documents/1",
            "Content": "https://app.sharebase.com/sharebaseapi/api/documents/1/content",
            "Revisions": "https://app.sharebase.com/sharebaseapi/api/documents/1/revisions"
        }
    },
    {
        "DocumentId": 2,
        "DocumentName": "Dev Education Agenda March 2016.docx",
        "DateModified": "2016-03-05T19:26:01.167Z",
        "Links": {
            "Self": "https://app.sharebase.com/sharebaseapi/api/documents/2",
            "Content": "https://app.sharebase.com/sharebaseapi/api/documents/2/content",
            "Revisions": "https://app.sharebase.com/sharebaseapi/api/documents/1/revisions"
        }
    },
]

A document has the following properties:

  • DocumentId: a numeric uniquely identifying the document
  • DocumentName: the name of the document
  • DateModified: the date the document was modified
  • Links:
  • Self: a reference to the document itself
  • Content: a reference to the document content
  • Revisions: a reference to the document revision Uri