|
| 1 | +# Skyflow Python SDK — Samples |
| 2 | + |
| 3 | +Runnable examples for the Skyflow Python SDK, grouped by area. Start with the [README](../README.md) and [API Reference](../docs/api_reference.md) for full documentation. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- Python 3.9 or above |
| 8 | +- The SDK installed: `pip install skyflow` |
| 9 | +- A Skyflow account, a vault, and a service account (see [Before you begin](../README.md#before-you-begin)) |
| 10 | +- The values listed in [`.env.example`](.env.example): `vault_id`, `cluster_id`, `env`, and one credential (API key, bearer token, or service-account credentials) |
| 11 | + |
| 12 | +## Configure |
| 13 | + |
| 14 | +Copy the env template and fill in your values: |
| 15 | + |
| 16 | +```bash |
| 17 | +cp .env.example .env |
| 18 | +``` |
| 19 | + |
| 20 | +The samples ship with inline `<PLACEHOLDER>` strings (for example `<YOUR_VAULT_ID>`). You can either: |
| 21 | + |
| 22 | +1. **Replace the placeholders** directly in the sample file you want to run, or |
| 23 | +2. **Load from `.env`** by adding the following near the top of the sample (`python-dotenv` is already a SDK dependency): |
| 24 | + |
| 25 | + ```python |
| 26 | + import os |
| 27 | + from dotenv import load_dotenv |
| 28 | + |
| 29 | + load_dotenv() |
| 30 | + vault_id = os.getenv('SKYFLOW_VAULT_ID') |
| 31 | + # ...use os.getenv(...) for the other values |
| 32 | + ``` |
| 33 | + |
| 34 | +> Never commit a filled-in `.env` or any real credentials. |
| 35 | +
|
| 36 | +## Run a sample |
| 37 | + |
| 38 | +```bash |
| 39 | +python samples/vault_api/insert_records.py |
| 40 | +``` |
| 41 | + |
| 42 | +## What's here |
| 43 | + |
| 44 | +### `vault_api/` |
| 45 | +Core vault data operations. |
| 46 | + |
| 47 | +| Sample | Demonstrates | |
| 48 | +|--------|--------------| |
| 49 | +| `client_operations.py` | Building and managing the Skyflow client | |
| 50 | +| `credentials_options.py` | The different credential types | |
| 51 | +| `insert_records.py` | Inserting and tokenizing records (`continue_on_error`) | |
| 52 | +| `insert_byot.py` | Bring-your-own-token inserts | |
| 53 | +| `get_records.py` | Getting records by Skyflow ID | |
| 54 | +| `get_column_values.py` | Getting records by column name/values | |
| 55 | +| `update_record.py` | Updating a record | |
| 56 | +| `delete_records.py` | Deleting records | |
| 57 | +| `query_records.py` | SQL queries | |
| 58 | +| `detokenize_records.py` | Detokenizing tokens | |
| 59 | +| `tokenize_records.py` | Retrieving existing tokens | |
| 60 | +| `upload_file.py` | Uploading a file to a record | |
| 61 | +| `invoke_connection.py` | Invoking a Skyflow Connection | |
| 62 | + |
| 63 | +### `detect_api/` |
| 64 | +Skyflow Detect (de-identification / re-identification). |
| 65 | + |
| 66 | +| Sample | Demonstrates | |
| 67 | +|--------|--------------| |
| 68 | +| `deidentify_text.py` | De-identifying text | |
| 69 | +| `reidentify_text.py` | Re-identifying text | |
| 70 | +| `deidentify_file.py` | De-identifying a file | |
| 71 | +| `deidentify_file_concurrent.py` | Running a file de-identification on a background thread (thread-based concurrency, not asyncio) | |
| 72 | +| `get_detect_run.py` | Polling a file de-identification run by `run_id` | |
| 73 | + |
| 74 | +### `service_account/` |
| 75 | +Bearer-token and signed-data-token generation. |
| 76 | + |
| 77 | +| Sample | Demonstrates | |
| 78 | +|--------|--------------| |
| 79 | +| `token_generation_example.py` | Generating a bearer token | |
| 80 | +| `scoped_token_generation_example.py` | Tokens scoped to specific roles | |
| 81 | +| `token_generation_with_context_example.py` | Tokens with context (`ctx`) | |
| 82 | +| `signed_token_generation_example.py` | Signed data tokens | |
| 83 | +| `bearer_token_expiry_example.py` | Handling token expiry / regeneration | |
0 commit comments