{"id":9693,"library":"dns-lexicon","title":"dns-lexicon","description":"dns-lexicon is a Python library that provides a standardized and agnostic way to manipulate DNS records across various DNS providers. It abstracts away provider-specific APIs, allowing users to manage DNS records programmatically or via a command-line interface. The library is actively maintained with frequent minor releases, typically on a monthly basis, adding new providers and fixing existing ones. The current version is 3.23.2.","status":"active","version":"3.23.2","language":"en","source_language":"en","source_url":"https://github.com/dns-lexicon/dns-lexicon","tags":["dns","domain management","dns provider","api","automation","cloudflare","godaddy","linode"],"install":[{"cmd":"pip install dns-lexicon","lang":"bash","label":"Install core library"}],"dependencies":[],"imports":[{"note":"The main entry point for the Python API is the Client class, found in the 'lexicon.client' module.","wrong":"import dns_lexicon.Client","symbol":"Client","correct":"from lexicon.client import Client"}],"quickstart":{"code":"import os\nfrom lexicon.client import Client\n\n# Example for Cloudflare. Replace with your actual provider and credentials.\n# Credentials should be stored securely, e.g., in environment variables.\nprovider_name = 'cloudflare'\ndomain_name = 'example.com' # Replace with your actual domain\n\nconfig = {\n    'provider_name': provider_name,\n    'domain': domain_name,\n    'cloudflare_token': os.environ.get('LEXICON_CLOUDFLARE_TOKEN', 'YOUR_CLOUDFLARE_API_TOKEN_HERE')\n}\n\ntry:\n    client = Client(config)\n    print(f\"Connected to {provider_name} for domain {domain_name}\")\n\n    # List all records\n    records = client.list_records()\n    print(f\"Existing records for {domain_name}:\")\n    for record in records:\n        print(f\"  ID: {record['id']}, Name: {record['name']}, Type: {record['type']}, Content: {record['content']}\")\n\n    # Example: Create a TXT record (uncomment to run)\n    # record_name = 'test-record'\n    # record_content = 'This is a test TXT record from dns-lexicon'\n    # new_record = client.create_record(rtype='TXT', name=record_name, content=record_content)\n    # print(f\"Created TXT record: {new_record['name']} -> {new_record['content']}\")\n\n    # Example: Delete a record by ID (uncomment and replace with actual ID)\n    # record_id_to_delete = 'your_record_id_here'\n    # client.delete_record(identifier=record_id_to_delete)\n    # print(f\"Deleted record with ID: {record_id_to_delete}\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to initialize a `Client` for a specific DNS provider (e.g., Cloudflare) using API credentials from environment variables or direct input, and then how to list existing DNS records for a domain. It also includes commented-out examples for creating and deleting records, which require careful use."},"warnings":[{"fix":"Update your provider configuration from `linode` to `linode4` if you are using the Linode DNS service. Review the changelog for other provider renames/removals.","message":"Breaking change in provider names: The `linode` provider was replaced by `linode4` in v3.23.0. While `linode4` is still usable for retro-compatibility, direct usage of `linode` may lead to issues or removal in future versions.","severity":"breaking","affected_versions":">=3.23.0"},{"fix":"Ensure your Python environment is running Python 3.10 or newer. Upgrade your Python installation if necessary.","message":"Python version support has been dropped incrementally. Python 3.9 support was removed in v3.22.0, and Python 3.8 support was removed in v3.19.0. The library now requires Python >= 3.10.","severity":"breaking","affected_versions":">=3.19.0"},{"fix":"Always refer to the official dns-lexicon documentation for the specific provider you are using (e.g., `cloudflare`, `godaddy`) to understand the exact authentication parameters required for the `Client` configuration dictionary.","message":"Authentication methods and required credentials are highly provider-specific. While `dns-lexicon` standardizes the API calls, the underlying authentication requirements (e.g., API keys, tokens, client IDs/secrets) vary significantly between providers. Consult the `dns-lexicon` documentation for your specific provider.","severity":"gotcha","affected_versions":"All versions"},{"fix":"When creating or updating records, ensure that the `name`, `content`, and `ttl` parameters adhere to the specific requirements of your DNS provider. For instance, `godaddy` provider in v3.18.0 improved behavior with invalid TTLs and subdomains.","message":"Some DNS providers have strict requirements or limitations on record names (e.g., subdomains), record content (e.g., specific formats for TXT records), or TTL values. Incorrect values might lead to API errors or unexpected behavior.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Check the spelling of the provider name. Refer to the dns-lexicon documentation or GitHub repository to find the list of supported providers and their exact names (e.g., 'cloudflare', 'godaddy', 'linode4').","cause":"Attempting to initialize the Client with a provider name that is not recognized or supported by dns-lexicon.","error":"ClientError: Provider 'non_existent_provider' not found."},{"fix":"Double-check your API credentials against your DNS provider's dashboard. Ensure they are correctly passed in the `config` dictionary and have the required permissions for DNS record management. Also, verify that the correct credential key names are used for your specific provider (e.g., `cloudflare_token`, `godaddy_secret`).","cause":"The credentials (API key, token, user/password) provided in the Client configuration are incorrect, expired, or lack the necessary permissions for the specified DNS provider.","error":"ClientError: Authentication failed for provider 'myprovider'. Invalid credentials."},{"fix":"Verify that the `rtype` (record type, e.g., 'A', 'AAAA', 'CNAME', 'TXT', 'MX') and `content` are consistent and valid according to DNS standards and your provider's API documentation. For instance, an 'A' record needs an IPv4 address, and a 'CNAME' record needs a hostname.","cause":"Attempting to create a DNS record with a type that does not match the provided content, or using a record type not supported by the provider for the given action.","error":"ValueError: Invalid record type 'TXT' for given content."}]}