Nodes - justmarks/SmugMug.NET.v2 GitHub Wiki

When doing read operations with folders, albums and nodes, OAuth authentication is not required (Anonymous will work fine).

Nodes are the generic term for folders and albums. You can access nodes directly through the API or alternatively use more specific APIs for folders and albums. The 2 mechanisms are equivalent though the APIs are slightly different.

Folders

Folders are accessed by passing in a user, either the user nickname string or a User object, as well as the path to a folder. Passing in null will give you the root folder for the account. When passing in a string use the '/' between folders.

Example: To get the 'Heroes' folder located as a child of the 'SmugMug' folder, make a call as follows:

Folder folder = await api.GetFolder("cmac", "SmugMug/Heroes");

Albums

Albums are containers for image files. For a given user you can enumerate all albums in the account:

List<Album> albums = await api.GetAlbums(user);

You can also access an album directly by using it's NodeId property:

Album album = await api.GetAlbum("SJT3DX");

Nodes

Instead of working with Folders and Albums, you can use a single set of 'Node' APIs and differentiate the returned objects by using the Type property.

A given node can be retrieved by using its NodeId:

Node node = await api.GetNode("XWx8t");

From a given node, you can enumerate the children of that node, whether Folders or Albums.

List<Node> childNodes = await api.GetChildNodes(node);

Creating folders

Folders are organizational containers allowing grouping of additional folders and albums. OAuth authentication is required to create folders.

Folders can be created as a Folder object or a Node object. When creating a folder you can set additional metadata on the folder, such as Description or SortDirection, by passing in a Dictionary<string,string>.

Example: To create the 'Heroes' folder as a child of the 'SmugMug' folder, make a call as follows:

//Create as a Folder
Folder folder = await api.CreateFolder("Heroes", user, "SmugMug");
//Create as a Node
Node folderNode = await api.CreateNode(NodeType.Folder, "Heroes", "XWx8t");
//Create as a Node (with arguments)
Dictionary<string, string> optionalArguments = new Dictionary<string, string>() { { "Description", "Sample description" } };
Node folderNode = await api.CreateNode(NodeType.Folder, "Heroes", "XWx8t", optionalArguments);

Creating albums

Albums are containers of images. OAuth authentication is required to create albums.

Albums can be created as an Album object or a Node object. When creating an album you can set additional metadata on the album, such as Description or SortDirection, by passing in a Dictionary<string,string>.

Example: To create the 'SuperHeroes' album located as a child of the 'SmugMug' folder, make a call as follows:

//Create as an Album
Album album = await api.CreateAlbum("SuperHeroes", folder, null);
//Create as a Node
Node albumNode = await api.CreateNode(NodeType.Album, "SuperHeroes", "XWx8t");
//Create as a Node (with arguments)
Dictionary<string, string> optionalArguments = new Dictionary<string, string>() { { "Description", "Sample description" } };
Node albumNode = await api.CreateNode(NodeType.Album, "SuperHeroes", "XWx8t", optionalArguments);

Modifying folders, albums and nodes

OAuth authentication is required to modify folders, albums and nodes.

To modify a folder, album or Node, call the appropriate Update API and pass in the object to change as well as a Dictionary<string,string> of changes to make:

Dictionary<string, string> updates = new Dictionary<string, string>() { { "Name", "Updated name" }, { "Description", "Updated description" }, { "SortDirection", "Ascending" } };
Folder updatedFolder = await api.UpdateFolder(folder, updates);
Album updatedAlbum = await api.UpdateAlbum(album, updates);
Node updatedAlbumNode = await api.UpdateNode(albumNode, updates);

Deleting folders, albums and nodes

OAuth authentication is required to delete folders, albums and nodes.

Deleting a folder, album or Node is pretty simple by calling the appropriate Delete API:

await api.DeleteAlbum(album);
await api.DeleteFolder(folder);
await api.DeleteNode(folderNode);

Sample

Both the Folders sample and the Nodes sample are checked into the samples directory of the project.

Be sure to specify your key and secret in app.config

⚠️ **GitHub.com Fallback** ⚠️