Skip to content

Getting Started

For API Users

Follow these steps to start making API calls with PipeGate:

Subscribe to API

You can discover PipeGate-enabled APIs on the PipeGate Hub. Subscribe to an API to get access to its endpoints.

For other ways to subscribe to the provider, head to the detailed section of the payment method, API provider supports from the section below.

Install SDK

Terminal
npm install pipegate-sdk

The SDK provides all necessary tools for interacting with PipeGate-enabled APIs, including payment channel management and request signing.

Initialize Client

import { ClientInterceptor } from "pipegate-sdk";
const pipeGate = new ClientInterceptor();

This creates a new PipeGate client instance and initializes connection to the blockchain. Make sure you have your wallet's private key PRIVATE_KEY in the environment variables.

Configuring Client

After subscribing to an API Provider, you can simply configure your client according to the payment method you have subscribed with

PipeGate supports three payment methods:

  1. Superfluid Streams
    • Perfect for subscription-based APIs
    • Continuous payment streams
    • Real-time value transfer
  2. One-Time Payments
    • Suitable for occasional API usage
    • Pay per single request
    • No channel setup needed
  3. Payment Channels [ Beta ]

    • Best for frequent API calls
    • Pay as you go with no gas fees per request
    • Deposit funds once, use multiple times

Make Your First API Call

import axios from "axios";
 
const api = axios.create({
  baseURL: "https://api.example.com",
});
 
// Example: Payment Channels
api.interceptors.request.use(
  pipeGate.createPaymentChannelRequestInterceptor(channelId).request
);
 
const response = await api.get("/endpoint");

For API Providers

Setting up PipeGate as an API provider involves multiple steps based on your chosen payment method:

Install Pipegate crates

Terminal
cargo add pipegate

Or

[dependencies]
pipegate = { version = "0.5.0" }

This adds the PipeGate middleware and required dependencies to your Rust project.

Register as Provider ( Optional )

This steps is only required if you want to list your API on the PipeGate Hub. You can skip this step if you are offering your own interface for users to subscribe

Prepare a POST request with the details of your API and the endpoint you support along with the payment information:

Terminal
curl -X POST "https://app.pipegate.xyz/api" \
-H "Content-Type: application/json" \
-d '{
  "name": "My Awesome API",
  "shortDescription": "Short description of my API",  // per month (STREAM) or per call (ONE_TIME)
  "description": "A detailed description of my API",
  "pricing": 1, // per month (STREAM) or per call (ONE_TIME)
  "baseUrl": "https://api.example.com",
  "endpoints": [
    {
      "method": "GET",
      "path": "/"
    }
  ],
  "network": "BASE_MAINNET",
  "token": "0x036CbD53842c5426634e7929541eC2318f3dCF7e", // USDC token address
  "paymentType": "ONE_TIME", // STREAM, ONE_TIME
  "providerId": "0x...WALLET_ADDRESf"
}'

This registers you as a provider on the PipeGate Hub and allows users to discover and subscribe to your API.

Choose Integration Method

Based on your API's needs, implement one or more payment methods:

  1. Superfluid Stream Handler
    use pipegate::middleware::stream_payment::StreamMiddlewareLayer
     
    let app = Router::new()
        .route("/", get(root))
        .layer(StreamMiddlewareLayer::new(config, state));
  2. One-Time Payment Setup
    use pipegate::middleware::one_time_payment::OnetimePaymentMiddlewareLayer
     
    let app = Router::new()
        .route("/", get(root))
        .layer(OnetimePaymentMiddlewareLayer::new(config));
  3. Payment Channel Integration
    use pipegate::middleware::payment_channel::PaymentChannelMiddlewareLayer
     
    let app = Router::new()
        .route("/", get(root))
        .layer(PaymentChannelMiddlewareLayer::new(state, config));

Setup management ( Soon )

Pipegate will offer a management interface for you to monitor and manage your API subscriptions and payments. Stay tuned for updates on this feature.

For now, Learn how to manage payment channels, including:

  • Monitoring channel states
  • Processing withdrawals
  • Handling channel closures

Current Deployments ( Only required for Payment Channels )

Next Steps

For API Consumers

For API Providers