generate_image_signed_url
Generate a signed URL that can be used to generate images on-demand without making API calls. Perfect for dynamic content in emails, web pages, and more.
client.generate_image_signed_url(
template_id: str,
modifications: Optional[List[Dict[str, Any]]] = None,
format: str = "png",
thumbnail: bool = False,
nocache: bool = False
) -> str
Parameters
The template ID (e.g., ‘tpl_xxxxxxxxx’)
Array of modifications to apply to the template
Output format: ‘png’ or ‘svg’
Generate thumbnail version
Bypass cache and generate fresh image
Returns
Returns a signed URL string.
str # e.g., "https://api.bannerify.co/v1/templates/signedurl?..."
Examples
Basic Signed URL
from bannerify import BannerifyClient
client = BannerifyClient("your-api-key")
signed_url = client.generate_image_signed_url("tpl_xxxxxxxxx")
print(f"<img src='{signed_url}' alt='Generated Image' />")
With Modifications
signed_url = client.generate_image_signed_url(
"tpl_xxxxxxxxx",
modifications=[
{"name": "title", "text": "Dynamic Title"},
{"name": "subtitle", "text": "Generated on the fly"}
]
)
print(f"<img src='{signed_url}' alt='Dynamic Banner' />")
signed_url = client.generate_image_signed_url(
"tpl_xxxxxxxxx",
format="svg",
modifications=[
{"name": "title", "text": "SVG Image"}
]
)
Bypass Cache
signed_url = client.generate_image_signed_url(
"tpl_xxxxxxxxx",
nocache=True,
modifications=[
{"name": "timestamp", "text": datetime.now().strftime("%Y-%m-%d %H:%M:%S")}
]
)
Use Cases
Email Campaigns
Generate personalized images in emails:
recipients = [
{"name": "Alice", "email": "[email protected]"},
{"name": "Bob", "email": "[email protected]"},
]
for recipient in recipients:
signed_url = client.generate_image_signed_url(
"tpl_email_header",
modifications=[
{"name": "name", "text": f"Hi, {recipient['name']}!"}
]
)
html = f"<img src='{signed_url}' alt='Personalized Header' />"
# Send email with html
Dynamic Open Graph Images
Generate OG images for social media sharing:
def get_og_image_url(title: str, author: str) -> str:
return client.generate_image_signed_url(
"tpl_og_image",
modifications=[
{"name": "title", "text": title},
{"name": "author", "text": author}
]
)
# In your template
og_image = get_og_image_url("My Blog Post", "John Doe")
# <meta property="og:image" content="{og_image}" />
Real-time Analytics Badges
stats = {
"views": 1234,
"likes": 567,
"shares": 89
}
badge_url = client.generate_image_signed_url(
"tpl_stats_badge",
modifications=[
{"name": "views", "text": str(stats["views"])},
{"name": "likes", "text": str(stats["likes"])},
{"name": "shares", "text": str(stats["shares"])}
],
nocache=True
)
print(f"[](https://example.com)")
User Profile Cards
def generate_profile_card(user_id: str, name: str, avatar: str) -> str:
return client.generate_image_signed_url(
"tpl_profile_card",
modifications=[
{"name": "user_name", "text": name},
{"name": "avatar", "src": avatar},
{"name": "user_id", "text": user_id}
]
)
profile_url = generate_profile_card("123", "Jane Smith", "https://example.com/avatar.jpg")
Flask/Django Integration
from flask import render_template
@app.route('/post/<post_id>')
def blog_post(post_id):
post = get_post(post_id)
og_image = client.generate_image_signed_url(
"tpl_og_image",
modifications=[
{"name": "title", "text": post.title},
{"name": "author", "text": post.author}
]
)
return render_template('post.html', post=post, og_image=og_image)
Benefits
- No API Calls - Images are generated only when accessed
- CDN Caching - Subsequent requests are served from cache
- Security - URLs are signed and can’t be tampered with
- Flexibility - Perfect for emails, OG images, and dynamic content
- Cost Effective - Only generates when actually viewed