Folders


Jump to API response

This endpoint allows you to create arbitrarily-deep, nested folders and list the children of a folder (similar to ls).

Reference

Authorization


You must have an account to make folders and so you must be logged in or must provide the appropriate credentials, see authentication. New folders start at your directory root unless a parent field is given.

Actions


The only supported actions at the folders endpoint are create and retrieve.

create

To create a folder, POST to this endpoint with at least the path field filled out with a valid value:

Example:

// POST https://api.plot.ly/v2/folders --> 201 Created
{
    "path": "/starts/at/root/and/ends/here"
}

Additionally, you may specify a parent field, which must be a folder. If a parent field is specified, the path field must only contain the name of the new folder to be created with the specified parent (i.e., the path field must no longer contain folders).

Example:

// POST https://api.plot.ly/v2/folders --> 201 Created
{
    "path": "new_folder",
    "parent": 84
}

Note that the parent field's value refers to an idlocal of a file with filetype fold.

detail

When accessing a detail view on a folder, a successful response will return an object that contains an array of serialized files and or folders within the target folder wrapped within the "children" field.

Example response for GET on folder:

// GET https://api.plot.ly/v2/folders/test:15
{
    "children": {
        "count": 2,
        "next": null,
        "previous": null,
        "first": "https://api-local.plot.ly/v2/folders/test:15?page=1",
        "last": "https://api-local.plot.ly/v2/folders/test:15?page=1",
        "results": [
            {
                "filename": "Stacked Bar Chart",
                "filetype": "plot",
                "fid": "test:11",
                "files_url": "https://api-local.plot.ly/v2/files/test:11"
            },
            {
                "filename": "User Traffic",
                "filetype": "plot",
                "fid": "test:9",
                "files_url": "https://api-local.plot.ly/v2/files/test:9"
            }
        ]
    }
}

home

Get all files in the home folder for a given user which are also viewable by the current user.

When given without query params, the request will assume the home folder of the request.user is desired. To view the home folder of another user, use the user query param. See query params for more details.

Example:

// Get *your* home folder
// GET https://api.plot.ly/v2/folders/home --> 200 OK
{ .. }

// Verbose version of getting your home folder (same as above)
// GET https://api.plot.ly/v2/folders/home?user=you --> 200 OK
{ .. }

// Get someone else's home folder
// GET https://api.plot.ly/v2/folders/home?user=someone_else --> 200 OK
{ .. }

shared

This returns all files shared with the requester.

Examples:

// Get all files shared with you
// GET https://api.plot.ly/v2/folders/shared --> 200 OK
{ .. }

starred

This returns all the files the requester has starred.

Example:

// Get all the files you thought were cool!
// GET https://api.plot.ly/v2/folders/starred --> 200 OK
{ .. }

trashed

This returns all the files the requester has ever deleted.

Example:

// Get all the files you decided to delete
// GET https://api.plot.ly/v2/folders/trashed --> 200 OK
{ .. }

all

This returns all the active files that the requester owns. If user query is present, only public files are returned.

Example:

// GET https://api.plot.ly/v2/folders/all --> 200 OK
{ .. }

owned themes

This returns all themes the requestor owns.

Example:

// GET https://api.plot.ly/v2/folders/themes_owned --> 200 OK
{ .. }

shared themes

This returns all themes that were shared with the requestor.

Example:

// GET https://api.plot.ly/v2/folders/themes_shared --> 200 OK
{ .. }

owned templates

This returns all templates the requestor owns.

Example:

// GET https://api.plot.ly/v2/folders/templates_owned --> 200 OK
{ .. }

shared templates

This returns all templates that were shared with the requestor.

Example:

// GET https://api.plot.ly/v2/folders/templates_shared --> 200 OK
{ .. }

query params

The following parameters may be used (they're neglected if unnecessary):

  • user Who's home folder are we looking at? see home
  • filetype Return only results matching this filetype (e.g. plot).
  • order_by Order results by given value.

user

Specify the owner of the pseudo-folder, (pseudo-folders being home, starred, trashed, etc.). That is, target user's shared folders, target user's home folder, etc. This is how you view another user's home folder.

Example:

// Get all of jonhamm's files in his home folder
// GET https://api.plot.ly/v2/folders/home?user=jonhamm --> 200 OK

filetype

Return the subset of results which have the specified filetypes. Filtering by multiple filetypes is supported.

Filetype options:

  • plot
  • grid
  • fold

Examples:

// Get your plots in the home folder (i.e., not folders or grids)
// GET https://api.plot.ly/v2/folders/home?filetype=plot --> 200 OK
{ .. }

// Get all the folders in a folder
// GET https://api.plot.ly/v2/folders/home?filetype=fold --> 200 OK
{ .. }

// Get all the plots and grids in a folder
// GET https://api.plot.ly/v2/folders/home?filetype=plot&filetype=grid
{ .. }

world_readable

Return the subset of results which have the specified value for their world_readable field. A value of true will return all public files in the folder, and a value of false will return all private files in the folder.

Examples:

// Return only public files
// GET https://api.plot.ly/v2/folders/home?world_readable=true --> 200 OK
{ .. }

// Return only private files
// GET https://api.plot.ly/v2/folders/home?world_readable=false --> 200 OK
{ .. }

order_by

Order by a field in ascending or descending order. Ascending order is assumed. To order in a descending manner, prepend the field with a - (minus sign):

?order_by=[-]<order_by-field>

Available order_by fields:

  • creation_time
  • date_modified
  • filename
  • filetype
  • views

Examples:

// Get your files ordered by date_modified, descending
// GET https://api.plot.ly/v2/folders/home?order_by=-date_modified --> 200 OK
{ .. }

// Get your files ordered alphabetically
// GET https://api.plot.ly/v2/folders/home?order_by=filename --> 200 OK
{ .. }

trash

Recursively trash a folder and its children. This action is reversible. To trash a folder, you POST at the /trash endpoint under the folder's detail url. A successful POST will receive a 200 OK response.

Examples:

// This works once
// POST https://api.plot.ly/v2/folders/greg:387/trash --> 200 OK

restore

Recursively restore a folder and its children from the Trash. To restore a folder, you POST to the /restore endpoint under the folder's detail url. A successful POST will receive a 200 OK response.

Example:

// This works once if the folder is in the Trash
// POST https://api.plot.ly/v2/folders/greg:387/restore --> 200 OK

permanent delete

Recursively, permanently delete a folder and its children. To permanently delete a folder, you DELETE to the /permanent_delete endpoint under the folder's detail url. A successful POST will receive a 200 OK response. Note that children trashed separately from this folder will also be permanently deleted by this action. This is because these children cannot be restored to their previous parent folder anyway.

Examples:

// This works once
// DELETE https://api.plot.ly/v2/folders/greg:387/permanent_delete --> 200 OK

// But fails a second time because the resource no longer exists
// DELETE https://api.plot.ly/v2/folders/greg:387/permanent_delete --> 404 Not Found

GET /v2/folders/home?user=s3792283
HTTP 200 OK
Allow: GET, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "filename": "home",
    "children": {
        "count": 3,
        "first": "https://api.plot.ly/v2/folders/home?page=1&user=s3792283",
        "previous": null,
        "next": null,
        "last": "https://api.plot.ly/v2/folders/home?page=1&user=s3792283",
        "results": [
            {
                "creation_time": "2019-03-22T04:33:26.035054Z",
                "comments": {
                    "results": [],
                    "count": 0
                },
                "parented": true,
                "embed_url": "https://plot.ly/~s3792283/3.embed",
                "fid": "s3792283:3",
                "filename": "Plot 3",
                "filetype": "plot",
                "img_url": "https://api.plot.ly/v2/files/s3792283:3/image?image_name=list-thumb",
                "image_urls": {
                    "default": "https://api.plot.ly/v2/files/s3792283:3/image?image_name=default",
                    "block-thumb": "https://api.plot.ly/v2/files/s3792283:3/image?image_name=block-thumb",
                    "list-thumb": "https://api.plot.ly/v2/files/s3792283:3/image?image_name=list-thumb"
                },
                "api_urls": {
                    "files": "https://api.plot.ly/v2/files/s3792283:3",
                    "plots": "https://api.plot.ly/v2/plots/s3792283:3",
                    "parent": "https://api.plot.ly/v2/folders/home?user=s3792283"
                },
                "owner": "s3792283",
                "parent": -1,
                "preview": "",
                "referencers": null,
                "references": null,
                "title": "",
                "views": 0,
                "web_url": "https://plot.ly/~s3792283/3/",
                "world_readable": true,
                "date_modified": "2019-03-22T04:33:26.047Z",
                "stars": {
                    "results": [],
                    "count": 0
                },
                "collaborators": {
                    "results": [],
                    "count": 0
                },
                "subfolder_count": null,
                "refresh_interval": null,
                "organize_view_url": "https://plot.ly/~s3792283/3/",
                "current_user_permission": "read",
                "is_theme": null,
                "is_template": false
            },
            {
                "creation_time": "2019-03-23T11:59:28.560559Z",
                "comments": {
                    "results": [],
                    "count": 0
                },
                "parented": true,
                "embed_url": "https://plot.ly/~s3792283/4.embed",
                "fid": "s3792283:4",
                "filename": "Neonatal Tetnas",
                "filetype": "grid",
                "img_url": "",
                "image_urls": {},
                "api_urls": {
                    "files": "https://api.plot.ly/v2/files/s3792283:4",
                    "grids": "https://api.plot.ly/v2/grids/s3792283:4",
                    "parent": "https://api.plot.ly/v2/folders/home?user=s3792283"
                },
                "owner": "s3792283",
                "parent": -1,
                "preview": {
                    "Year": [
                        "2017",
                        "2016",
                        "2015",
                        "2014",
                        "2013",
                        "2012",
                        "2011",
                        "2010",
                        "2009",
                        "2008"
                    ],
                    "Africa": [
                        "80",
                        "78",
                        "78",
                        "77",
                        "76",
                        "75",
                        "77",
                        "80",
                        "81",
                        "78"
                    ],
                    "Americas": [
                        "92",
                        "89",
                        "89",
                        "88",
                        "87",
                        "85",
                        "85",
                        "84",
                        "82",
                        "82"
                    ],
                    "South-East Asi": [
                        "90",
                        "88",
                        "88",
                        "88",
                        "87",
                        "88",
                        "88",
                        "87",
                        "87",
                        "86"
                    ],
                    "Europe": [
                        "95",
                        "90",
                        "90",
                        "90",
                        "90",
                        "90",
                        "90",
                        "90",
                        "71",
                        "71"
                    ]
                },
                "referencers": null,
                "references": null,
                "title": "",
                "views": 0,
                "web_url": "https://plot.ly/~s3792283/4/",
                "world_readable": true,
                "date_modified": "2019-03-24T02:52:20.792Z",
                "stars": {
                    "results": [],
                    "count": 0
                },
                "collaborators": {
                    "results": [],
                    "count": 0
                },
                "subfolder_count": null,
                "refresh_interval": null,
                "organize_view_url": "https://plot.ly/~s3792283/4/",
                "current_user_permission": "read",
                "is_theme": null,
                "is_template": null
            },
            {
                "creation_time": "2019-03-23T13:03:26.813517Z",
                "comments": {
                    "results": [],
                    "count": 0
                },
                "parented": true,
                "embed_url": "https://plot.ly/~s3792283/5.embed",
                "fid": "s3792283:5",
                "filename": "Neonatal Tetnas - plot",
                "filetype": "plot",
                "img_url": "https://api.plot.ly/v2/files/s3792283:5/image?image_name=list-thumb",
                "image_urls": {
                    "default": "https://api.plot.ly/v2/files/s3792283:5/image?image_name=default",
                    "block-thumb": "https://api.plot.ly/v2/files/s3792283:5/image?image_name=block-thumb",
                    "list-thumb": "https://api.plot.ly/v2/files/s3792283:5/image?image_name=list-thumb"
                },
                "api_urls": {
                    "files": "https://api.plot.ly/v2/files/s3792283:5",
                    "plots": "https://api.plot.ly/v2/plots/s3792283:5",
                    "parent": "https://api.plot.ly/v2/folders/home?user=s3792283"
                },
                "owner": "s3792283",
                "parent": -1,
                "preview": "",
                "referencers": null,
                "references": null,
                "title": "",
                "views": 0,
                "web_url": "https://plot.ly/~s3792283/5/",
                "world_readable": true,
                "date_modified": "2019-03-24T02:52:21.241Z",
                "stars": {
                    "results": [],
                    "count": 0
                },
                "collaborators": {
                    "results": [],
                    "count": 0
                },
                "subfolder_count": null,
                "refresh_interval": null,
                "organize_view_url": "https://plot.ly/~s3792283/5/",
                "current_user_permission": "read",
                "is_theme": null,
                "is_template": false
            }
        ]
    },
    "subfolder_count": 0
}