This guide explains how to test the SmugMug API integration with your account.
-
Install required dependencies:
pip install requests-oauthlib
-
SmugMug API credentials (see setup below if you don't have them)
-
Configuration file with SmugMug credentials at
~/.smugvision/config.yaml
SmugMug uses OAuth 1.0a for authentication, which requires two sets of credentials:
- Application Credentials - Identify your app (smugVision)
- User Access Tokens - Identify which SmugMug user and what permissions
- Visit the SmugMug API Developer Page
- Log in with your SmugMug account
- Fill out the application form:
- Application Name: smugVision (or your preferred name)
- Description: AI-powered photo metadata generation
- Platform: Desktop/Web Application
- Submit and wait for approval (usually quick)
After approval, you'll receive:
- ✅ API Key (also called Consumer Key)
- ✅ API Secret (also called Consumer Secret)
The API key/secret identify your application, but you also need tokens that identify which SmugMug user is using it. This is a separate OAuth authorization step.
We've created a script to walk you through the OAuth flow:
python get_smugmug_tokens.pyThis will:
- Ask for your API key and secret (from Step 1)
- Open your browser to SmugMug's authorization page
- You authorize smugVision to access your account
- Get a 6-digit verification code
- Exchange it for access tokens
- Display your user_token and user_secret
If you prefer to do it manually:
- Create an OAuth request token using your API credentials
- Navigate to:
https://api.smugmug.com/services/oauth/1.0a/authorize?oauth_token={request_token}&Access=Full&Permissions=Modify - Authorize access and get verification code
- Exchange the verification code for access tokens
(The script in Option A does all this automatically)
After authorization, you'll have:
- ✅ user_token (OAuth Access Token)
- ✅ user_secret (OAuth Access Token Secret)
Important: You only need to do this once. Save these tokens - they don't expire unless you revoke them.
Edit your ~/.smugvision/config.yaml:
smugmug:
api_key: "YOUR_API_KEY_HERE"
api_secret: "YOUR_API_SECRET_HERE"
user_token: "YOUR_ACCESS_TOKEN_HERE"
user_secret: "YOUR_ACCESS_TOKEN_SECRET_HERE"To test with an album, you need its Album Key:
- Go to any album on your SmugMug site
- Look at the URL, it will be something like:
https://yoursite.smugmug.com/Album-Name/n-AbCdEf - The album key is the part after
n-: AbCdEf
Alternatively, you can find it in the album settings or by using the SmugMug API browser.
Once you have your credentials configured and an album key:
python test_smugmug.py <ALBUM_KEY>Example:
python test_smugmug.py AbCdEfThe test script will:
- ✅ Load configuration from
~/.smugvision/config.yaml - ✅ Authenticate with SmugMug using OAuth 1.0a
- ✅ Fetch album details (name, description, image count)
- ✅ Retrieve all images from the album (handles pagination automatically)
- ✅ Display each image's:
- Filename
- Current caption (if any)
- Current tags/keywords (if any)
- Whether it has the "smugvision" marker tag
- Other metadata (date taken, uploaded, etc.)
- ✅ Show summary statistics:
- Total images
- How many have captions
- How many have tags
- How many have been processed already
- Which images are ready for processing
======================================================================
smugVision SmugMug API Test
======================================================================
Loading configuration...
✓ Configuration loaded from: /Users/you/.smugvision/config.yaml
Connecting to SmugMug API...
✓ Successfully authenticated with SmugMug
Fetching album: AbCdEf
======================================================================
Album: My Test Album
======================================================================
Description: Test album for smugVision
Images: 25
Web URL: https://yoursite.smugmug.com/...
Fetching images from album...
✓ Retrieved 25 images
======================================================================
Images in Album
======================================================================
Image 1 of 25
----------------------------------------------------------------------
Filename: IMG_1234.jpg
Image Key: xyz123
Format: JPG
Caption: A beautiful sunset over the Golden Gate Bridge in San
Francisco, California
Tags: sunset, bridge, san francisco, california, landscape
Tag Count: 5
Processed: ✓ Yes (has 'smugvision' tag)
Date Taken: 2024-11-15T18:30:00Z
Uploaded: 2024-11-16T10:15:00Z
Web URL: https://yoursite.smugmug.com/...
Image 2 of 25
----------------------------------------------------------------------
Filename: IMG_1235.jpg
Image Key: xyz124
Format: JPG
Caption: (none)
Tags: (none)
Processed: ✗ No (missing 'smugvision' tag)
Date Taken: 2024-11-15T19:00:00Z
...
======================================================================
Summary
======================================================================
Total Images: 25
With Captions: 10 (40.0%)
With Tags: 12 (48.0%)
Already Processed: 8 (32.0%)
Ready to Process: 17 images
Images ready for processing:
- IMG_1235.jpg
- IMG_1236.jpg
- IMG_1237.jpg
- IMG_1238.jpg
- IMG_1239.jpg
... and 12 more
======================================================================
Test completed successfully!
======================================================================
Problem: Invalid credentials or OAuth tokens expired.
Solutions:
- Double-check all four credentials in config.yaml
- Make sure you're using OAuth 1.0a tokens (not OAuth 2.0)
- Verify your API key is approved and active
- Try re-generating your access tokens
Problem: Invalid album key or album not accessible.
Solutions:
- Verify the album key is correct (check the URL)
- Make sure the album belongs to your account
- Check that the album is not private/hidden from API access
- Try a different album to rule out album-specific issues
Problem: Too many API requests in a short time.
Solution:
- Wait a few minutes before trying again
- SmugMug has rate limits documented in their API docs
- The client will tell you how long to wait
Problem: No config.yaml found.
Solution:
mkdir -p ~/.smugvision
cp config.yaml.example ~/.smugvision/config.yaml
# Edit ~/.smugvision/config.yaml with your credentialsProblem: Cannot reach SmugMug API.
Solutions:
- Check your internet connection
- Verify you can access https://api.smugmug.com in a browser
- Check if a firewall is blocking the connection
- Try increasing the timeout in the config
Once the test is successful, you're ready to:
-
Process images with AI:
- Use the vision model to generate captions and tags
- Update SmugMug images with new metadata
-
Batch process entire albums:
- The client handles pagination automatically
- Can process hundreds of images
-
Integrate with face recognition:
- Identify people in photos
- Include names in captions and tags
For more details on the SmugMug API v2:
- SmugMug API Documentation
- API Tutorial
- Live API Browser (explore while logged in)
If you encounter issues:
- Check the log file:
~/.smugvision/smugvision.log - Run with DEBUG logging:
import logging logging.basicConfig(level=logging.DEBUG)
- Review SmugMug API status page
- Check GitHub issues for similar problems