Getting started overview

This guide provides a focused walkthrough for developers to get started with Bruzu's Dynamic Image API. It covers the essential steps from account creation and API key retrieval to making a successful first API request. Bruzu specializes in generating images and videos dynamically from templates, supporting various use cases such as personalized marketing and e-commerce product imagery. The API uses a template-based approach, where users design image templates within the Bruzu dashboard and then populate them with data via API calls (Bruzu API reference).

The process typically involves:

  1. Account Creation: Registering for a Bruzu account.
  2. API Key Generation: Obtaining the necessary API credentials.
  3. Template Design: Creating or selecting an image template.
  4. First API Call: Sending a request to generate an image based on the template and provided data.

Bruzu offers SDKs for several programming languages, including Node.js and Python, to simplify API interactions (Bruzu documentation for SDKs).

Quick Reference Steps

Step What to Do Where
1. Sign Up Create a new Bruzu account. Bruzu homepage
2. Get API Keys Locate your API Key and Secret. Bruzu Dashboard > Settings > API Keys
3. Create Template Design an image template or use an existing one. Bruzu Dashboard > Templates
4. Make Request Send a POST request to the Dynamic Image API endpoint. Your preferred development environment
5. Verify Output Check the generated image URL. Browser or image viewer

Create an account and get keys

To begin using Bruzu, you must first create an account. Bruzu offers a free tier that includes 50 API calls per month, which is sufficient for initial testing and development (Bruzu pricing details).

1. Sign Up for a Bruzu Account

Navigate to the Bruzu website and complete the registration process. This typically involves providing an email address and creating a password. After signing up, you may need to verify your email address to activate your account.

2. Locate Your API Key and Secret

Once logged into your Bruzu dashboard:

  1. Click on your profile icon or navigate to 'Settings'.
  2. Look for a section labeled 'API Keys' or 'Developer Settings'.
  3. Here you will find your unique API Key and API Secret. These credentials are required for authenticating your API requests. Treat your API Secret as sensitive information, similar to a password. It should not be exposed in client-side code or publicly accessible repositories.

Bruzu's authentication mechanism typically involves including these keys in the headers or body of your API requests (Bruzu authentication guide).

Your first request

Before making your first API request, you need to have an image template ready in your Bruzu dashboard. This template defines the layout and design of the image you want to generate, with placeholders for dynamic content.

1. Create an Image Template

  1. In your Bruzu dashboard, go to the 'Templates' section.
  2. Click 'Create New Template' or select an existing example template.
  3. Use the online editor to design your image. Add text layers, image layers, and other elements. For dynamic content, define variables (e.g., {{title}}, {{username}}) that you will populate via the API.
  4. Save your template. Note its unique Template ID, which you will use in your API call.

2. Choose Your SDK or Make a Direct HTTP Request

Bruzu provides SDKs for several languages, simplifying API interactions. For this guide, we'll show examples for Node.js and Python, and a cURL example for direct HTTP requests. The core concept is sending a POST request to the Bruzu Dynamic Image API endpoint with your API credentials and data to populate the template.

Example: Node.js SDK

First, install the Bruzu Node.js SDK:

npm install bruzu-sdk

Then, use the following code:

const Bruzu = require('bruzu-sdk');

const bruzu = new Bruzu({
  apiKey: 'YOUR_API_KEY',
  apiSecret: 'YOUR_API_SECRET'
});

async function generateImage() {
  try {
    const result = await bruzu.template.render('YOUR_TEMPLATE_ID', {
      title: 'Welcome to Bruzu!',
      username: 'Developer'
    });
    console.log('Generated Image URL:', result.url);
  } catch (error) {
    console.error('Error generating image:', error.message);
  }
}

generateImage();

Replace 'YOUR_API_KEY', 'YOUR_API_SECRET', and 'YOUR_TEMPLATE_ID' with your actual credentials and template ID.

Example: Python SDK

First, install the Bruzu Python SDK:

pip install bruzu-python-sdk

Then, use the following code:

from bruzu import Bruzu

bruzu = Bruzu(
    api_key='YOUR_API_KEY',
    api_secret='YOUR_API_SECRET'
)

def generate_image():
    try:
        result = bruzu.template.render(
            'YOUR_TEMPLATE_ID',
            {
                'title': 'Hello from Python!',
                'username': 'PythonDev'
            }
        )
        print(f'Generated Image URL: {result["url"]}')
    except Exception as e:
        print(f'Error generating image: {e}')

generate_image()

Replace placeholders with your actual credentials and template ID.

Example: cURL (Direct HTTP Request)
curl -X POST \ 
  https://api.bruzu.com/v1/template/render \ 
  -H 'Content-Type: application/json' \ 
  -H 'X-Bruzu-Api-Key: YOUR_API_KEY' \ 
  -H 'X-Bruzu-Api-Secret: YOUR_API_SECRET' \ 
  -d '{ 
        "template_id": "YOUR_TEMPLATE_ID", 
        "data": { 
          "title": "Direct API Call", 
          "username": "cURL User" 
        } 
      }'

Ensure you replace YOUR_API_KEY, YOUR_API_SECRET, and YOUR_TEMPLATE_ID with your actual values. The response will include a URL to the generated image.

Common next steps

After successfully generating your first image, consider these common next steps:

  • Explore More Template Features: Experiment with different layers, fonts, and dynamic elements within the Bruzu template editor. Bruzu supports various data types for template population, including images and rich text (Bruzu template rendering options).
  • Integrate into Applications: Embed the image generation process into your existing applications. For instance, automate the creation of social media posts, personalized email banners, or e-commerce product variations.
  • Webhooks: Configure webhooks to receive notifications when images are finished processing or other events occur. This can be useful for asynchronous operations (Bruzu webhook documentation).
  • Error Handling: Implement robust error handling in your code to manage API rate limits, invalid template IDs, or incorrect data payloads. Review the Bruzu API documentation for specific error codes and their meanings.
  • Video API: If your use case extends beyond static images, explore Bruzu's Video API capabilities for dynamic video generation. This follows a similar template-based approach (Bruzu Video API guide).
  • Performance Optimization: For high-volume use cases, consider caching generated images or optimizing your template designs to reduce rendering times.
  • Secure API Keys: Ensure your API keys are managed securely, especially in production environments. Best practices include using environment variables or dedicated secret management services, as recommended by general API security guidelines (Microsoft API Management security best practices).

Troubleshooting the first call

If your first API call to Bruzu fails, consider the following common issues and troubleshooting steps:

  • Incorrect API Key/Secret: Double-check that you have copied your API Key and API Secret correctly from your Bruzu dashboard. Ensure there are no leading or trailing spaces. Authentication errors are often indicated by 401 Unauthorized responses.
  • Invalid Template ID: Verify that the template_id you are using in your API request exactly matches a valid template in your Bruzu account. A common error is using a template ID from a different account or a mistyped ID. This might result in a 404 Not Found or 400 Bad Request.
  • Missing or Mismatched Data: Ensure that the data payload in your request correctly maps to the variables defined in your Bruzu template. If a required variable is missing or has an incorrect data type, the image generation might fail or produce unexpected results.
  • Content-Type Header: For direct HTTP requests, confirm that the Content-Type: application/json header is correctly set if you are sending a JSON payload.
  • Rate Limiting: If you are making many requests quickly, you might hit rate limits, especially on the free tier. Check the API response for 429 Too Many Requests errors. Implement exponential backoff for retries if necessary.
  • Network Issues: Verify your internet connection and ensure that there are no firewall rules blocking outgoing requests to api.bruzu.com.
  • SDK Configuration: If using an SDK, ensure it is installed correctly and configured with the correct API key and secret. Consult the specific SDK's documentation for any language-specific nuances (Bruzu SDK documentation).
  • Bruzu Dashboard Status: Check the Bruzu dashboard or their status page (if available) for any ongoing service disruptions.
  • Examine API Response: Always inspect the full API response, including status codes and error messages. Bruzu's API typically provides descriptive error messages in the response body that can guide your troubleshooting.