{"id":8548,"library":"python-alfresco-api","title":"Python Alfresco API Client","description":"Python Client for all Alfresco Content Services REST APIs, built with Pydantic v2 models for robust data validation and serialization, and offering event support. It provides comprehensive coverage of Alfresco's API endpoints through dedicated subclients. The current version is 1.1.5, with frequent updates incorporating new API features and improvements.","status":"active","version":"1.1.5","language":"en","source_language":"en","source_url":"https://github.com/stevereiner/python-alfresco-api","tags":["alfresco","api-client","pydantic","content-services","cms"],"install":[{"cmd":"pip install python-alfresco-api","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core data validation and serialization models (requires v2)","package":"Pydantic"},{"reason":"HTTP communication with Alfresco API","package":"requests"}],"imports":[{"note":"The main client class resides in the 'client' submodule.","wrong":"from alfresco_api import AlfrescoClient","symbol":"AlfrescoClient","correct":"from alfresco_api.client import AlfrescoClient"},{"note":"Pydantic models are organized under 'model' and then by specific API resource (e.g., 'nodes').","wrong":"from alfresco_api.models import NodeBodyCreate","symbol":"NodeBodyCreate","correct":"from alfresco_api.model.nodes import NodeBodyCreate"}],"quickstart":{"code":"import os\nfrom alfresco_api.client import AlfrescoClient\nfrom alfresco_api.model.nodes import NodeBodyCreate\n\n# Configure Alfresco connection via environment variables\nALFRESCO_HOST = os.environ.get('ALFRESCO_HOST', 'http://localhost:8080')\nALFRESCO_USERNAME = os.environ.get('ALFRESCO_USERNAME', 'admin')\nALFRESCO_PASSWORD = os.environ.get('ALFRESCO_PASSWORD', 'admin')\n\n# Initialize the client\ntry:\n    client = AlfrescoClient(\n        host=ALFRESCO_HOST,\n        username=ALFRESCO_USERNAME,\n        password=ALFRESCO_PASSWORD\n    )\n\n    # Example: Get the 'Company Home' node by its path (v1.1.5+ feature)\n    nodes_api = client.nodes\n    company_home_node = nodes_api.get_node_by_path(relative_path='/Company Home')\n    print(f\"Successfully connected. Company Home Node ID: {company_home_node.entry.id}\")\n\n    # Example: Create a new folder\n    new_folder_name = 'MyTestFolder'\n    folder_create_body = NodeBodyCreate(\n        name=new_folder_name,\n        node_type='cm:folder',\n        properties={'cm:title': 'My Test Folder via Python API'}\n    )\n    created_folder = nodes_api.create_node(\n        node_id=company_home_node.entry.id,\n        node_body_create=folder_create_body\n    )\n    print(f\"Created folder '{new_folder_name}' with ID: {created_folder.entry.id}\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n","lang":"python","description":"This quickstart initializes the Alfresco client using environment variables for credentials, then fetches the 'Company Home' node by path and creates a new folder within it. Ensure your Alfresco instance is running and accessible."},"warnings":[{"fix":"Review the Pydantic model definitions (e.g., `NodeBodyCreate`) and update your data structures to conform to Pydantic v2 standards. Consult Pydantic v2 migration guides if necessary.","message":"The client is built on Pydantic v2. If you are migrating from a project using Pydantic v1 or an older version of this client, you may encounter `ValidationError` due to changes in model definitions and validation logic.","severity":"breaking","affected_versions":"All versions >= 1.0.0"},{"fix":"Double-check the `ALFRESCO_HOST`, `ALFRESCO_USERNAME`, and `ALFRESCO_PASSWORD` environment variables or the parameters passed directly to the `AlfrescoClient` constructor. Ensure the Alfresco instance is running and network accessible.","message":"Incorrect Alfresco host, username, or password will lead to authentication failures or connection errors. This is a common setup mistake.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade to `python-alfresco-api` version 1.1.5 or newer to leverage the most robust path-based node retrieval. For older versions, you might need to rely on ID-based lookups or custom queries.","message":"The `get_node_by_path` method (using `relative_path`) for efficient node retrieval by path was significantly improved and stabilized in v1.1.5. Older versions might have limited or different behavior.","severity":"gotcha","affected_versions":"< 1.1.5"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Change your import statement to `from alfresco_api.client import AlfrescoClient`.","cause":"The `AlfrescoClient` class is not directly in the top-level `alfresco_api` package. It resides in the `client` submodule.","error":"ModuleNotFoundError: No module named 'alfresco_api.client'"},{"fix":"Examine the specific Pydantic model being used (e.g., `NodeBodyCreate`). Ensure all required fields are present with correct data types, and that you are passing a dictionary or keyword arguments that map directly to the model's fields.","cause":"You are passing data that does not match the Pydantic v2 model's expected schema (e.g., missing required fields, wrong data types, or providing a non-dictionary object when a dictionary is expected for model instantiation).","error":"ValidationError: Input should be a valid dictionary"},{"fix":"Verify the username and password are correct for your Alfresco instance. Check the user's permissions within Alfresco. Ensure `ALFRESCO_USERNAME` and `ALFRESCO_PASSWORD` (or direct arguments) are set correctly.","cause":"The credentials (username/password) provided to the `AlfrescoClient` are incorrect or the Alfresco user lacks necessary permissions.","error":"alfresco_api.exceptions.AlfrescoAPIException: Authentication failed for user 'your_username'"}]}