{"id":6244,"library":"spaces","title":"Hugging Face Spaces Utilities (Legacy)","description":"The `spaces` library (version 0.48.2) provides utilities for interacting with Hugging Face Spaces. It largely acts as a thin wrapper around the `huggingface_hub` library, which provides the core API for managing Spaces. As of late 2023, its development appears stalled, with most new Spaces features and ongoing maintenance occurring directly within `huggingface_hub`.","status":"maintenance","version":"0.48.2","language":"en","source_language":"en","source_url":"https://github.com/huggingface/huggingface_hub","tags":["huggingface","spaces","mlops","cli"],"install":[{"cmd":"pip install spaces","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Provides the core API functionality for Hugging Face Spaces interaction.","package":"huggingface_hub","optional":false}],"imports":[{"note":"While `from spaces.api import HfApi` also works, the `HfApi` symbol is directly exposed at the top level of the `spaces` package for convenience.","wrong":"from spaces.api import HfApi","symbol":"HfApi","correct":"from spaces import HfApi"}],"quickstart":{"code":"import os\nfrom spaces import HfApi\n\n# Authenticate using an environment variable\nHF_TOKEN = os.environ.get(\"HF_TOKEN\", \"hf_YOUR_TOKEN_HERE\")\n\nif HF_TOKEN == \"hf_YOUR_TOKEN_HERE\":\n    print(\"Please set the HF_TOKEN environment variable for authentication.\")\n    print(\"You can get one from https://huggingface.co/settings/tokens\")\n    exit(1)\n\napi = HfApi(token=HF_TOKEN)\n\ntry:\n    # This example lists spaces owned by the authenticated user\n    # Note: For new features and active development, prefer 'huggingface_hub' directly.\n    user_info = api.whoami()\n    if user_info and 'name' in user_info:\n        my_spaces = api.list_spaces(author=user_info['name'])\n        print(f\"Found {len(my_spaces)} spaces for user '{user_info['name']}':\")\n        for space in my_spaces:\n            print(f\"- {space.id} (Status: {space.runtime['stage']})\")\n    else:\n        print(\"Could not retrieve user info. Check your token's permissions.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Ensure your HF_TOKEN is valid and has appropriate permissions.\")\n","lang":"python","description":"Demonstrates how to initialize the Hugging Face API client using the `spaces` library and list your Hugging Face Spaces. It highlights the use of an `HF_TOKEN` for authentication."},"warnings":[{"fix":"For up-to-date and complete Spaces API functionality, install and use `huggingface_hub` directly (`pip install huggingface_hub`), referring to its documentation.","message":"The `spaces` library (version 0.48.2) is a distinct PyPI package from `huggingface_hub`. While `spaces` leverages `huggingface_hub` internally, its development has largely stalled. New features for Hugging Face Spaces management are exclusively added to `huggingface_hub` (e.g., `v1.9.0` introduced Spaces Volumes).","severity":"gotcha","affected_versions":"All `spaces` versions (0.x)"},{"fix":"Transition existing code to use `huggingface_hub`'s `HfApi` and related classes (e.g., `from huggingface_hub import HfApi, Space, Volume`) for robust and future-proof Space management.","message":"The `spaces` library's APIs for interaction with Hugging Face Spaces have largely been superseded by more comprehensive and actively maintained functionalities within `huggingface_hub`. Using `spaces` may lead to missing modern features or encountering unpatched issues.","severity":"deprecated","affected_versions":"All `spaces` versions (0.x)"},{"fix":"Consult the `huggingface_hub` changelog for recent updates related to Spaces features. Do not expect `spaces` (0.x) to contain features from `huggingface_hub` `1.x` releases.","message":"The release notes and version numbers provided in the prompt (e.g., `v1.10.x`) pertain to the `huggingface_hub` library, not the `spaces` library itself. The `spaces` library's last release was `0.48.2` (August 2023).","severity":"gotcha","affected_versions":"All `spaces` versions (0.x)"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}