Skip to content

Commit 7eee056

Browse files
authored
docs(functions): improve README with installation options and examples (#1217)
1 parent 2533ba1 commit 7eee056

File tree

1 file changed

+53
-6
lines changed

1 file changed

+53
-6
lines changed

src/functions/README.md

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,68 @@
11
# Functions-py
22

33
## Installation
4-
5-
`pip3 install supabase_functions`
4+
The package can be installed using pip, uv or poetry:
5+
### Pip
6+
```bash
7+
pip install supabase_functions
8+
```
9+
### UV
10+
```bash
11+
uv add supabase_functions
12+
```
13+
### Poetry
14+
```bash
15+
poetry add supabase_functions
16+
```
617

718
## Usage
819

9-
Deploy your function as per documentation.
20+
Deploy your Edge Function following the [Supabase Functions documentation](https://supabase.com/docs/guides/functions).
21+
1022

23+
### Asynchronous Client
1124

12-
```python3
25+
```python
1326
import asyncio
1427
from supabase_functions import AsyncFunctionsClient
28+
1529
async def run_func():
16-
fc = AsyncFunctionsClient("https://<project_ref>.functions.supabase.co", {})
17-
res = await fc.invoke("payment-sheet", {"responseType": "json"})
30+
# Initialize the client with your project URL and optional headers
31+
headers = {
32+
"Authorization": "Bearer your-anon-key",
33+
# Add any other headers you might need
34+
}
35+
36+
fc = AsyncFunctionsClient("https://<project_ref>.functions.supabase.co", headers)
37+
38+
try:
39+
# Invoke your Edge Function
40+
res = await fc.invoke("payment-sheet", {
41+
"responseType": "json",
42+
"body": {"amount": 1000, "currency": "usd"}
43+
})
44+
print("Response:", res)
45+
except Exception as e:
46+
print(f"Error: {e}")
1847

1948
if __name__ == "__main__":
2049
asyncio.run(run_func())
2150
```
51+
### Synchronous Client
52+
```python
53+
from supabase_functions import SyncFunctionsClient
54+
55+
# Initialize the client
56+
headers = {"Authorization": "Bearer your-anon-key"}
57+
fc = SyncFunctionsClient("https://<project_ref>.functions.supabase.co", headers)
58+
59+
# Invoke your Edge Function
60+
try:
61+
res = fc.invoke("payment-sheet", {
62+
"responseType": "json",
63+
"body": {"amount": 1000, "currency": "usd"}
64+
})
65+
print("Response:", res)
66+
except Exception as e:
67+
print(f"Error: {e}")
68+
```

0 commit comments

Comments
 (0)