Skip to main content

Official Infisical SDK for Python (New)

Project description

infisical

Open-source, end-to-end encrypted tool to manage secrets and configs across your team and infrastructure.

Table of Contents

Links

Basic Usage

from flask import Flask
from infisical_client import ClientSettings, InfisicalClient, GetSecretOptions

app = Flask(__name__)

client = InfisicalClient(ClientSettings(
    client_id="MACHINE_IDENTITY_CLIENT_ID",
    client_secret="MACHINE_IDENTITY_CLIENT_SECRET",
))

@app.route("/")
def hello_world():
    # access value

    name = client.getSecret(options=GetSecretOptions(
       environment="dev",
       project_id="PROJECT_ID",
       secret_name="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.

Installation

You need Python 3.7+.

$ pip install infisical-python

Configuration

Import the SDK and create a client instance with your Machine Identity.

from infisical_client import ClientSettings, InfisicalClient

client = InfisicalClient(ClientSettings(
    client_id="MACHINE_IDENTITY_CLIENT_ID",
    client_secret="MACHINE_IDENTITY_CLIENT_SECRET",
))

Options

Parameter Type Description
client_id string Your Infisical Client ID.
client_secret string Your Infisical Client Secret.
access_token string If you want to directly pass an access token obtained from the authentication endpoints, you can do so.
site_url string Your self-hosted Infisical site URL. Default: https://app.infisical.com.

Secrets

List secrets

client.listSecrets(options=ListSecretsOptions(
    environment="dev",
    project_id="658066938ffb84aa0aa507f6"
))

Retrieve all secrets within a given environment and folder path. The service token used must have access to the given path and environment.

Parameters

  • environment (string): The slug name (dev, prod, etc) of the environment from where secrets should be fetched from.
  • project_id (string): The ID of the project the secret lives in.
  • path (string): The path from where secrets should be fetched from.
  • include_imports (boolean): Whether or not to include imported secrets from the current path. Read about secret import. If not specified, the default value is True.

Get Secret

secret = client.getSecret(options=GetSecretOptions(
    environment="dev",
    project_id="658066938ffb84aa0aa507f6",
    secret_name="API_KEY"
))
value = secret.secret_value # get its value

By default, get_secret() fetches and returns a shared secret. If not found, it returns a personal secret.

To explicitly retrieve a personal secret:

secret = client.getSecret(options=GetSecretOptions(
    environment="dev",
    project_id="658066938ffb84aa0aa507f6",
    secret_name="API_KEY",
    type="personal"
))
value = secret.secret_value # get its value

Parameters

  • secret_name (string): The key of the secret to retrieve.
  • environment (string): The slug name (dev, prod, etc) of the environment from where secrets should be fetched from.
  • project_id (string): The ID of the project the secret lives in.
  • path (string): The path from where secrets should be fetched from.
  • type (string, optional): The type of the secret. Valid options are "shared" or "personal". If not specified, the default value is "personal".
  • include_imports (boolean, optional): Whether or not to include imported secrets from the current path. Read about secret import.

Create Secret

Create a new secret in Infisical

api_key = client.createSecret(options=CreateSecretOptions(
    secret_name="API_KEY",
    secret_value="Some API Key",
    environment="dev",
    project_id="658066938ffb84aa0aa507f6"
))

Parameters

  • secret_name (string): The key of the secret to create.
  • secret_value (string): The value of the secret.
  • environment (string): The slug name (dev, prod, etc) of the environment from where secrets should be fetched from.
  • project_id (string): The ID of the project the secret lives in.
  • path (string): The path from where secrets should be created.
  • type (string, optional): The type of the secret. Valid options are "shared" or "personal". If not specified, the default value is "shared". A personal secret can only be created if a shared secret with the same name exists.

Update Secret

Update an existing secret in Infisical

client.updateSecret(options=UpdateSecretOptions(
    secret_name="API_KEY",
    secret_value="new secret value!",
    environment="dev",
    project_id="658066938ffb84aa0aa507f6"
))

Parameters

  • secret_name (string): The key of the secret to update.
  • secret_value (string): The new value of the secret.
  • environment (string): The slug name (dev, prod, etc) of the environment from where secrets should be fetched from.
  • project_id (string): The ID of the project the secret lives in.
  • path (string): The path from where secrets should be updated.
  • type (string, optional): The type of the secret. Valid options are "shared" or "personal". If not specified, the default value is "shared".

Delete Secret

Delete a secret in Infisical

client.deleteSecret(options=DeleteSecretOptions(
    environment="dev",
    project_id="658066938ffb84aa0aa507f6",
    secret_name="API_KEY"
))

Parameters

  • secret_name (string): The key of the secret to delete.
  • environment (string): The slug name (dev, prod, etc) of the environment from where secrets should be fetched from.
  • project_id (string): The ID of the project the secret lives in.
  • path (string): The path from where secrets should be deleted.
  • type (string, optional): The type of the secret. Valid options are "shared" or "personal". If not specified, the default value is "shared".

License

infisical-python is distributed under the terms of the MIT license.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

infisical_python-1.0.24.tar.gz (37.0 kB view hashes)

Uploaded Source

Built Distributions

infisical_python-1.0.24-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

infisical_python-1.0.24-pp39-pypy39_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl (3.7 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ s390x

infisical_python-1.0.24-pp39-pypy39_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.3 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ppc64le

infisical_python-1.0.24-pp39-pypy39_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (2.9 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

infisical_python-1.0.24-pp39-pypy39_pp73-manylinux_2_12_i686.manylinux2010_i686.whl (3.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ i686

infisical_python-1.0.24-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

infisical_python-1.0.24-pp38-pypy38_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl (3.7 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ s390x

infisical_python-1.0.24-pp38-pypy38_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.3 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ppc64le

infisical_python-1.0.24-pp38-pypy38_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (2.9 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

infisical_python-1.0.24-pp38-pypy38_pp73-manylinux_2_12_i686.manylinux2010_i686.whl (3.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ i686

infisical_python-1.0.24-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

infisical_python-1.0.24-pp37-pypy37_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl (3.7 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ s390x

infisical_python-1.0.24-pp37-pypy37_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.3 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ppc64le

infisical_python-1.0.24-pp37-pypy37_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (2.9 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

infisical_python-1.0.24-pp37-pypy37_pp73-manylinux_2_12_i686.manylinux2010_i686.whl (3.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ i686

infisical_python-1.0.24-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

infisical_python-1.0.24-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl (3.7 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ s390x

infisical_python-1.0.24-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.3 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ppc64le

infisical_python-1.0.24-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.8 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

infisical_python-1.0.24-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.whl (3.2 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.12+ i686

infisical_python-1.0.24-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

infisical_python-1.0.24-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl (3.7 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ s390x

infisical_python-1.0.24-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.3 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ppc64le

infisical_python-1.0.24-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (2.9 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARMv7l

infisical_python-1.0.24-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.8 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

infisical_python-1.0.24-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.whl (3.2 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.12+ i686

infisical_python-1.0.24-cp310-none-win_amd64.whl (1.8 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

infisical_python-1.0.24-cp310-none-win32.whl (1.5 MB view hashes)

Uploaded CPython 3.10 Windows x86

infisical_python-1.0.24-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

infisical_python-1.0.24-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl (3.7 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ s390x

infisical_python-1.0.24-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.3 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ppc64le

infisical_python-1.0.24-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (2.9 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARMv7l

infisical_python-1.0.24-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.8 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

infisical_python-1.0.24-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.whl (3.2 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.12+ i686

infisical_python-1.0.24-cp310-cp310-macosx_11_0_arm64.whl (1.9 MB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

infisical_python-1.0.24-cp310-cp310-macosx_10_12_x86_64.whl (2.0 MB view hashes)

Uploaded CPython 3.10 macOS 10.12+ x86-64

infisical_python-1.0.24-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

infisical_python-1.0.24-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl (3.7 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ s390x

infisical_python-1.0.24-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.3 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ppc64le

infisical_python-1.0.24-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (2.9 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARMv7l

infisical_python-1.0.24-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.8 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

infisical_python-1.0.24-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl (3.2 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ i686

infisical_python-1.0.24-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

infisical_python-1.0.24-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl (3.7 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ s390x

infisical_python-1.0.24-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.3 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ppc64le

infisical_python-1.0.24-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (2.9 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARMv7l

infisical_python-1.0.24-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.8 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

infisical_python-1.0.24-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl (3.2 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

infisical_python-1.0.24-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

infisical_python-1.0.24-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl (3.7 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ s390x

infisical_python-1.0.24-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.3 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ppc64le

infisical_python-1.0.24-cp37-cp37m-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (2.9 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARMv7l

infisical_python-1.0.24-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.8 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

infisical_python-1.0.24-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.whl (3.2 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ i686

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page