Model Database's logo
Join the Model Database community

and get access to the augmented documentation experience

to get started

Hub API Endpoints

We have open endpoints that you can use to retrieve information from the Hub as well as perform certain actions such as creating model, dataset or Space repos. We offer a wrapper Python library, huggingface_hub, that allows easy access to these endpoints. We also provide webhooks to receive real-time incremental info about repos. Enjoy!

Endpoints table

The base URL for those endpoints below is https://huggingface.co. For example, to construct the api/models call below, one can call the URL https://huggingface.co/api/models

Endpoint Description huggingface_hub root methods Payload
/api/models GET Get information from all models in the Hub. The response is paginated, use the Link header to get the following pages. You can specify additional parameters to have more specific results. - search: Filter based on substrings for repos and their usernames, such as resnet or microsoft - author: Filter models by an author or organization, such as huggingface or microsoft - filter: Filter based on tags, such as text-classification or spacy. - sort: Property to use when sorting, such as downloads or author. - direction: Direction in which to sort, such as -1 for descending, and anything else for ascending. - limit: Limit the number of models fetched. - full: Whether to fetch most model data, such as all tags, the files, etc. - config: Whether to also fetch the repo config. list_models() params= { "search":"search", "author":"author", "filter":"filter", "sort":"sort", "direction":"direction", "limit":"limit", "full":"full", "config":"config"}
/api/models/{repo_id} /api/models/{repo_id}/revision/{revision} GET Get all information for a specific model. model_info(repo_id, revision) headers = { "authorization" : "Bearer $token" }
/api/models-tags-by-type GET Gets all the available model tags hosted in the Hub get_model_tags()
/api/datasets GET Get information from all datasets in the Hub. The response is paginated, use the Link header to get the following pages. You can specify additional parameters to have more specific results. - search: Filter based on substrings for repos and their usernames, such as pets or microsoft - author: Filter datasets by an other or organization, such as huggingface or microsoft - filter: Filter based on tags, such as task_categories:text-classification or languages:en. - sort: Property to use when sorting, such as downloads or author. - direction: Direction in which to sort, such as -1 for descending, and anything else for ascending. - limit: Limit the number of datasets fetched. - full: Whether to fetch most dataset data, such as all tags, the files, etc. list_datasets() params= { "search":"search", "author":"author", "filter":"filter", "sort":"sort", "direction":"direction", "limit":"limit", "full":"full", "config":"config"}
/api/datasets/{repo_id} /api/datasets/{repo_id}/revision/{revision} GET Get all information for a specific dataset. - full: Whether to fetch most dataset data, such as all tags, the files, etc. dataset_info(repo_id, revision) headers = { "authorization" : "Bearer $token", "full" : "full" }
/api/datasets/{repo_id}/parquet /api/datasets/{repo_id}/parquet/{config}/{split} GET Get the list of auto-converted parquet files. headers = { "authorization" : "Bearer $token", "full" : "full" }
/api/datasets/{repo_id}/parquet/{config}/{split}/{n}.parquet GET Get the nth shard of the auto-converted parquet files. headers = { "authorization" : "Bearer $token", "full" : "full" }
/api/datasets-tags-by-type GET Gets all the available dataset tags hosted in the Hub get_dataset_tags()
/api/spaces GET Get information from all Spaces in the Hub. The response is paginated, use the Link header to get the following pages. You can specify additional parameters to have more specific results. - search: Filter based on substrings for repos and their usernames, such as resnet or microsoft - author: Filter models by an author or organization, such as huggingface or microsoft - filter: Filter based on tags, such as text-classification or spacy. - sort: Property to use when sorting, such as downloads or author. - direction: Direction in which to sort, such as -1 for descending, and anything else for ascending. - limit: Limit the number of models fetched. - full: Whether to fetch most model data, such as all tags, the files, etc. - config: Whether to also fetch the repo config. list_spaces() params= { "search":"search", "author":"author", "filter":"filter", "sort":"sort", "direction":"direction", "limit":"limit", "full":"full", "config":"config"}
/api/spaces/{repo_id} /api/spaces/{repo_id}/revision/{revision} GET Get all information for a specific model. space_info(repo_id, revision) headers = { "authorization" : "Bearer $token" }
/api/metrics GET Get information from all metrics in the Hub. list_metrics()
/api/repos/create POST Create a repository. It’s a model repo by default. - type: Type of repo (datasets or spaces; model by default). - name: Name of repo. - organization: Name of organization. - - private: Whether the repo is private. create_repo() headers = { authorization : "Bearer $token" } json= {"type":"type", "repo_id":"repo_id", "private":"private"}
/api/repos/delete DELETE Delete a repository. It’s a model repo by default. - type: Type of repo (datasets or spaces; model by default). - name: Name of repo. - organization: Name of organization. delete_repo() headers = { "authorization" : "Bearer $token" } json= {"type":"type", "name":"name", "organization":"organization"}
/api/repos/{type}/{repo_id}/settings PUT Update repo visibility. update_repo_visibility() headers = { "authorization" : "Bearer $token" } json= {"private":"private"}
/api/repos/move POST Move a repository (rename within same namespace or transfer from user to organization). move_repo() headers = { "authorization" : "Bearer $token" } json= {"fromRepo" : "namespace/repo_name", "toRepo" : "namespace2/repo_name2"}
/api/whoami-v2 GET Get username and organizations the user belongs to. whoami(token) headers = { "authorization" : "Bearer $token" }