Skip to content

Commit 1eb3930

Browse files
committed
feat: add examples for basic usage, proxy API, and unify API
1 parent 6b345cf commit 1eb3930

5 files changed

Lines changed: 129 additions & 0 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Official Python SDK for the [BundleUp](https://bundleup.io) API. Connect to 100+
1111
- [Installation](#installation)
1212
- [Requirements](#requirements)
1313
- [Features](#features)
14+
- [Examples](#examples)
1415
- [Quick Start](#quick-start)
1516
- [Authentication](#authentication)
1617
- [Core Concepts](#core-concepts)
@@ -76,6 +77,15 @@ The BundleUp SDK is tested and supported on:
7677
- 🔍 **Type Hints** - Full type annotations for better IDE support
7778
- 🧪 **Tested** - Comprehensive test suite with pytest
7879

80+
## Examples
81+
82+
Runnable examples are available in the [`examples/`](./examples) directory:
83+
84+
- [`examples/basic_usage.py`](./examples/basic_usage.py) - Client setup, connections, integrations, and webhooks
85+
- [`examples/proxy_api.py`](./examples/proxy_api.py) - Proxy API GET request with a connection
86+
- [`examples/unify_api.py`](./examples/unify_api.py) - Unify Chat, Git, and PM endpoint usage
87+
- [`examples/README.md`](./examples/README.md) - Setup and execution instructions
88+
7989
## Quick Start
8090

8191
Get started with BundleUp in just a few lines of code:

examples/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# BundleUp Python SDK Examples
2+
3+
This folder contains runnable scripts that show common SDK workflows.
4+
5+
## Prerequisites
6+
7+
- Python 3.8+
8+
- `pip install -r requirements.txt` run from `bundleup-sdk-python/`
9+
- `BUNDLEUP_API_KEY` set in your environment
10+
11+
For examples that use a connected integration, also set:
12+
13+
- `BUNDLEUP_CONNECTION_ID`
14+
15+
## Run an Example
16+
17+
From `bundleup-sdk-python/`:
18+
19+
```bash
20+
python examples/basic_usage.py
21+
python examples/proxy_api.py
22+
python examples/unify_api.py
23+
```
24+
25+
## Scripts
26+
27+
- `basic_usage.py` — initialize the SDK and list connections, integrations, and webhooks
28+
- `proxy_api.py` — send a GET request through the Proxy API
29+
- `unify_api.py` — call Unify Chat, Git, and PM endpoints

examples/basic_usage.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import os
2+
3+
from bundleup import BundleUp
4+
5+
api_key = os.getenv("BUNDLEUP_API_KEY")
6+
7+
if not api_key:
8+
raise SystemExit("BUNDLEUP_API_KEY is required")
9+
10+
client = BundleUp(api_key)
11+
12+
print("BundleUp Python SDK: basic usage")
13+
14+
try:
15+
connections = client.connection.list()
16+
print(f"Connections: {len(connections)}")
17+
except Exception as error:
18+
print(f"Failed to list connections: {error}")
19+
20+
try:
21+
integrations = client.integration.list()
22+
print(f"Integrations: {len(integrations)}")
23+
except Exception as error:
24+
print(f"Failed to list integrations: {error}")
25+
26+
try:
27+
webhooks = client.webhook.list()
28+
print(f"Webhooks: {len(webhooks)}")
29+
except Exception as error:
30+
print(f"Failed to list webhooks: {error}")

examples/proxy_api.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import os
2+
3+
from bundleup import BundleUp
4+
5+
api_key = os.getenv("BUNDLEUP_API_KEY")
6+
connection_id = os.getenv("BUNDLEUP_CONNECTION_ID")
7+
path = os.getenv("BUNDLEUP_PROXY_PATH", "/users")
8+
9+
if not api_key:
10+
raise SystemExit("BUNDLEUP_API_KEY is required")
11+
12+
if not connection_id:
13+
raise SystemExit("BUNDLEUP_CONNECTION_ID is required for proxy example")
14+
15+
client = BundleUp(api_key)
16+
proxy = client.proxy(connection_id)
17+
18+
print(f"Proxy GET {path}")
19+
20+
try:
21+
response = proxy.get(path)
22+
print(f"Status: {response.status_code}")
23+
print(f"Body: {response.text}")
24+
except Exception as error:
25+
print(f"Proxy request failed: {error}")

examples/unify_api.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import os
2+
3+
from bundleup import BundleUp
4+
5+
api_key = os.getenv("BUNDLEUP_API_KEY")
6+
connection_id = os.getenv("BUNDLEUP_CONNECTION_ID")
7+
8+
if not api_key:
9+
raise SystemExit("BUNDLEUP_API_KEY is required")
10+
11+
if not connection_id:
12+
raise SystemExit("BUNDLEUP_CONNECTION_ID is required for unify example")
13+
14+
client = BundleUp(api_key)
15+
unify = client.unify(connection_id)
16+
17+
print("Unify API example")
18+
19+
try:
20+
channels = unify.chat.channels({"limit": 10})
21+
print(f"Chat channels: {len(channels.get('data', []))}")
22+
except Exception as error:
23+
print(f"Failed to fetch chat channels: {error}")
24+
25+
try:
26+
repos = unify.git.repos({"limit": 10})
27+
print(f"Git repos: {len(repos.get('data', []))}")
28+
except Exception as error:
29+
print(f"Failed to fetch git repos: {error}")
30+
31+
try:
32+
issues = unify.pm.issues({"limit": 10})
33+
print(f"PM issues: {len(issues.get('data', []))}")
34+
except Exception as error:
35+
print(f"Failed to fetch PM issues: {error}")

0 commit comments

Comments
 (0)