# Hugging Face Hub API

The Hugging Face Hub API, accessed through the <mark style="color:yellow;">**`huggingface_hub`**</mark> package in Python, provides a comprehensive set of methods and classes to interact with the Hugging Face Hub platform.

It allows users to access and manage repositories, models, datasets, and other resources available on the Hub. Here's a detailed summary of the capabilities of the Hugging Face Hub API:

### <mark style="color:green;">Repository Management</mark>

* Create a new repository on the Hub using `create_repo()`.
* Delete a repository from the Hub using `delete_repo()`.
* Update the visibility (public/private) of a repository using `update_repo_visibility()`.
* Move a repository from one namespace to another using `move_repo()`.

### <mark style="color:green;">Model and Dataset Information</mark>

* Get information about a specific model using `model_info()`.
* Get information about a specific dataset using `dataset_info()`.
* Get information about a specific space using `space_info()`.
* Get generic repository information using `repo_info()`.

### <mark style="color:green;">Listing Resources</mark>

* List all available models on the Hub using `list_models()`.
* List all available datasets on the Hub using `list_datasets()`.
* List all available metrics on the Hub using `list_metrics()`.
* Filter models and datasets based on various criteria using `ModelFilter` and `DatasetFilter` classes.

### <mark style="color:green;">File Management</mark>

* Upload a local file to a repository using `upload_file()`.
* Delete a file from a repository using `delete_file()`.
* List all files in a repository using `list_repo_files()`.

### <mark style="color:green;">Authentication</mark>

* Set the access token for authentication using `set_access_token()`.
* Unset the access token using `unset_access_token()`.
* Get information about the authenticated user using `whoami()`.

### <mark style="color:green;">Local Storage</mark>

* The `HfFolder` class provides methods to manage local storage of authentication tokens.
* Save a token using `save_token()`, get a token using `get_token()`, and delete a token using `delete_token()`.

### <mark style="color:green;">Filtering Helpers</mark>

* The `ModelFilter` and `DatasetFilter` classes provide an easy way to construct filters for searching models and datasets based on various criteria such as author, task, language, tags, etc.
* The `ModelSearchArguments` and `DatasetSearchArguments` classes provide tab-completion and access to all possible values for properties of models and datasets hosted on the Hub.

### <mark style="color:green;">Technical Details</mark>

* The API communicates with the Hugging Face Hub platform using HTTP requests.
* Authentication is performed using access tokens, which can be obtained from the Hugging Face website and set using the <mark style="color:yellow;">**`set_access_token()`**</mark> method.
* The API uses JSON format for data exchange.
* The <mark style="color:yellow;">**`HfApi`**</mark> class serves as the main entry point for interacting with the API, and most methods are accessible directly from the <mark style="color:yellow;">**`huggingface_hub`**</mark> package.
* The API supports various parameters for filtering, sorting, and pagination when listing resources.
* Error handling is provided through specific exception classes such as <mark style="color:yellow;">**`RepositoryNotFoundError`**</mark> and <mark style="color:yellow;">**`RevisionNotFoundError`**</mark>.
* The API allows specifying the revision (e.g., branch or tag) when accessing repository-related information.
* The <mark style="color:yellow;">**`upload_file()`**</mark> method supports uploading files up to 5GB in size.

The Hugging Face Hub API provides a powerful and flexible way to interact with the Hugging Face Hub platform programmatically.&#x20;

It enables users to manage repositories, access model and dataset information, upload and delete files, and perform various search and filtering operations.&#x20;
