SDKs overview

Webhook Relay provides a suite of official SDKs and client libraries designed to facilitate programmatic interaction with its webhook management platform. These SDKs abstract the underlying REST API, allowing developers to integrate features such as creating forwarding rules, managing buckets, inspecting webhook traffic, and establishing secure tunnels for local development. The primary goal of these libraries is to simplify the developer experience by providing idiomatic interfaces for common programming languages, reducing the need to interact directly with HTTP requests and JSON parsing.

The SDKs are maintained by the Webhook Relay team and are generally kept up-to-date with the platform's API capabilities. They often include utilities for authentication, error handling, and data serialization, which are critical for building reliable integrations. Beyond the official offerings, a developer community contributes additional tools and libraries, extending the reach and functionality of the Webhook Relay ecosystem to other languages or specialized use cases. For a detailed understanding of the platform's capabilities, developers can consult the Webhook Relay API reference documentation.

Official SDKs by language

Webhook Relay offers official SDKs for several popular programming languages, each designed to provide a native development experience. These SDKs are the recommended method for integrating Webhook Relay functionality into applications written in these languages. They typically include features for managing tunnels, relaying messages, and interacting with the Webhook Relay API programmatically. The following table outlines the currently supported official SDKs, their respective package names, and typical installation commands.

Language Package Name Installation Command Maturity
Go github.com/webhookrelay/go-relay go get github.com/webhookrelay/go-relay Stable
Node.js @webhookrelay/node-sdk npm install @webhookrelay/node-sdk Stable
Python webhookrelay pip install webhookrelay Stable
Ruby webhookrelay-ruby gem install webhookrelay-ruby Stable

Each SDK provides a client object that can be initialized with API credentials, allowing access to various methods corresponding to API endpoints. For instance, the Node.js SDK might expose methods like createTunnel() or listBuckets(), simplifying interactions compared to crafting raw HTTP requests. Developers can find specific usage examples and detailed API documentation within the Webhook Relay official documentation portal.

Installation

Installing Webhook Relay SDKs typically follows the standard package management practices for each respective programming language. Below are detailed instructions for installing the official SDKs.

Go SDK Installation

The Go SDK is distributed via Go modules. To add it to your project, execute the following command in your terminal:

go get github.com/webhookrelay/go-relay

After installation, you can import the package in your Go source files:

import (
    "github.com/webhookrelay/go-relay/relay"
)

Node.js SDK Installation

The Node.js SDK is available on npm. Install it using either npm or yarn:

npm install @webhookrelay/node-sdk
# or
yarn add @webhookrelay/node-sdk

Then, you can require or import it in your JavaScript/TypeScript files:

const { Relay } = require('@webhookrelay/node-sdk');
// or
import { Relay } from '@webhookrelay/node-sdk';

Python SDK Installation

The Python SDK is available on PyPI. Install it using pip:

pip install webhookrelay

You can then import the library in your Python scripts:

from webhookrelay import Relay

Ruby SDK Installation

The Ruby SDK is available as a gem. Install it using the gem command:

gem install webhookrelay-ruby

Then, require it in your Ruby code:

require 'webhookrelay'

For more specific details on authentication and initial client setup, refer to the Webhook Relay API documentation for each language.

Quickstart example

This quickstart demonstrates how to use the Node.js SDK to create a webhook forwarding tunnel. The example assumes you have an active Webhook Relay account and have generated API keys. The goal is to establish a tunnel that forwards incoming webhooks to a local development server running on http://localhost:8080.

Prerequisites

Node.js Quickstart Code

First, create a file named tunnel.js:

const { Relay } = require('@webhookrelay/node-sdk');

// Replace with your actual API key and secret
const API_KEY = process.env.WEBHOOK_RELAY_KEY || 'YOUR_API_KEY';
const API_SECRET = process.env.WEBHOOK_RELAY_SECRET || 'YOUR_API_SECRET';

async function createAndRunTunnel() {
  if (API_KEY === 'YOUR_API_KEY' || API_SECRET === 'YOUR_API_SECRET') {
    console.error('Please set WEBHOOK_RELAY_KEY and WEBHOOK_RELAY_SECRET environment variables or replace placeholders.');
    process.exit(1);
  }

  const relay = new Relay({
    apiKey: API_KEY,
    apiSecret: API_SECRET,
  });

  try {
    console.log('Connecting to Webhook Relay...');
    await relay.connect();
    console.log('Connected. Starting tunnel...');

    // Create a tunnel that forwards to http://localhost:8080
    const tunnel = await relay.createTunnel({
      bucketName: 'my-dev-bucket', // Ensure this bucket exists in your account or is created via the API
      destination: 'http://localhost:8080',
      // You can also specify a name for the tunnel
      // name: 'my-local-dev-tunnel'
    });

    console.log(`Tunnel '${tunnel.name}' created successfully.`);
    console.log(`Incoming webhooks will be forwarded from: ${tunnel.url}`);
    console.log(`Forwarding to local destination: ${tunnel.destination}`);
    console.log('Press Ctrl+C to stop the tunnel.');

    // Keep the process alive while the tunnel is active
    process.on('SIGINT', async () => {
      console.log('\nStopping tunnel and disconnecting...');
      await relay.disconnect();
      console.log('Disconnected.');
      process.exit(0);
    });

  } catch (error) {
    console.error('Error creating or running tunnel:', error.message);
    // Log detailed error if available
    if (error.response && error.response.data) {
      console.error('API Error details:', error.response.data);
    }
    process.exit(1);
  }
}

createAndRunTunnel();

Running the Quickstart

  1. Save the code above as tunnel.js.
  2. Ensure you have a local server running on http://localhost:8080 (e.g., a simple Express.js app).
  3. Replace 'YOUR_API_KEY' and 'YOUR_API_SECRET' with your actual Webhook Relay credentials, or set them as environment variables.
  4. Run the script from your terminal:
node tunnel.js

Upon successful execution, the script will output the public URL assigned to your tunnel. Any HTTP requests sent to this URL will be forwarded to your local http://localhost:8080 server. This demonstrates a core capability of Webhook Relay for local development and debugging of webhook integrations. For more advanced configurations, such as custom headers, request transformations, or fan-out capabilities, consult the full Webhook Relay API documentation.

Community libraries

While Webhook Relay provides official SDKs for key languages, the open-source nature of webhook technologies often fosters community-driven development of additional tools and libraries. These community contributions can extend Webhook Relay's functionality to languages not officially supported, provide specialized integrations, or offer alternative interfaces for specific use cases. Examples might include wrappers for less common languages, command-line tools built on top of the official APIs, or integrations with specific frameworks or platforms.

Community libraries are typically hosted on platforms like GitHub and are often discovered through developer forums, blog posts, or direct searches within package repositories. When considering a community-contributed library, it is advisable to assess its maintenance status, community activity, and documentation quality. Developers should review the source code and any associated licenses, as these libraries may not carry the same level of support or guarantees as official SDKs. Resources like MDN Web Docs on Webhooks can provide general context on webhook implementation patterns, which can be useful when evaluating community tools.

For the most up-to-date information on community efforts or to contribute your own, checking the Webhook Relay community forums or GitHub repositories linked from their official documentation is recommended. These platforms often serve as central hubs for discussions and sharing of community-developed resources.