# Hugging face API for querying models metadata

**URL:** <https://discuss.huggingface.co/t/hugging-face-api-for-querying-models-metadata/71640>\
**Category:** Models\
**Created:** [February 2, 2024, 7:31pm UTC](https://discuss.huggingface.co/t/hugging-face-api-for-querying-models-metadata/71640 "2024-02-02T19:31:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nanolm](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@nanolm](https://discuss.huggingface.co/u/nanolm)\
**Post date:** [February 2, 2024, 7:31pm UTC](https://discuss.huggingface.co/t/hugging-face-api-for-querying-models-metadata/71640/1 "2024-02-02T19:31:46Z")

</div>

I aim to conduct an analysis of the top 1000 most downloaded models across each category from the Hugging Face model repository for my academic project, with the objective of optimizing them. Could you advise on how to access metadata for these models, such as model size, number of parameters, model type, upload date, and number of downloads? what is the best way?

---

<div class="post-metadata">

**Author:** ![nanolm](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@nanolm](https://discuss.huggingface.co/u/nanolm)\
**Post date:** [February 4, 2024, 1:34pm UTC](https://discuss.huggingface.co/t/hugging-face-api-for-querying-models-metadata/71640/2 "2024-02-04T13:34:25Z")

</div>

Could someone please help?

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](https://discuss.huggingface.co/u/nielsr)\
**Post date:** [February 4, 2024, 2:32pm UTC](https://discuss.huggingface.co/t/hugging-face-api-for-querying-models-metadata/71640/3 "2024-02-04T14:32:14Z")

</div>

Hi,

You can leverage the `huggingface_hub` Python library for that.

Refer to the docs: [https://huggingface.co/docs/huggingface\_hub/guides/search#how-to-list-repositories-](https://huggingface.co/docs/huggingface_hub/guides/search#how-to-list-repositories-).

The `ModelFilter` class will be useful for you: [HfApi Client](https://huggingface.co/docs/huggingface_hub/v0.20.3/en/package_reference/hf_api#huggingface_hub.ModelFilter).

Note, things like `model_type` are only supported for models which are natively supported in the Transformers library.

---

<div class="post-metadata">

**Author:** ![nanolm](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@nanolm](https://discuss.huggingface.co/u/nanolm)\
**Post date:** [February 8, 2024, 11:47am UTC](https://discuss.huggingface.co/t/hugging-face-api-for-querying-models-metadata/71640/4 "2024-02-08T11:47:45Z")

</div>

Thanks @nielsr !! Appreciate your help.
