Fetch a secret with the Python SDK
Install the oneclaw Python SDK, create a client, and print a secret from your vault.
The 1Claw Python SDK ships as the PyPI package oneclaw. You create a client with an API key, and it handles token exchange and refresh for you.
You need Python 3.9+ and a 1Claw API key from 1claw.co/settings/api-keys. A 1ck_ key is a user key, an ocv_ key is an agent key. Both work here.
- 1
Create and activate a virtual environment.
bashpython3 -m venv .venv source .venv/bin/activate - 2
Install the SDK from PyPI.
bashpip install oneclaw - 3
Export your API key and the vault ID that holds a secret. Replace
1ck_your_user_keywith your 1ck_ key from Settings → API Keys. Use your vault UUID from1claw vault listor the Foundations track.bashexport ONECLAW_API_KEY=1ck_your_user_key export ONECLAW_VAULT_ID=your-vault-uuid - 4
Write the following script and save it as
fetch_secret.py. It creates a client and reads one secret by path.pythonimport os from oneclaw import create_client client = create_client(api_key=os.environ["ONECLAW_API_KEY"]) vault_id = os.environ["ONECLAW_VAULT_ID"] secret = client.secrets.get(vault_id, "api-keys/openai") print(secret.data["value"]) - 5
Create the secret if it doesn't already exist.
bash1claw secret set api-keys/openai --vault $ONECLAW_VAULT_ID --value 'your-openai-key' --type api_key - 6
Run it. The fetched secret value prints to your terminal.
bashpython fetch_secret.py
Use create_client() inside a with block if you want the connection pool closed automatically when the script exits.
You now have a Python script that authenticates to 1Claw and prints a real secret pulled from your vault.
What this gives you, and what it does not. The Python client mirrors the TypeScript one in shape while following Python conventions, and the differences catch people who move between them.
- Resource names differ deliberately. Python exposes client.vaults and snake_case methods; TypeScript uses client.vault and camelCase. Neither is a typo for the other.
- The response envelope is the same. Calls return an object with data and error, so reading resp.data['value'] rather than treating the result as the value itself is the habit to build.
- It does not manage your process environment. Fetching a secret gives you a value in memory; putting it into os.environ is a decision you are making, and one that widens its reach to every library in the process.
If you work in both languages, expect the pluralisation difference to bite once. client.vault in Python and client.vaults in TypeScript are both wrong, and both fail as attribute errors rather than anything descriptive.
Decide
A Python service fetches a database password at startup and needs it available to an ORM that reads DATABASE_URL. A colleague sets os.environ['DATABASE_URL'] right after the fetch, because the ORM expects it there.
What is the consequence worth raising?
Check your understanding
3 questionsWhat is the PyPI package name for the 1Claw Python SDK?
Which call retrieves a single secret by path?
What does an ocv_ prefixed key represent?