{"library":"pydo","title":"DigitalOcean Python Client","description":"pydo is the official Python client library for interacting with the DigitalOcean API. It provides a programmatic interface to manage DigitalOcean resources such as Droplets, Kubernetes clusters, databases, and more. Currently at version 0.30.0, the library is frequently updated (often monthly minor releases) to reflect changes and additions to the DigitalOcean OpenAPI specification.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install pydo"],"cli":null},"imports":["from pydo import Client","from pydo import models"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom pydo import Client\nfrom pydo.models import Account\n\n# Initialize a client with your DigitalOcean API token.\n# It's highly recommended to set DIGITALOCEAN_TOKEN as an environment variable.\n# Example: export DIGITALOCEAN_TOKEN=\"YOUR_DO_TOKEN\"\n# For local testing without setting env var:\nDO_TOKEN = os.environ.get(\"DIGITALOCEAN_TOKEN\", \"YOUR_DO_TOKEN\") \n\nif DO_TOKEN == \"YOUR_DO_TOKEN\":\n    print(\"WARNING: Please set the DIGITALOCEAN_TOKEN environment variable for authentication.\")\n    print(\"Using a placeholder token for demonstration purposes. API calls will likely fail.\")\n\nclient = Client(token=DO_TOKEN)\n\ntry:\n    # Fetch current account information\n    account: Account = client.account.get_account()\n    print(f\"Account Email: {account.email}\")\n    print(f\"Droplet Limit: {account.droplet_limit}\")\n    print(f\"Email Verified: {account.email_verified}\")\n\n    # Example: List up to 5 Droplets (adjust for pagination on large accounts)\n    # droplets = client.droplets.list_droplets(per_page=5)\n    # if droplets:\n    #     print(f\"First Droplet Name: {droplets[0].name}\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    if \"Unauthorized\" in str(e):\n        print(\"Please ensure your DigitalOcean API token is valid and correctly set.\")\n","lang":"python","description":"This quickstart demonstrates how to initialize the DigitalOcean client using an API token (preferably from an environment variable) and then fetch basic account information. It also includes commented-out examples for listing resources like Droplets, highlighting the common pattern for interacting with different services.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}