Skip to content

Commit 6af0f2d

Browse files
committed
feat: added pythong sdk
1 parent 97e66e8 commit 6af0f2d

File tree

16 files changed

+2372
-2
lines changed

16 files changed

+2372
-2
lines changed

pnpm-lock.yaml

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python/.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
PIPEDREAM_CLIENT_ID=j80qqQFJXA9dbmeEVaTCKxTWzAqFh-1XEuHAszA_KB0
2+
PIPEDREAM_CLIENT_SECRET=UAHVdpsb9l-d6zDvBvuGkkMDS4Upc3TKzTmNIwt9b7o
3+
PIPEDREAM_PROJECT_ID=proj_nasq6ee
4+
PIPEDREAM_PROJECT_ENVIRONMENT=development

python/.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
__pycache__/
2+
*.pyc
3+
*.pyo
4+
*.pyd
5+
*.pyw
6+
*.pyz
7+
*.pywz
8+
*.pyzw
9+
*.pyzwz
10+
*.egg-info/

python/CHANGELOG.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Changelog
2+
3+
All notable changes to the Pipedream Python SDK will be documented in this file.
4+
5+
## [1.0.0] - 2024-01-01
6+
7+
### Added
8+
- Initial release of the Pipedream Python SDK
9+
- Complete Python implementation of the Pipedream Connect API
10+
- Support for OAuth and access token authentication
11+
- Account management (CRUD operations)
12+
- App discovery and metadata retrieval
13+
- Component management (triggers and actions)
14+
- Connect token creation for user authentication
15+
- Action execution capabilities
16+
- Trigger deployment and management
17+
- Workflow invocation with various authentication types
18+
- Proxy API for making authenticated requests on behalf of users
19+
- Comprehensive type definitions with dataclasses
20+
- Full test suite and examples
21+
- Zero external dependencies (uses only Python standard library)
22+
23+
### Features
24+
- **Authentication**: OAuth2 and access token support with automatic token refresh
25+
- **Account Management**: Create, read, update, delete operations for connected accounts
26+
- **App Discovery**: Search and retrieve app metadata and capabilities
27+
- **Component Operations**: Configure, reload, and execute components
28+
- **Trigger Management**: Deploy, update, delete, and monitor triggers
29+
- **Workflow Invocation**: Call workflows with different authentication methods
30+
- **Proxy Requests**: Make API calls on behalf of users through Pipedream's proxy
31+
- **Type Safety**: Comprehensive type definitions for all API operations
32+
- **Error Handling**: Proper exception handling for API errors
33+
- **Pagination**: Support for paginated API responses
34+
35+
### Technical Details
36+
- Python 3.8+ compatibility
37+
- Uses only standard library modules (urllib, json, time, etc.)
38+
- Dataclass-based type definitions for better IDE support
39+
- Enum-based constants for better type safety
40+
- Comprehensive docstrings and examples

python/README.md

Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
# Pipedream Python SDK
2+
3+
A Python client library for the [Pipedream Connect API](https://pipedream.com/docs/connect).
4+
5+
## Installation
6+
7+
```bash
8+
pip install pipedream-sdk
9+
```
10+
11+
## Quick Start
12+
13+
### Using OAuth Credentials
14+
15+
```python
16+
from pipedream_sdk import create_client, OAuthCredentials
17+
18+
# Create client with OAuth credentials
19+
credentials = OAuthCredentials(
20+
client_id="your_client_id",
21+
client_secret="your_client_secret"
22+
)
23+
24+
client = create_client(
25+
project_id="your_project_id",
26+
credentials=credentials,
27+
environment="development" # or "production"
28+
)
29+
30+
# Create a Connect token for user authentication
31+
token_response = client.create_connect_token({
32+
"external_user_id": "user123",
33+
"success_redirect_uri": "https://yourapp.com/success",
34+
"error_redirect_uri": "https://yourapp.com/error"
35+
})
36+
37+
print(f"Connect URL: {token_response.connect_link_url}")
38+
```
39+
40+
### Using Access Token
41+
42+
```python
43+
from pipedream_sdk import create_client, AccessTokenCredentials
44+
45+
# Create client with access token
46+
credentials = AccessTokenCredentials(access_token="your_access_token")
47+
48+
client = create_client(
49+
project_id="your_project_id",
50+
credentials=credentials
51+
)
52+
```
53+
54+
## Core Features
55+
56+
### Account Management
57+
58+
```python
59+
# Get all connected accounts
60+
accounts = client.get_accounts()
61+
62+
# Get accounts for a specific user
63+
accounts = client.get_accounts({
64+
"external_user_id": "user123",
65+
"include_credentials": True
66+
})
67+
68+
# Get a specific account
69+
account = client.get_account_by_id("account_id", {
70+
"include_credentials": True
71+
})
72+
73+
# Delete an account
74+
client.delete_account("account_id")
75+
76+
# Delete all accounts for an external user
77+
client.delete_external_user("user123")
78+
```
79+
80+
### App Discovery
81+
82+
```python
83+
# Get all available apps
84+
apps = client.get_apps()
85+
86+
# Search for apps
87+
apps = client.get_apps({
88+
"q": "slack",
89+
"has_actions": True,
90+
"limit": 10
91+
})
92+
93+
# Get a specific app
94+
app = client.get_app("slack")
95+
```
96+
97+
### Component Management
98+
99+
```python
100+
from pipedream_sdk.types import ComponentType
101+
102+
# Get all components
103+
components = client.get_components()
104+
105+
# Get components for a specific app
106+
components = client.get_components({
107+
"app": "slack",
108+
"component_type": ComponentType.ACTION
109+
})
110+
111+
# Get a specific component
112+
component = client.get_component({"key": "slack-send-message"})
113+
114+
# Configure a component prop
115+
config_response = client.configure_component({
116+
"external_user_id": "user123",
117+
"component_id": "slack-send-message",
118+
"prop_name": "channel",
119+
"configured_props": {"text": "Hello world"}
120+
})
121+
```
122+
123+
### Running Actions
124+
125+
```python
126+
# Run an action
127+
result = client.run_action({
128+
"external_user_id": "user123",
129+
"action_id": "slack-send-message",
130+
"configured_props": {
131+
"channel": "#general",
132+
"text": "Hello from Pipedream!"
133+
}
134+
})
135+
136+
print(f"Action result: {result.ret}")
137+
```
138+
139+
### Trigger Management
140+
141+
```python
142+
# Deploy a trigger
143+
trigger = client.deploy_trigger({
144+
"external_user_id": "user123",
145+
"trigger_id": "github-new-commit",
146+
"configured_props": {
147+
"repo": "username/repo"
148+
},
149+
"webhook_url": "https://yourapp.com/webhook"
150+
})
151+
152+
# Get deployed triggers
153+
triggers = client.get_triggers({
154+
"external_user_id": "user123"
155+
})
156+
157+
# Update a trigger
158+
client.update_trigger({
159+
"id": trigger.id,
160+
"external_user_id": "user123",
161+
"active": False
162+
})
163+
164+
# Get trigger events
165+
events = client.get_trigger_events({
166+
"id": trigger.id,
167+
"external_user_id": "user123",
168+
"limit": 10
169+
})
170+
171+
# Delete a trigger
172+
client.delete_trigger({
173+
"id": trigger.id,
174+
"external_user_id": "user123"
175+
})
176+
```
177+
178+
### Workflow Invocation
179+
180+
```python
181+
from pipedream_sdk.types import HTTPAuthType
182+
183+
# Invoke a workflow
184+
response = client.invoke_workflow(
185+
"https://your-workflow-url.m.pipedream.net",
186+
data={"message": "Hello"},
187+
auth_type=HTTPAuthType.NONE
188+
)
189+
190+
# Invoke a workflow for a specific user
191+
response = client.invoke_workflow_for_external_user(
192+
"https://your-workflow-url.m.pipedream.net",
193+
external_user_id="user123",
194+
data={"message": "Hello"}
195+
)
196+
```
197+
198+
### Proxy API
199+
200+
```python
201+
# Make a proxy request on behalf of a user
202+
response = client.make_proxy_request(
203+
proxy_opts={
204+
"search_params": {
205+
"external_user_id": "user123",
206+
"account_id": "account_456"
207+
}
208+
},
209+
target_request={
210+
"url": "https://api.github.com/user/repos",
211+
"options": {
212+
"method": "GET",
213+
"headers": {"Accept": "application/json"}
214+
}
215+
}
216+
)
217+
```
218+
219+
## Error Handling
220+
221+
The SDK raises exceptions for API errors:
222+
223+
```python
224+
try:
225+
account = client.get_account_by_id("invalid_id")
226+
except Exception as e:
227+
print(f"API Error: {e}")
228+
```
229+
230+
## Development
231+
232+
### Setup
233+
234+
```bash
235+
git clone https://github.com/PipedreamHQ/pipedream.git
236+
cd pipedream/python-sdk
237+
pip install -e .
238+
pip install -r requirements-dev.txt
239+
```
240+
241+
### Testing
242+
243+
```bash
244+
pytest
245+
```
246+
247+
### Code Formatting
248+
249+
```bash
250+
black pipedream_sdk/
251+
flake8 pipedream_sdk/
252+
mypy pipedream_sdk/
253+
```
254+
255+
## Requirements
256+
257+
- Python 3.8+
258+
- No external dependencies (uses only Python standard library)
259+
260+
## Documentation
261+
262+
For detailed API documentation, visit [Pipedream Connect Docs](https://pipedream.com/docs/connect).
263+
264+
## License
265+
266+
See the main Pipedream repository for license information.

0 commit comments

Comments
 (0)