Skip to main content

API Documentation

Complete API reference for the FeelyFeely CDN service.

Base URL

Production: https://cdn.feelyfeely.com
Development: http://localhost:5065

Authentication

The CDN uses Keycloak for authentication. Include the authorization header for protected endpoints:

Authorization: Bearer <your-jwt-token>

Image Endpoints

1. General User Assets

Retrieve and process user-uploaded assets with dynamic operations.

GET /image/<bucket>/<uuid>/<operation>/<path:s3_key>

Parameters

ParameterTypeDescriptionExample
bucketstringDigitalOcean Spaces bucket nameff.user.assets
uuidstringUnique identifier for the asset12345-67890-abcdef
operationstringImage processing operationmedium, thumbnail, etc.
s3_keystringFile path in the bucketprofile/avatar.jpg

Example Request

curl -X GET "https://cdn.feelyfeely.com/image/ff.user.assets/12345-67890/medium/profile/avatar.jpg"

Response

HTTP/1.1 200 OK
Content-Type: image/jpeg
Content-Length: 45678

[Binary image data with watermark]

2. Mobile Device Photos

Access photos from mobile devices with automatic processing.

GET /image/mobiledevice/<path:s3_key>

Parameters

ParameterTypeDescriptionExample
s3_keystringFull path to the imagedevices/iphone/photos/2024/01/photo1.jpg

Example Request

curl -X GET "https://cdn.feelyfeely.com/image/mobiledevice/devices/iphone12/medium/photos/2024/photo1.jpg"

3. Vehicle Photos

Retrieve vehicle-related images with processing.

GET /image/vehicle/<path:s3_key>

Parameters

ParameterTypeDescriptionExample
s3_keystringFull path to the vehicle imagecars/sedan/exterior/front.jpg

Example Request

curl -X GET "https://cdn.feelyfeely.com/image/vehicle/cars/toyota/camry/2024/thumbnail/exterior.jpg"

Image Operations

Available Operations

OperationDimensionsSmart CropUse Case
thumbnail150×150Profile pictures, avatars
small320×240Small previews, thumbnails
medium640×480Standard web images
large1024×768High-quality displays
wide1280×720Widescreen displays
portrait800×1200Portrait orientation
landscape1200×800Landscape orientation
square600×600Square format images
hero1920×1080Banner/hero images
full2560×1440Full HD displays
profile400×400Profile photos
slideshow3000×1687Presentation slides

Quality Settings

The CDN automatically applies optimal quality settings:

QualityDescriptionUse Case
autoService-optimizedDefault for most images
normalStandard quality1× pixel density displays
betterEnhanced qualitySmall detailed previews (~125% size)
bestNear-pristineArtwork, professional photos (~170% size)
lighterBandwidth optimizedLarge images (~80% size)
lightestMaximum compressionHigh-DPI displays (~50% size)

Image Processing Flow

1. Request Flow

graph TD
A[Client Request] --> B{Image Exists?}
B -->|Yes| C[Fetch from Spaces]
B -->|No| D[Fetch Original]
D --> E[Upload to Uploadcare]
E --> F[Apply Operations]
F --> G[Store Processed Image]
C --> H[Apply Watermark]
G --> H
H --> I[Return to Client]

2. Automatic Features

  • Smart Cropping: Preserves important image areas
  • Format Optimization: Automatic format selection (WebP, JPEG, PNG)
  • Quality Adjustment: Dynamic quality based on image content
  • Watermark Embedding: Real-time watermark application based on image brightness
  • Caching: Processed images are cached for faster subsequent access

Error Responses

HTTP Status Codes

CodeDescriptionResponse Body
200SuccessImage binary data
400Bad Request{"error": "Invalid parameters"}
403Forbidden{"error": "Access denied"}
404Not Found{"error": "Image not found"}
500Server Error{"error": "Internal server error"}

Error Examples

404 - Image Not Found

{
"status": 404,
"error": "file not found",
"message": "The requested image does not exist"
}

400 - Unsupported Operation

{
"status": 400,
"error": "unsupported operation",
"message": "The requested operation is not supported"
}

Rate Limiting

The CDN implements rate limiting to ensure service quality:

  • Requests per minute: 1000 per IP
  • Concurrent requests: 50 per IP
  • Daily bandwidth: 10GB per IP (adjustable)

Rate Limit Headers

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 995
X-RateLimit-Reset: 1640995200

Caching

Client-Side Caching

Images include appropriate cache headers:

Cache-Control: public, max-age=31536000
ETag: "abc123def456"
Last-Modified: Wed, 21 May 2024 15:30:00 GMT

CDN Caching

  • Original images: Cached indefinitely
  • Processed images: Cached for 1 year
  • Watermarked images: Generated in real-time

Advanced Usage

URL Parameters

Add query parameters for additional control:

# Force refresh (bypass cache)
/image/bucket/uuid/medium/photo.jpg?refresh=true

# Custom quality
/image/bucket/uuid/medium/photo.jpg?quality=best

# Disable watermark (if authorized)
/image/bucket/uuid/medium/photo.jpg?nowatermark=true

Batch Operations

For multiple images, use the batch endpoint:

POST /batch/images
Content-Type: application/json

{
"images": [
{
"bucket": "ff.user.assets",
"uuid": "12345",
"operation": "thumbnail",
"s3_key": "photo1.jpg"
},
{
"bucket": "ff.user.assets",
"uuid": "12346",
"operation": "medium",
"s3_key": "photo2.jpg"
}
]
}

SDK Examples

JavaScript/Node.js

const FFCDN = require('@feelyfeely/cdn-sdk');

const cdn = new FFCDN({
baseURL: 'https://cdn.feelyfeely.com',
apiKey: 'your-api-key'
});

// Get processed image URL
const imageUrl = cdn.getImageUrl({
bucket: 'ff.user.assets',
uuid: '12345',
operation: 'medium',
s3Key: 'profile/avatar.jpg'
});

// Preload multiple images
const images = await cdn.preloadImages([
{ uuid: '12345', operation: 'thumbnail', s3Key: 'photo1.jpg' },
{ uuid: '12346', operation: 'medium', s3Key: 'photo2.jpg' }
]);

Python

from feelyfeely_cdn import FFCDN

cdn = FFCDN(
base_url='https://cdn.feelyfeely.com',
api_key='your-api-key'
)

# Get image URL
image_url = cdn.get_image_url(
bucket='ff.user.assets',
uuid='12345',
operation='medium',
s3_key='profile/avatar.jpg'
)

# Download image
image_data = cdn.download_image(
uuid='12345',
operation='thumbnail',
s3_key='photo.jpg'
)

cURL Examples

# Basic image request
curl -H "Authorization: Bearer <token>" \
"https://cdn.feelyfeely.com/image/ff.user.assets/12345/medium/photo.jpg"

# Mobile device photo
curl "https://cdn.feelyfeely.com/image/mobiledevice/devices/iphone/photos/2024/photo.jpg"

# Vehicle photo with custom quality
curl "https://cdn.feelyfeely.com/image/vehicle/cars/sedan/exterior.jpg?quality=best"

Performance Considerations

Optimization Tips

  1. Choose appropriate operations: Use smaller operations for thumbnails
  2. Leverage caching: Images are cached, subsequent requests are faster
  3. Use CDN domains: Multiple domains for parallel downloads
  4. Preload critical images: Use batch endpoints for multiple images

Best Practices

  1. Progressive loading: Load thumbnails first, then higher resolutions
  2. Responsive images: Request appropriate sizes for different devices
  3. Error handling: Always handle 404s and fallback to default images
  4. Monitor usage: Track bandwidth and request patterns

Monitoring & Analytics

Metrics Available

  • Request count and response times
  • Bandwidth usage by operation
  • Cache hit/miss ratios
  • Error rates by endpoint
  • Popular image sizes and operations

Health Check

GET /health

Response:

{
"status": "healthy",
"version": "1.0.0",
"uptime": 86400,
"services": {
"mysql": "connected",
"mongodb": "connected",
"spaces": "connected",
"uploadcare": "connected"
}
}

Troubleshooting

Common Issues

  1. Slow Image Loading

    • Check if original image exists
    • Verify Uploadcare processing time
    • Monitor DigitalOcean Spaces latency
  2. Images Not Found

    • Verify bucket permissions
    • Check S3 key path
    • Confirm upload completion
  3. Quality Issues

    • Review operation settings
    • Check Uploadcare processing logs
    • Verify source image quality

Support

For API support: