<>

API Documentation

Getting Started

OGenerate provides a simple API to generate Open Graph images for your web pages. To get started, you'll need an API key which you can obtain from your dashboard after signing up.

Base URL

All API requests should be made to:

Base URL

Base URL

Authentication

All API requests require an API key which should be included in the URL path.

Authentication

Authentication

Endpoints

Generate an Open Graph image for a specific URL.

HTTP Request

HTTP Request

Parameters

ParameterTypeRequiredDescription
apiKeyQuery ParameterYesYour API key for authentication
urlQuery ParameterYesThe URL to generate an OG image for
widthQuery ParameterNoWidth of the screenshot in pixels (default: 1200)
heightQuery ParameterNoHeight of the screenshot in pixels (default: 630)
themeQuery ParameterNoTheme for the screenshot: "light" or "dark" (default: "light")

Example Request

Basic Request

Basic Request

Advanced Examples

Custom Dimensions

Custom Dimensions

Dark Theme

Dark Theme

Full Example with All Parameters

Full Example with All Parameters

Example Usage in HTML

index.html

index.html

Response

The API returns a PNG image if successful. In case of an error, it returns a JSON response with an error message.

Integration Examples

Next.js

This approach uses Next.js App Router with a custom API route that integrates with OGenerate. It provides automatic fallback to a custom image generator for pages that you want to handle yourself.

Step 1: Set up middleware to track current path

src/middleware.ts

src/middleware.ts

Step 2: Configure Open Graph metadata in your layout

src/app/layout.tsx

src/app/layout.tsx

Step 3: Create the OG image API route

src/app/api/og/route.tsx

src/app/api/og/route.tsx

Step 4: Environment Variables

Add these environment variables to your `.env.local` file:

.env.local

.env.local

WordPress

There are two ways to integrate OGenerate with WordPress: using an SEO plugin or manually adding the code to your theme.

Method 1: Using an SEO Plugin

Add this code to your theme's functions.php file to integrate with Yoast SEO or Rank Math

functions.php

functions.php

Security Tip: Add your API key to wp-config.php

wp-config.php

wp-config.php

Method 2: Manual Integration

Add this code to your theme's header.php file within the <head> section

header.php

header.php

Shopify

Integrate OGenerate into your Shopify store by editing your theme.

Edit Your Theme's Layout File

  1. From your Shopify admin, go to Online Store > Themes
  2. Click Actions > Edit code for your active theme
  3. Under the Layout directory, open theme.liquid
  4. Find the <head> section and add the code below

theme.liquid

theme.liquid

Store Your API Key Securely

For better security, use Shopify theme settings to store your API key

1. Create settings schema in your config file:

config/settings_schema.json

config/settings_schema.json

2. Update your Liquid code to use the theme setting:

theme.liquid

theme.liquid

Best Practices

  • Always URL encode the url parameter to ensure proper handling
  • Consider caching the generated images on your end for better performance
  • Test your OpenGraph images with the Facebook Sharing Debugger and Twitter Card Validator
  • Ensure your platform is configured to use the proper meta tags

Error Codes

Error CodeMessage
400Missing URL or API key or Insufficient credits
401Invalid API key
404Invalid URL or Domain not found
500Internal server error

Say Goodbye to og:image Headaches

Don't let the challenges of Open Graph image creation slow you down. With OGenerate, you can focus on growing your business while we take care of your social media presence.