[{"data":1,"prerenderedAt":565},["ShallowReactive",2],{"content-query-yYKDVIr7q5":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"sidebar_position":10,"body":11,"_type":559,"_id":560,"_source":561,"_file":562,"_stem":563,"_extension":564},"/docs/sdks/python","sdks",false,"","Python SDK","The official CredVault SDK for Python applications. Designed for data scientists, backend developers, and automation engineers, this SDK makes it easy to integrate CredVault into your Python projects.",2,{"type":12,"children":13,"toc":548},"root",[14,22,27,34,39,44,49,55,60,94,100,105,167,172,177,183,188,199,209,219,229,239,245,250,260,270,280,285,291,296,301,307,312,447,453,458,463,468,491,497,507,517,527,537,542],{"type":15,"tag":16,"props":17,"children":19},"element","h1",{"id":18},"python-sdk",[20],{"type":21,"value":8},"text",{"type":15,"tag":23,"props":24,"children":25},"p",{},[26],{"type":21,"value":9},{"type":15,"tag":28,"props":29,"children":31},"h2",{"id":30},"why-use-the-python-sdk",[32],{"type":21,"value":33},"Why Use the Python SDK?",{"type":15,"tag":23,"props":35,"children":36},{},[37],{"type":21,"value":38},"Python is the language of choice for data science and machine learning, making it a natural fit for CredVault's Intelligence Engine. The SDK works seamlessly in Jupyter notebooks, allowing you to explore data and train models interactively.",{"type":15,"tag":23,"props":40,"children":41},{},[42],{"type":21,"value":43},"For backend development, the SDK integrates with Flask, Django, FastAPI, and other popular frameworks. The API design follows Python conventions, using snake_case naming and returning native Python types.",{"type":15,"tag":23,"props":45,"children":46},{},[47],{"type":21,"value":48},"The SDK supports Python 3.8 and later. All I/O operations use synchronous methods by default, making it easy to use in scripts and notebooks. For high-concurrency applications, async support is available.",{"type":15,"tag":28,"props":50,"children":52},{"id":51},"installation",[53],{"type":21,"value":54},"Installation",{"type":15,"tag":23,"props":56,"children":57},{},[58],{"type":21,"value":59},"The SDK is available on PyPI, Python's package repository. Install it using pip, poetry, or your preferred package manager:",{"type":15,"tag":61,"props":62,"children":66},"pre",{"className":63,"code":64,"language":65,"meta":7,"style":7},"language-bash shiki shiki-themes github-dark","pip install credvault\n","bash",[67],{"type":15,"tag":68,"props":69,"children":70},"code",{"__ignoreMap":7},[71],{"type":15,"tag":72,"props":73,"children":76},"span",{"class":74,"line":75},"line",1,[77,83,89],{"type":15,"tag":72,"props":78,"children":80},{"style":79},"--shiki-default:#B392F0",[81],{"type":21,"value":82},"pip",{"type":15,"tag":72,"props":84,"children":86},{"style":85},"--shiki-default:#9ECBFF",[87],{"type":21,"value":88}," install",{"type":15,"tag":72,"props":90,"children":91},{"style":85},[92],{"type":21,"value":93}," credvault\n",{"type":15,"tag":28,"props":95,"children":97},{"id":96},"connecting-to-credvault",[98],{"type":21,"value":99},"Connecting to CredVault",{"type":15,"tag":23,"props":101,"children":102},{},[103],{"type":21,"value":104},"Create a client instance to start making API calls. The client requires authentication credentials and optionally accepts a custom base URL for enterprise deployments.",{"type":15,"tag":61,"props":106,"children":110},{"className":107,"code":108,"language":109,"meta":7,"style":7},"language-python shiki shiki-themes github-dark","import os\nfrom credvault import CredVault\n\nclient = CredVault(\n    api_key=os.environ.get(\"CREDVAULT_API_KEY\")\n)\n","python",[111],{"type":15,"tag":68,"props":112,"children":113},{"__ignoreMap":7},[114,122,130,140,149,158],{"type":15,"tag":72,"props":115,"children":116},{"class":74,"line":75},[117],{"type":15,"tag":72,"props":118,"children":119},{},[120],{"type":21,"value":121},"import os\n",{"type":15,"tag":72,"props":123,"children":124},{"class":74,"line":10},[125],{"type":15,"tag":72,"props":126,"children":127},{},[128],{"type":21,"value":129},"from credvault import CredVault\n",{"type":15,"tag":72,"props":131,"children":133},{"class":74,"line":132},3,[134],{"type":15,"tag":72,"props":135,"children":137},{"emptyLinePlaceholder":136},true,[138],{"type":21,"value":139},"\n",{"type":15,"tag":72,"props":141,"children":143},{"class":74,"line":142},4,[144],{"type":15,"tag":72,"props":145,"children":146},{},[147],{"type":21,"value":148},"client = CredVault(\n",{"type":15,"tag":72,"props":150,"children":152},{"class":74,"line":151},5,[153],{"type":15,"tag":72,"props":154,"children":155},{},[156],{"type":21,"value":157},"    api_key=os.environ.get(\"CREDVAULT_API_KEY\")\n",{"type":15,"tag":72,"props":159,"children":161},{"class":74,"line":160},6,[162],{"type":15,"tag":72,"props":163,"children":164},{},[165],{"type":21,"value":166},")\n",{"type":15,"tag":23,"props":168,"children":169},{},[170],{"type":21,"value":171},"For most applications, authenticate with an API key. Store your API key in an environment variable or a secure configuration file. Avoid hardcoding credentials in your source code.",{"type":15,"tag":23,"props":173,"children":174},{},[175],{"type":21,"value":176},"For applications that act on behalf of users, authenticate with a bearer token. Tokens are obtained through the login endpoint and should be refreshed before expiration.",{"type":15,"tag":28,"props":178,"children":180},{"id":179},"working-with-data",[181],{"type":21,"value":182},"Working with Data",{"type":15,"tag":23,"props":184,"children":185},{},[186],{"type":21,"value":187},"The data resource provides methods for interacting with your database clusters.",{"type":15,"tag":23,"props":189,"children":190},{},[191,197],{"type":15,"tag":192,"props":193,"children":194},"strong",{},[195],{"type":21,"value":196},"Listing clusters",{"type":21,"value":198}," retrieves all clusters in your account. Use this to discover available databases or build administrative interfaces.",{"type":15,"tag":23,"props":200,"children":201},{},[202,207],{"type":15,"tag":192,"props":203,"children":204},{},[205],{"type":21,"value":206},"Querying collections",{"type":21,"value":208}," fetches documents matching specified criteria. The method accepts a dictionary for filtering and supports various query operators.",{"type":15,"tag":23,"props":210,"children":211},{},[212,217],{"type":15,"tag":192,"props":213,"children":214},{},[215],{"type":21,"value":216},"Inserting documents",{"type":21,"value":218}," adds new records to collections. Pass a list of dictionaries to insert multiple documents efficiently.",{"type":15,"tag":23,"props":220,"children":221},{},[222,227],{"type":15,"tag":192,"props":223,"children":224},{},[225],{"type":21,"value":226},"Updating documents",{"type":21,"value":228}," modifies existing records. Specify a filter to select documents and provide the changes to apply.",{"type":15,"tag":23,"props":230,"children":231},{},[232,237],{"type":15,"tag":192,"props":233,"children":234},{},[235],{"type":21,"value":236},"Deleting documents",{"type":21,"value":238}," removes records permanently. Always double-check your filter to avoid unintended data loss.",{"type":15,"tag":28,"props":240,"children":242},{"id":241},"using-the-intelligence-engine",[243],{"type":21,"value":244},"Using the Intelligence Engine",{"type":15,"tag":23,"props":246,"children":247},{},[248],{"type":21,"value":249},"The Python SDK excels at working with CIE, the CredVault Intelligence Engine.",{"type":15,"tag":23,"props":251,"children":252},{},[253,258],{"type":15,"tag":192,"props":254,"children":255},{},[256],{"type":21,"value":257},"Uploading datasets",{"type":21,"value":259}," prepares your data for model training. The SDK handles file uploads efficiently, supporting large datasets.",{"type":15,"tag":23,"props":261,"children":262},{},[263,268],{"type":15,"tag":192,"props":264,"children":265},{},[266],{"type":21,"value":267},"Training models",{"type":21,"value":269}," starts a training job with your configuration. Models train on CredVault's infrastructure, freeing your local machine for other work.",{"type":15,"tag":23,"props":271,"children":272},{},[273,278],{"type":15,"tag":192,"props":274,"children":275},{},[276],{"type":21,"value":277},"Running predictions",{"type":21,"value":279}," invokes your trained models. Pass input data and receive predictions in response.",{"type":15,"tag":23,"props":281,"children":282},{},[283],{"type":21,"value":284},"These capabilities integrate naturally with popular data science libraries. Load data from CredVault into pandas DataFrames, train models, and deploy them back to the platform.",{"type":15,"tag":28,"props":286,"children":288},{"id":287},"handling-errors",[289],{"type":21,"value":290},"Handling Errors",{"type":15,"tag":23,"props":292,"children":293},{},[294],{"type":21,"value":295},"The SDK raises descriptive exceptions when operations fail. Use try/except blocks to handle errors appropriately.",{"type":15,"tag":23,"props":297,"children":298},{},[299],{"type":21,"value":300},"Authentication errors occur when credentials are invalid or expired. Not found errors indicate a resource doesn't exist. Validation errors happen when request parameters are malformed.",{"type":15,"tag":28,"props":302,"children":304},{"id":303},"resources-available",[305],{"type":21,"value":306},"Resources Available",{"type":15,"tag":23,"props":308,"children":309},{},[310],{"type":21,"value":311},"All platform capabilities are accessible through the SDK:",{"type":15,"tag":313,"props":314,"children":315},"ul",{},[316,327,337,347,357,367,377,387,397,407,417,427,437],{"type":15,"tag":317,"props":318,"children":319},"li",{},[320,325],{"type":15,"tag":192,"props":321,"children":322},{},[323],{"type":21,"value":324},"auth",{"type":21,"value":326}," — User authentication and sessions",{"type":15,"tag":317,"props":328,"children":329},{},[330,335],{"type":15,"tag":192,"props":331,"children":332},{},[333],{"type":21,"value":334},"data",{"type":21,"value":336}," — Database clusters and collections",{"type":15,"tag":317,"props":338,"children":339},{},[340,345],{"type":15,"tag":192,"props":341,"children":342},{},[343],{"type":21,"value":344},"cie",{"type":21,"value":346}," — Machine learning training and inference",{"type":15,"tag":317,"props":348,"children":349},{},[350,355],{"type":15,"tag":192,"props":351,"children":352},{},[353],{"type":21,"value":354},"webhooks",{"type":21,"value":356}," — Event notifications",{"type":15,"tag":317,"props":358,"children":359},{},[360,365],{"type":15,"tag":192,"props":361,"children":362},{},[363],{"type":21,"value":364},"functions",{"type":21,"value":366}," — Serverless function execution",{"type":15,"tag":317,"props":368,"children":369},{},[370,375],{"type":15,"tag":192,"props":371,"children":372},{},[373],{"type":21,"value":374},"triggers",{"type":21,"value":376}," — Database event automation",{"type":15,"tag":317,"props":378,"children":379},{},[380,385],{"type":15,"tag":192,"props":381,"children":382},{},[383],{"type":21,"value":384},"backups",{"type":21,"value":386}," — Backup management",{"type":15,"tag":317,"props":388,"children":389},{},[390,395],{"type":15,"tag":192,"props":391,"children":392},{},[393],{"type":21,"value":394},"schema",{"type":21,"value":396}," — Schema and index operations",{"type":15,"tag":317,"props":398,"children":399},{},[400,405],{"type":15,"tag":192,"props":401,"children":402},{},[403],{"type":21,"value":404},"api_keys",{"type":21,"value":406}," — API key lifecycle",{"type":15,"tag":317,"props":408,"children":409},{},[410,415],{"type":15,"tag":192,"props":411,"children":412},{},[413],{"type":21,"value":414},"metrics",{"type":21,"value":416}," — Platform metrics",{"type":15,"tag":317,"props":418,"children":419},{},[420,425],{"type":15,"tag":192,"props":421,"children":422},{},[423],{"type":21,"value":424},"logs",{"type":21,"value":426}," — Activity logging",{"type":15,"tag":317,"props":428,"children":429},{},[430,435],{"type":15,"tag":192,"props":431,"children":432},{},[433],{"type":21,"value":434},"notifications",{"type":21,"value":436}," — Notification management",{"type":15,"tag":317,"props":438,"children":439},{},[440,445],{"type":15,"tag":192,"props":441,"children":442},{},[443],{"type":21,"value":444},"settings",{"type":21,"value":446}," — Configuration options",{"type":15,"tag":28,"props":448,"children":450},{"id":449},"using-in-notebooks",[451],{"type":21,"value":452},"Using in Notebooks",{"type":15,"tag":23,"props":454,"children":455},{},[456],{"type":21,"value":457},"Jupyter notebooks are excellent for exploring data and prototyping. The SDK works naturally in this environment.",{"type":15,"tag":23,"props":459,"children":460},{},[461],{"type":21,"value":462},"Start by importing the library and creating a client. Then fetch data from your clusters and work with it using pandas, numpy, or your preferred tools.",{"type":15,"tag":23,"props":464,"children":465},{},[466],{"type":21,"value":467},"The interactive nature of notebooks makes them ideal for:",{"type":15,"tag":313,"props":469,"children":470},{},[471,476,481,486],{"type":15,"tag":317,"props":472,"children":473},{},[474],{"type":21,"value":475},"Exploring new datasets",{"type":15,"tag":317,"props":477,"children":478},{},[479],{"type":21,"value":480},"Prototyping queries before implementing them in applications",{"type":15,"tag":317,"props":482,"children":483},{},[484],{"type":21,"value":485},"Testing machine learning models during development",{"type":15,"tag":317,"props":487,"children":488},{},[489],{"type":21,"value":490},"Creating data analysis reports",{"type":15,"tag":28,"props":492,"children":494},{"id":493},"best-practices",[495],{"type":21,"value":496},"Best Practices",{"type":15,"tag":23,"props":498,"children":499},{},[500,505],{"type":15,"tag":192,"props":501,"children":502},{},[503],{"type":21,"value":504},"Use virtual environments.",{"type":21,"value":506}," Isolate your project dependencies to avoid conflicts with Python projects.",{"type":15,"tag":23,"props":508,"children":509},{},[510,515],{"type":15,"tag":192,"props":511,"children":512},{},[513],{"type":21,"value":514},"Store credentials securely.",{"type":21,"value":516}," Use environment variables or tools like python-dotenv to manage API keys.",{"type":15,"tag":23,"props":518,"children":519},{},[520,525],{"type":15,"tag":192,"props":521,"children":522},{},[523],{"type":21,"value":524},"Handle rate limits.",{"type":21,"value":526}," Implement retry logic with exponential backoff for robust applications.",{"type":15,"tag":23,"props":528,"children":529},{},[530,535],{"type":15,"tag":192,"props":531,"children":532},{},[533],{"type":21,"value":534},"Keep the SDK updated.",{"type":21,"value":536}," New features and bug fixes are released regularly.",{"type":15,"tag":23,"props":538,"children":539},{},[540],{"type":21,"value":541},"For complete documentation, refer to the SDK's README on GitHub or explore the source code for implementation details.",{"type":15,"tag":543,"props":544,"children":545},"style",{},[546],{"type":21,"value":547},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":7,"searchDepth":10,"depth":10,"links":549},[550,551,552,553,554,555,556,557,558],{"id":30,"depth":10,"text":33},{"id":51,"depth":10,"text":54},{"id":96,"depth":10,"text":99},{"id":179,"depth":10,"text":182},{"id":241,"depth":10,"text":244},{"id":287,"depth":10,"text":290},{"id":303,"depth":10,"text":306},{"id":449,"depth":10,"text":452},{"id":493,"depth":10,"text":496},"markdown","content:docs:sdks:python.md","content","docs/sdks/python.md","docs/sdks/python","md",1777847380916]