Skip to content

Commit b5ba6dc

Browse files
Updating API doc for proxy
1 parent c9cd135 commit b5ba6dc

File tree

1 file changed

+49
-43
lines changed

1 file changed

+49
-43
lines changed

docs-v2/pages/connect/api-proxy.mdx

Lines changed: 49 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ Pipedream Connect provides a proxy API that you can use to send authenticated re
1313

1414
The Connect proxy enables you to interface with any integrated API and make authenticated requests on behalf of your users, without dealing with OAuth or storing end user credentials.
1515

16-
- You send a request to the proxy and identify the end user you want to act on behalf of
17-
- The proxy sends the request to the downstream API and dynamically inserts your end user's auth credentials
18-
- The proxy returns the response from the downstream API back to you
16+
1. You send a request to the proxy and identify the end user you want to act on behalf of
17+
2. The proxy sends the request to the downstream API and dynamically inserts your end user's auth credentials
18+
3. The proxy returns the response from the downstream API back to you
1919

20-
![Connect API proxy visualization](https://res.cloudinary.com/pipedreamin/image/upload/v1738734958/pd-connect-proxy-viz_y8fzuk.png)
20+
![Connect API proxy visualization](https://res.cloudinary.com/pipedreamin/image/upload/v1738822030/pd-connect-proxy-viz_k5iksb.png)
2121

2222
<Callout type="info">
2323
Before getting started with the Connect proxy, make sure you've already gone through the [managed auth quickstart](/connect/managed-auth/quickstart) for Pipedream Connect.
@@ -28,33 +28,16 @@ Before getting started with the Connect proxy, make sure you've already gone thr
2828
You can send requests to the Connect proxy using the [Pipedream SDK](/connect/sdk) with a fetch-style interface, or by making a request to the [REST API](/rest-api/connect/proxy).
2929

3030
- A [Pipedream OAuth client](/rest-api/auth#oauth) to make authenticated requests to Pipedream's API
31-
- The [external user ID](/connect/api#external-users) for your end user (ex, `abc-123`)
3231
- Connect [environment](/connect/environments) (ex, `production` or `development`)
32+
- The [external user ID](/connect/api#external-users) for your end user (ex, `abc-123`)
3333
- The [account ID](/connect/api#accounts) for your end user's connected account (ex, `apn_1234567`)
3434

35-
### Code examples
36-
37-
**URL**
38-
39-
- The URL of the API you want to call (ex, `https://slack.com/api/chat.postMessage`)
40-
- If using the REST API, this should be an URL-safe Base64 encoded string (ex, `aHR0cHM6Ly9zbGFjay5jb20vYXBpL2NoYXQucG9zdE1lc3NhZ2U`)
35+
Refer to the full Connect API [here](/connect/api).
4136

42-
**HTTP method**
37+
### Using the Pipedream SDK (preferred)
4338

44-
- Use the HTTP method required by the downstream API
45-
46-
**Body**
39+
You can use the [Pipedream SDK](https://www.npmjs.com/package/@pipedream/sdk) to send a fetch-style request:
4740

48-
- Optionally include a body to send to the downstream API
49-
50-
**Headers**
51-
52-
- If using the REST API, include the `Authorization` header with your Pipedream OAuth access token (`Bearer {access_token}`)
53-
- Only headers that contain the prefix `x-pd-proxy` will get forwarded to the downstream API
54-
55-
<Tabs items={['Node.js', 'HTTP (cURL)']}>
56-
57-
<Tabs.Tab>
5841
```javascript
5942
import { createBackendClient } from "@pipedream/sdk/server";
6043

@@ -67,29 +50,55 @@ const pd = createBackendClient({
6750
},
6851
});
6952

70-
const url = "https://slack.com/api/chat.postMessage" // No need to Base64 encode the URL if using the SDK
71-
const params = {
72-
account_id: "{account_id}", // The account ID for your end user (ex, apn_1234567)
73-
external_user_id: "{external_user_id}", // The external user ID for your end user
74-
}
7553

7654
const resp = await pd.makeProxyRequest(
77-
url,
78-
params,
7955
{
80-
method: "POST",
81-
body: {
82-
text: "hello, world",
83-
channel: "C03NA8B4VA9"
56+
searchParams: {
57+
account_id: "{account_id}", // The account ID for your end user (ex, apn_1234567)
58+
external_user_id: "{external_user_id}", // The external user ID for your end user
59+
}
8460
},
85-
})
61+
{
62+
url: "https://slack.com/api/chat.postMessage", // Include any query params you need; no need to Base64 encode the URL if using the SDK
63+
options: {
64+
method: "POST",
65+
headers: {
66+
hello: "world!" // These get sent to the downstream API
67+
},
68+
body: {
69+
text: "hello, world",
70+
channel: "C03NA8B4VA9"
71+
},
72+
},
73+
}
74+
)
8675

8776
// Parse and return the data you need
8877
console.log(resp);
8978
```
90-
</Tabs.Tab>
9179

92-
<Tabs.Tab>
80+
### Using the REST API
81+
82+
You can also send a request to the Connect REST API with the below config:
83+
84+
**URL**
85+
86+
- The URL of the API you want to call (ex, `https://slack.com/api/chat.postMessage`)
87+
- When using the REST API, this should be an URL-safe Base64 encoded string (ex, `aHR0cHM6Ly9zbGFjay5jb20vYXBpL2NoYXQucG9zdE1lc3NhZ2U`)
88+
89+
**HTTP method**
90+
91+
- Use the HTTP method required by the downstream API
92+
93+
**Body**
94+
95+
- Optionally include a body to send to the downstream API
96+
97+
**Headers**
98+
99+
- If using the REST API, include the `Authorization` header with your Pipedream OAuth access token (`Bearer {access_token}`)
100+
- Headers that contain the prefix `x-pd-proxy` will get forwarded to the downstream API
101+
93102
```bash
94103
# First, obtain an OAuth access token
95104
curl -X POST https://api.pipedream.com/v1/oauth/token \
@@ -111,7 +120,4 @@ curl -X POST "https://api.pipedream.com/v1/connect/{your_project_id}/proxy/{url_
111120
}'
112121

113122
# Parse and return the data you need
114-
```
115-
</Tabs.Tab>
116-
117-
</Tabs>
123+
```

0 commit comments

Comments
 (0)