Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 53 additions & 6 deletions src/functions/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,68 @@
# Functions-py

## Installation

`pip3 install supabase_functions`
The package can be installed using pip, uv or poetry:
### Pip
```bash
pip install supabase_functions
```
### UV
```bash
uv add supabase_functions
```
### Poetry
```bash
poetry add supabase_functions
```

## Usage

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


### Asynchronous Client

```python3
```python
import asyncio
from supabase_functions import AsyncFunctionsClient

async def run_func():
fc = AsyncFunctionsClient("https://<project_ref>.functions.supabase.co", {})
res = await fc.invoke("payment-sheet", {"responseType": "json"})
# Initialize the client with your project URL and optional headers
headers = {
"Authorization": "Bearer your-anon-key",
# Add any other headers you might need
}

fc = AsyncFunctionsClient("https://<project_ref>.functions.supabase.co", headers)

try:
# Invoke your Edge Function
res = await fc.invoke("payment-sheet", {
"responseType": "json",
"body": {"amount": 1000, "currency": "usd"}
})
print("Response:", res)
except Exception as e:
print(f"Error: {e}")

if __name__ == "__main__":
asyncio.run(run_func())
```
### Synchronous Client
```python
from supabase_functions import SyncFunctionsClient

# Initialize the client
headers = {"Authorization": "Bearer your-anon-key"}
fc = SyncFunctionsClient("https://<project_ref>.functions.supabase.co", headers)

# Invoke your Edge Function
try:
res = fc.invoke("payment-sheet", {
"responseType": "json",
"body": {"amount": 1000, "currency": "usd"}
})
print("Response:", res)
except Exception as e:
print(f"Error: {e}")
```