Skip to content

Commit 9c47239

Browse files
adding info on dev rate limits
1 parent 6cd5675 commit 9c47239

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

docs-v2/pages/connect/api.mdx

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,93 @@ External User IDs are limited to 250 characters.
142142

143143
## Rate limits
144144

145+
### Pipedream rate limits
146+
145147
| API Endpoint | Rate Limit |
146148
|----------------------------|------------------------------------------------------|
147149
| `POST /tokens` | 100 requests per minute per `external_user_id` |
148150
| `GET */accounts/*`| The sum of requests across all `*/accounts/*` endpoints must not exceed 100 requests per minute. This includes requests to `/accounts`, `/apps/:app_id/accounts`, `/accounts/:account_id`, and more — any request for account metadata and credentials is counted towards this total. |
149151

150152
If you need higher rate limits, please [reach out](https://pipedream.com/support).
151153

154+
### Developer rate limits
155+
156+
- You can optionally set rate limits for your users to control their usage of the Connect API from within your application, to prevent runaway use or abuse.
157+
- Specify a time window in seconds and how many requests to allow in that window. The API will give you a `rate_limit_token` that you'll need to include in future `/connect/` requests:
158+
159+
```
160+
POST /rate_limits
161+
```
162+
163+
**Body parameters**
164+
165+
`window_size_seconds` **integer**
166+
167+
Define the size of the time window in seconds.
168+
169+
---
170+
171+
`requests_per_window` **integer**
172+
173+
Define the number of requests you want to allow per time window.
174+
175+
**Example request**
176+
177+
```bash
178+
# First, obtain an OAuth access token
179+
curl -X POST https://api.pipedream.com/v1/oauth/token \
180+
-H "Content-Type: application/json" \
181+
-d '{
182+
"grant_type": "client_credentials",
183+
"client_id": "{oauth_client_id}",
184+
"client_secret": "{oauth_client_secret}"
185+
}'
186+
187+
# The response will include an access_token. Use it in the Authorization header below.
188+
# Define the rate limit parameters
189+
190+
curl -X POST https://api.pipedream.com/v1/connect/rate_limits \
191+
-H "Content-Type: application/json" \
192+
-H "Authorization: Bearer {access_token}" \
193+
-d '{
194+
"window_size_seconds": 10,
195+
"requests_per_window": 1000
196+
}'
197+
```
198+
199+
**Example response**
200+
```json
201+
{
202+
"token": "CiKpqRdTmNwLfhzSvYxBjAkMnVbXuQrWeZyHgPtJsDcEvFpLnE"
203+
}
204+
```
205+
206+
**Example usage**
207+
208+
```
209+
# The response will include a rate limit token. Pass it as a header in your downstream requests to the Connect API.
210+
# Below is an example request that runs the "List Commits" action for the Gitlab app.
211+
212+
echo '{
213+
"external_user_id": "jverce",
214+
"id": "gitlab-list-commits",
215+
"configured_props": {
216+
"gitlab": {
217+
"authProvisionId": "apn_kVh9AoD"
218+
},
219+
"projectId": 45672541,
220+
"refName": "main"
221+
}
222+
}' > data.json
223+
224+
curl -X POST "https://api.pipedream.com/v1/connect/{your_project_id}/actions/run" \
225+
-H "Authorization: Bearer {access_token}" \
226+
-H "Content-Type: application/json" \
227+
-H "x-pd-rate-limit: {rate_limit_token}" \ # Pass the rate limit token in the header
228+
-d @data.json
229+
'
230+
```
231+
152232
## API Reference
153233

154234
### Invoke workflows

0 commit comments

Comments
 (0)