diff --git a/src/functions/README.md b/src/functions/README.md index 9f7f24a5..9f7f360f 100644 --- a/src/functions/README.md +++ b/src/functions/README.md @@ -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://.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://.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://.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}") +```