SDKs overview

OpenGraphr offers Software Development Kits (SDKs) and client libraries designed to streamline interaction with its API for generating dynamic Open Graph images and social cards. These SDKs abstract the underlying HTTP requests, authentication, and JSON payload construction, allowing developers to integrate OpenGraphr's functionality into their applications using language-specific paradigms. The primary benefit of using an SDK over direct API calls is reduced development time and fewer potential errors in API integration, as common tasks like request signing and response handling are managed by the library itself Google API client library advantages. OpenGraphr provides official SDKs for several popular programming languages and supports community-developed libraries.

The OpenGraphr API is a RESTful interface, primarily accepting POST requests to an image generation endpoint. The request body typically includes parameters defining the image template, dynamic data to populate the template, and output format options. Responses generally contain a URL to the generated image or an error message. The SDKs simplify this process by providing functions and methods that map directly to API operations, handling serialization and deserialization of data.

Developers new to OpenGraphr should consult the OpenGraphr API reference documentation for comprehensive details on available endpoints, request parameters, and response structures. This page focuses on the installation and usage of the officially supported SDKs and notable community contributions.

Official SDKs by language

OpenGraphr maintains official SDKs for several programming languages, providing tested and supported methods for integrating its image generation capabilities. These SDKs are typically available through standard package managers for each respective language.

Language Package Name Install Command Maturity
Node.js @opengraphr/node npm install @opengraphr/node Stable
Python opengraphr-python pip install opengraphr-python Stable
Ruby opengraphr-ruby gem install opengraphr-ruby Stable
PHP opengraphr/php-client composer require opengraphr/php-client Stable
Go github.com/opengraphr/go-client go get github.com/opengraphr/go-client Stable

Each official SDK is designed to align with the conventions and best practices of its respective language ecosystem, offering an idiomatic way to interact with the OpenGraphr API. For detailed API methods and specific usage patterns, refer to the official OpenGraphr documentation.

Installation

Installation of OpenGraphr SDKs typically follows the standard procedures for package management in each programming language. Below are common installation instructions for the officially supported libraries:

  • Node.js: Use npm (Node Package Manager) to add the SDK to your project dependencies. This command should be run in your project's root directory:
    npm install @opengraphr/node
  • Python: Use pip (Python Package Installer) to install the library. It is recommended to install within a virtual environment.
    pip install opengraphr-python
  • Ruby: Use RubyGems to install the gem. This can be added to your Gemfile for Rails or other Bundler-managed projects, or installed globally.
    gem install opengraphr-ruby
  • PHP: Use Composer, the PHP dependency manager. Add the package to your composer.json file or install directly:
    composer require opengraphr/php-client
  • Go: Use the go get command to fetch and install the module. This integrates it into your Go module system.
    go get github.com/opengraphr/go-client

After installation, ensure that your environment variables, particularly your OpenGraphr API key, are securely configured. API keys are crucial for authentication and should not be hardcoded directly into source files AWS security best practices for access keys.

Quickstart example

This example demonstrates how to generate an Open Graph image using the Node.js SDK. The core process involves initializing the client with your API key, specifying a template ID, and providing dynamic data for the image generation.

const OpenGraphr = require('@opengraphr/node');

const client = new OpenGraphr({
  apiKey: process.env.OPENGRAPHR_API_KEY
});

async function generateSocialCard() {
  try {
    const response = await client.images.generate({
      templateId: 'your_template_id',
      data: {
        title: 'New Article Title',
        description: 'A summary of the article content.',
        author: 'John Doe',
        image: 'https://example.com/author-avatar.jpg'
      },
      output: {
        format: 'png',
        width: 1200,
        height: 630
      }
    });

    console.log('Generated Image URL:', response.imageUrl);
    // You can now use response.imageUrl in your meta tags
  } catch (error) {
    console.error('Error generating image:', error.message);
  }
}

generateSocialCard();

In this Node.js example:

  1. The @opengraphr/node package is imported.
  2. An instance of the OpenGraphr client is created, authenticated with an API key typically sourced from environment variables.
  3. The images.generate method is called with a templateId and a data object. The templateId refers to a pre-designed template configured within your OpenGraphr dashboard. The data object contains key-value pairs that map to dynamic fields within your chosen template.
  4. The output object specifies desired image properties like format and dimensions.
  5. Upon successful generation, the API returns an object containing the imageUrl, which is the public URL where the generated image can be accessed.
  6. Error handling is included to catch and log any issues during the API call.

Similar quickstart patterns apply to other languages, with variations in syntax for object instantiation, method calls, and error handling specific to each language's conventions. Developers should consult the OpenGraphr documentation for language-specific examples and detailed parameter descriptions.

Community libraries

While OpenGraphr provides official SDKs, the developer community sometimes contributes additional libraries or integrations. These community-maintained resources can offer specialized functionality, integrations with specific frameworks, or support for languages not officially covered. Community libraries typically emerge from developers seeking to solve particular integration challenges or enhance developer experience within their preferred ecosystems. Before relying on a community library for production applications, it is advisable to evaluate its maintenance status, documentation, and community support.

As of 2026, the OpenGraphr ecosystem is relatively new, having been founded in 2023. Consequently, the number of widely adopted community libraries is still developing. Developers interested in contributing to the OpenGraphr ecosystem or finding existing community projects can often look for repositories on platforms like GitHub or explore developer forums. These platforms serve as common hubs for open-source projects and collaborative development, allowing developers to share tools and insights related to API integrations GitHub project exploration guide.

For the most up-to-date information on community contributions, developers are encouraged to monitor the official OpenGraphr documentation and community channels, as these are often the first places where new libraries and integrations are announced or referenced.