Pipedream provides TypeScript, Python, and Java SDKs along with a REST API to interact with the Connect service. You’ll find examples using the SDKs and the REST API in multiple languages below.

REST API base URL

Pipedream Connect resources are scoped to projects, so you’ll need to pass the project’s ID as a part of the base URL or when initializing the SDK client:
https://api.pipedream.com/v1/connect/{project_id}

SDK Installation

Pipedream provides SDKs in TypeScript, Python, and Java.

TypeScript SDK

The TypeScript SDK can be used in both browser and server environments, enabling you to build full-stack applications with Pipedream Connect.

npm

To install the SDK from npm, run:
npm i --save @pipedream/sdk

<script> tag

You can also load the client-side SDK via <script> tag. You can run the latest version:
<script src="https://unpkg.com/@pipedream/sdk/dist/browser/index.js"></script>
or a specific version:
<script src="https://unpkg.com/@pipedream/sdk@1.0.6/dist/browser/index.js"></script>

Python SDK

The Python SDK is for server-side use. Install it to build backend services and APIs that interact with Pipedream Connect as part of your full-stack application.

pip

To install the SDK from pip, run:
pip install pipedream

Java SDK

The Java SDK is for server-side use in JVM-based applications. Use it to build Java backends, Spring Boot applications, and other JVM services that integrate with Pipedream Connect.

Maven

To install the SDK with Maven, add this dependency to your pom.xml:
<dependency>
    <groupId>com.pipedream</groupId>
    <artifactId>pipedream-java</artifactId>
    <version>1.0.0</version>
</dependency>

Gradle

For Gradle, add this to your build.gradle:
implementation 'com.pipedream:pipedream-java:1.0.0'

SDK Usage

TypeScript SDK (server)

Most of your interactions with the Connect API will likely happen on the server, to protect API requests and user credentials. You’ll use the SDK in your frontend to let users connect accounts. Once connected, you’ll use the SDK on the server to retrieve account info, invoke workflows on their behalf, and more. Create a Pipedream OAuth client and instantiate the SDK with your client ID and secret:
import { PipedreamClient } from "@pipedream/sdk";
 
// These secrets should be saved securely and passed to your environment
const client = new PipedreamClient({
  clientId: "{oauth_client_id}",
  clientSecret: "{oauth_client_secret}",
  projectId: "{project_id}",
  projectEnvironment: "development", // or "production"
});
 
// The client provides methods to interact with the Connect API

TypeScript SDK (browser)

You’ll primarily use the browser SDK to let your users securely connect apps from your frontend. Here, you
  1. Create a short-lived token on your server
  2. Initiate auth with that token to securely connect an account for a specific user
Here’s a Next.js example from our quickstart:
import { PipedreamClient } from "@pipedream/sdk"
// Example from our Next.js app
import { serverConnectTokenCreate } from "./server"
 
const { token, expires_at } = await serverConnectTokenCreate({
  external_user_id: externalUserId  // The end user's ID in your system
});
 
export default function Home() {
  const client = new PipedreamClient()
  
  function connectAccount() {
    client.connectAccount({
      app: appSlug, // Pass the app name slug of the app you want to integrate
      oauthAppId: appId, // For OAuth apps, pass the OAuth app ID; omit this param to use Pipedream's OAuth client or for key-based apps
      token, // The token you received from your server above
      onSuccess: ({ id: accountId }) => {
        console.log(`Account successfully connected: ${accountId}`)
      }
    })
  }
 
  return (
    <main>
      <button onClick={connectAccount}>Connect your account</button>
    </main>
  )
}

Java SDK

Like the Python SDK, the Java SDK is designed for server-side applications. Use it to securely manage user connections, retrieve account info, and interact with the Connect API from your Java backend. Create a Pipedream OAuth client and instantiate the SDK with your client ID and secret:
import com.pipedream.api.BaseClient;

// These secrets should be saved securely and passed to your environment
BaseClient client = BaseClient
    .builder()
    .clientId("{oauth_client_id}")
    .clientSecret("{oauth_client_secret}")
    .projectId("{project_id}")
    .projectEnvironment("development") // or "production"
    .build();

// The client provides methods to interact with the Connect API

Environment

Most API endpoints require an environment parameter. This lets you specify the environment (production or development) where resources will live in your project. Always set the environment when you create the SDK client:
import { PipedreamClient } from "@pipedream/sdk";
 
const client = new PipedreamClient({
  clientId: "your-oauth-client-id",
  clientSecret: "your-oauth-client-secret",
  projectId: "your-project-id",
  projectEnvironment: "development" // change to "production" for production environment
});
or pass the X-PD-Environment header in HTTP requests:
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/tokens \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: development" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "your-external-user-id"
  }'

External users

When you use the Connect API, you’ll pass an external_user_id parameter when initiating account connections and retrieving account info. This is your user’s ID, in your system — whatever you use to uniquely identify them. Pipedream associates this ID with user accounts, so you can retrieve account info for a specific user, and invoke actions on their behalf. External User IDs are limited to 250 characters. Read more about external users.