Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Finish Python SDK docs
Tuan Dangf137087ef14e
diff --git a/docs/getting-started/quickstart.mdx b/docs/getting-started/quickstart.mdxindex 7fca86d4d0..dba032e6e9 100644--- a/docs/getting-started/quickstart.mdx+++ b/docs/getting-started/quickstart.mdx@@ -49,6 +49,8 @@ These examples demonstrate how to store and fetch environment variables from [In<Tab title="SDK">[Infisical SDKs](/sdks/overview) let your app fetch back secrets using an [Infisical Token](/getting-started/dashboard/token) that is scoped to a project and environment in Infisical. In this example, we demonstrate how to use the [Node SDK](/sdks/languages/node).+ Using Python? We have a [Python SDK](/sdks/languages/python) as well.+### Obtain an [Infisical Token](/getting-started/dashboard/token)Head to your project settings to create a token scoped to the project and environment you wish to fetch secrets from.diff --git a/docs/sdks/languages/go.mdx b/docs/sdks/languages/go.mdxindex 0ff2a2dde3..b470c5b7d3 100644--- a/docs/sdks/languages/go.mdx+++ b/docs/sdks/languages/go.mdx@@ -1,5 +1,6 @@---title: "Go"+icon: "golang"---Coming soon.diff --git a/docs/sdks/languages/java.mdx b/docs/sdks/languages/java.mdxindex 2dd2c3c1d1..7bc371bae3 100644--- a/docs/sdks/languages/java.mdx+++ b/docs/sdks/languages/java.mdx@@ -1,5 +1,6 @@---title: "Java"+icon: "java"---Coming soon.diff --git a/docs/sdks/languages/node.mdx b/docs/sdks/languages/node.mdxindex 4d75168bc6..7f0176f918 100644--- a/docs/sdks/languages/node.mdx+++ b/docs/sdks/languages/node.mdx@@ -1,5 +1,6 @@---title: "Node"+icon: "node"---If you're working with Node.js, the official [infisical-node](https://github.com/Infisical/infisical-node) package is the easiest way to fetch and work with secrets for your application.@@ -7,8 +8,8 @@ If you're working with Node.js, the official [infisical-node](https://github.com## Basic Usage```js-import InfisicalClient from "infisical-node";import express from "express";+import InfisicalClient from "infisical-node";const app = express();const PORT = 3000;@@ -40,8 +41,8 @@ This example demonstrates how to use the Infisical SDK with an Express applicatiRun `npm` to add `infisical-node` to your project.-```bash-npm install infisical-node --save+```console+$ npm install infisical-node --save```## Configuration@@ -75,39 +76,54 @@ Import the SDK and create a client instance with your Infisical token.</Tabs>-<ResponseField name="options" type="object">+### Parameters++<ParamField query="options" type="object"><Expandable title="properties">- <ResponseField name="token" type="string">+ <ParamField query="token" type="string" optional>An [Infisical Token](/getting-started/dashboard/token) scoped to a projectand environment- </ResponseField>- <ResponseField- name="siteURL"+ </ParamField>+ <ParamField+ query="siteURL"type="string"default="https://app.infisical.com"+ optional>Your self-hosted absolute site URL including the protocol (e.g.`https://app.infisical.com`)- </ResponseField>- <ResponseField name="cacheTTL" type="number" default="300">+ </ParamField>+ <ParamField query="cacheTTL" type="number" default="300" optional>Time-to-live (in seconds) for refreshing cached secrets. Default: `300`.- </ResponseField>- <ResponseField name="debug" type="boolean" default="false">+ </ParamField>+ <ParamField query="debug" type="boolean" default="false" optional>Whether or not debug mode is on- </ResponseField>+ </ParamField></Expandable>-</ResponseField>+</ParamField>## CachingThe SDK caches every secret and updates it periodically based on the provided `cacheTTL`. For example, if `cacheTTL` of `300` is provided, then a secret will be refetched 5 minutes after the first fetch; if the fetch fails, the cached secret is returned.+<Tip>+ For optimal performance, we recommend creating a single instance of the Infisical client and exporting it to be used across your entire app to take advantage of caching benefits.+</Tip>+## Working with Secrets-### infisical.getSecret(secretName, options)+### client.getAllSecrets()++```js+const secrets = await client.getAllSecrets();+```++Retrieve all secrets within the Infisical project and environment that client is connected to++### client.getSecret(secretName, options)```js-const secret = await infisical.getSecret("API_KEY");+const secret = await client.getSecret("API_KEY");const value = secret.secretValue; // get its value```@@ -115,79 +131,82 @@ Retrieve a secret from Infisical.By default, `getSecret()` fetches and returns a personal secret. If not found, it returns a shared secret, or tries to retrieve the value from `process.env`. If a secret is fetched, `getSecret()` caches it to reduce excessive calls and re-fetches periodically based on the `cacheTTL` option (default is `300` seconds) when initializing the client — for more information, see the caching section.+### Parameters-<ResponseField name="secretName" type="string" required>+<ParamField query="secretName" type="string" required>The key of the secret to retrieve-</ResponseField>-<ResponseField name="options" type="object">+</ParamField>+<ParamField query="options" type="object" optional><Expandable title="properties">- <ResponseField name="type" type="string">- "personal" (default) or "shared".- </ResponseField>+ <ParamField query="type" type="string" default="personal" optional>+ The type of the secret. Valid options are "shared" or "personal"+ </ParamField></Expandable>-</ResponseField>+</ParamField>-### infisical.createSecret(secretName, secretValue, options)+### client.createSecret(secretName, secretValue, options)```js-const newApiKey = await infisical.createSecret("API_KEY", "FOO");+const newApiKey = await client.createSecret("API_KEY", "FOO");```Create a new secret in Infisical.-<ResponseField name="secretName" type="string" required>+<ParamField query="secretName" type="string" required>The key of the secret to create-</ResponseField>-<ResponseField name="secretName" type="string" required>+</ParamField>+<ParamField query="secretName" type="string" required>The value of the secret to create-</ResponseField>-<ResponseField name="options" type="object">+</ParamField>+<ParamField query="options" type="object" default="object" optional><Expandable title="properties">- <ResponseField name="type" type="string">- "shared" (default) or "personal". A personal secret can only be created if a shared secret with the same name exists.- </ResponseField>+ <ParamField query="type" type="string" default="shared" optional>+ The type of the secret. Valid options are "shared" or "personal". A personal secret can only be created if a shared secret with the same name exists.+ </ParamField></Expandable>-</ResponseField>+</ParamField>-### infisical.updateSecret(secretName, secretValue, options)+### client.updateSecret(secretName, secretValue, options)```js-const updatedApiKey = await infisical.updateSecret("API_KEY", "BAR");+const updatedApiKey = await client.updateSecret("API_KEY", "BAR");```Update an existing secret in Infisical.-<ResponseField name="secretName" type="string" required>+### Parameters++<ParamField query="secretName" type="string" required>The key of the secret to update-</ResponseField>-<ResponseField name="secretName" type="string" required>+</ParamField>+<ParamField query="secretName" type="string" required>The new value of the secret-</ResponseField>-<ResponseField name="options" type="object">+</ParamField>+<ParamField query="options" type="object" default="object" optional><Expandable title="properties">- <ResponseField name="type" type="string">- "shared" (default) or "personal".- </ResponseField>+ <ParamField query="type" type="string" default="shared" optional>+ The type of the secret. Valid options are "shared" or "personal"+ </ParamField></Expandable>-</ResponseField>+</ParamField>-### infisical.deleteSecret(secretName, options)+### client.deleteSecret(secretName, options)```js-const deletedSecret = await infisical.deleteSecret("API_KEY");+const deletedSecret = await client.deleteSecret("API_KEY");```Delete a secret in Infisical.-<ResponseField name="secretName" type="string" required>+<ParamField query="secretName" type="string" required>The key of the secret to delete-</ResponseField>-<ResponseField name="options" type="object">+</ParamField>+<ParamField query="options" type="object" default="object" optional><Expandable title="properties">- <ResponseField name="type" type="string">- "shared" (default) or "personal". Note that deleting a shared secret also deletes all associated personal secrets.- </ResponseField>+ <ParamField query="type" type="string" default="shared" optional>+ The type of the secret. Valid options are "shared" or "personal". Note that deleting a shared secret also deletes all associated personal secrets.+ </ParamField></Expandable>-</ResponseField>+</ParamField>diff --git a/docs/sdks/languages/python.mdx b/docs/sdks/languages/python.mdxindex 3a9b821520..27ba412712 100644--- a/docs/sdks/languages/python.mdx+++ b/docs/sdks/languages/python.mdx@@ -1,8 +1,169 @@---title: "Python"+icon: "python"----Coming soon.+If you're working with Python, the official [infisical-python](https://github.com/Infisical/infisical-python) package is the easiest way to fetch and work with secrets for your application.++## Basic Usage++```py+from flask import Flask+from infisical import InfisicalClient++app = Flask(__name__)++client = InfisicalClient(token="your_infisical_token")+[email protected]("/")+def hello_world():+ # access value+ name = client.get_secret("NAME")+ return f"Hello! My name is: {name.secret_value}"+```++This example demonstrates how to use the Infisical Python SDK with a Flask application. The application retrieves a secret named "NAME" and responds to requests with a greeting that includes the secret value.++<Warning>+ We do not recommend hardcoding your [Infisical+ Token](/getting-started/dashboard/token). Setting it as an environment+ variable would be best.+</Warning>++## Installation++Run `pip` to add `infisical-python` to your project++```console+$ pip install infisical+```++Note: You need Python 3.7+.++## Configuration++Import the SDK and create a client instance with your Infisical token.++```py+from infisical import InfisicalClient++client = InfisicalClient(token="your_infisical_token")+```++### Parameters++ <ParamField query="token" type="string" optional>+ An [Infisical Token](/getting-started/dashboard/token) scoped to a project+ and environment+ </ParamField>+ <ParamField+ query="site_url"+ type="string"+ default="https://app.infisical.com"+ optional+ >+ Your self-hosted absolute site URL including the protocol (e.g.+ `https://app.infisical.com`)+ </ParamField>+ <ParamField query="cache_ttl" type="number" default="300" optional>+ Time-to-live (in seconds) for refreshing cached secrets. Default: `300`.+ </ParamField>+ <ParamField query="debug" type="boolean" default="false" optional>+ Whether or not debug mode is on+ </ParamField>++## Caching++The SDK caches every secret and updates it periodically based on the provided `cache_ttl`. For example, if `cache_ttl` of `300` is provided, then a secret will be refetched 5 minutes after the first fetch; if the fetch fails, the cached secret is returned.++<Tip>+ For optimal performance, we recommend creating a single instance of the Infisical client and exporting it to be used across your entire app to take advantage of caching benefits.+</Tip>++## Working with Secrets++### client.get_all_secrets()++```py+secrets = client.get_all_secrets()+```++Retrieve all secrets within the Infisical project and environment that client is connected to++### client.get_secret(secret_name, options)++```py+secret = client.get_secret("API_KEY")+value = secret.secret_value # get its value+```++By default, `get_secret()` fetches and returns a personal secret. If not found, it returns a shared secret, or tries to retrieve the value from `os.environ`. If a secret is fetched, `get_secret()` caches it to reduce excessive calls and re-fetches periodically based on the `cacheTTL` option (default is 300 seconds) when initializing the client — for more information, see the caching section.++### Parameters++<ParamField query="secret_name" type="string" required>+ The key of the secret to retrieve+</ParamField>+<ParamField query="type" type="string" default="personal" optional>+ The type of the secret. Valid options are "shared" or "personal"+</ParamField>++### client.create_secret(secret_name, secret_value, options)++```py+new_api_key = client.create_secret("API_KEY", "FOO");+```++Create a new secret in Infisical.++### Parameters++<ParamField query="secret_name" type="string" required>+ The key of the secret to create+</ParamField>+<ParamField query="secret_value" type="string" required>+ The value of the secret to create+</ParamField>+<ParamField query="type" type="string" default="shared" optional>+ The type of the secret. Valid options are "shared" or "personal". A personal secret can only be created if a shared secret with the same name exists.+</ParamField>++### client.update_secret(secret_name, secret_value, options)++```py+updated_api_key = client.update_secret("API_KEY", "BAR");+```++Update an existing secret in Infisical.++### Parameters++<ParamField query="secret_name" type="string" required>+ The key of the secret to update+</ParamField>+<ParamField query="secret_value" type="string" required>+ The new value of the secret+</ParamField>+<ParamField query="type" type="string" default="shared" optional>+ The type of the secret. Valid options are "shared" or "personal"+</ParamField>++### client.delete_secret(secret_name, options)++```py+deleted_secret = client.delete_secret("API_KEY");+```++Delete a secret in Infisical.++### Parameters++<ParamField query="secret_name" type="string" required>+ The key of the secret to delete+</ParamField>+<ParamField query="type" type="string" default="shared" optional>+ The type of the secret. Valid options are "shared" or "personal"+</ParamField>Follow this GitHub[issue](https://github.com/Infisical/infisical/issues/433) to stay updated.diff --git a/docs/sdks/languages/ruby.mdx b/docs/sdks/languages/ruby.mdxindex 80dab508a8..1233e44bde 100644--- a/docs/sdks/languages/ruby.mdx+++ b/docs/sdks/languages/ruby.mdx@@ -1,5 +1,6 @@---title: "Ruby"+icon: "gem"---Coming soon.diff --git a/docs/sdks/languages/rust.mdx b/docs/sdks/languages/rust.mdxindex 8fa9b3b5b6..5d5b770cac 100644--- a/docs/sdks/languages/rust.mdx+++ b/docs/sdks/languages/rust.mdx@@ -1,5 +1,6 @@---title: "Rust"+icon: "rust"---Coming soon.diff --git a/docs/sdks/overview.mdx b/docs/sdks/overview.mdxindex fd27ad9026..e1d85dae2c 100644--- a/docs/sdks/overview.mdx+++ b/docs/sdks/overview.mdx@@ -3,12 +3,9 @@ title: "Overview"description: "How to use Infisical SDKs to fetch back secrets for your app"----Infisical SDKs provide the easiest way for your app to fetch back secrets using an [Infisical Token](/getting-started/dashboard/token) and has a few benefits:+Whether it be for local development or production, Infisical SDKs provide the easiest way for your app to fetch back secrets using an [Infisical Token](/getting-started/dashboard/token).-- Local development: Replace 10s of environment variables in your `.env` file with 1 environment variable (the [Infisical Token](/getting-started/dashboard/token)).-- Production: Fetch secrets back to any cloud regardless of if an integration exists between Infisical and the cloud platform.--We currently only have the [Node SDK](/sdks/languages/node) available but more language SDKs are coming out soon:+We currently have the [Node SDK](/sdks/languages/node) and [Python SDK](/sdks/languages/python) available with more language SDKs coming out soon:- [Node](/sdks/languages/node)- [Python](/sdks/languages/python)