Simple SmugMug C# Wrapper

posted 5/13/2008 12:00:00 AM by Mark Burnham

One of our clients is using the SmugMug API which changed recently to require keys for retrieving images. This _simple_ library and sample code is intended to show how to use the new API.

The wrapper library uses the SmugMug API version 1.2.0.

Download sample code and library HERE.

The API recently changed significantly to require keys to be passed for most queries. To retrieve an image, you used to be able to do this:

http://SmugMugNickName.smugmug.com/photos/PHOTOID-420x300.jpg" alt="Your nice photo!" />

Now, you have to pass the image’s key like this:

http://SmugMugNickName.smugmug.com/photos/PHOTOID_PHOTOKEY-420x300.jpg" alt="Your nice photo!" />

You can read more about this change on the SmugMug forum here:

http://www.dgrin.com/showthread.php?t=83916

You can get a SmugMug API key here:

http://www.smugmug.com/hack/apikeys

To use this library and sample code, just add your SmugMug API key and SmugMugNickName to the web.config like this:

To get started with the SmugMug API, you can just try loading URL’s in a browser, and cutting and pasting. This is a good way to see what kind of data the API returns. For example, to get a SmugMug SessionID (required for all functions), type this:

http://api.smugmug.com/hack/rest/1.2.0/?APIKey=Your_API_Key&method=smugmug.login.anonymously

The response will look like this:

You then use the Session ID for all subsequent transactions, such as, (for example) finding all the galleries for a given NickName:

http://api.smugmug.com/hack/rest/1.2.0/?APIKey=Your_API_Key&method=smugmug.albums.get &NickName=SmugMugNickName&SessionID=SessionID_that_you_just_got_from_last_step

NOTE: The SmugMug API refers to albums when, as far as I can tell, it “really means” SmugMug galleries.

Our Work