# Can I use Spaces to host an API (not a demo site)

**URL:** <https://discuss.huggingface.co/t/can-i-use-spaces-to-host-an-api-not-a-demo-site/154159>\
**Category:** Spaces\
**Created:** [May 8, 2025, 3:57pm UTC](https://discuss.huggingface.co/t/can-i-use-spaces-to-host-an-api-not-a-demo-site/154159 "2025-05-08T15:57:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rapPayne](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/rappayne/32/47152_2.png) [@rapPayne](https://discuss.huggingface.co/u/rapPayne)\
**Post date:** [May 8, 2025, 3:57pm UTC](https://discuss.huggingface.co/t/can-i-use-spaces-to-host-an-api-not-a-demo-site/154159/1 "2025-05-08T15:57:31Z")

</div>

Say I have a demo web API that serves product data, like from an online store or something. Each product has customer-entered reviews that I want to do sentiment analysis on so I can say if the review was positive or negative. I want my API to make a fetch request to a service out there somewhere, submit the review sentence and get back the sentiment. I _thought_ I could use Spaces for that. But it seems that Spaces only allows me to host a frontend website.

Does Spaces expose an endpoint that allows HTTP POST requests? How do I access it?

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [May 9, 2025, 12:02am UTC](https://discuss.huggingface.co/t/can-i-use-spaces-to-host-an-api-not-a-demo-site/154159/2 "2025-05-09T00:02:22Z")

</div>

For API-like uses, using a dedicated endpoint is more reliable, but it is possible to use Gradio spaces as an API.

> **[Querying Gradio Apps With Curl](https://www.gradio.app/main/guides/querying-gradio-apps-with-curl)**
>
> A Step-by-Step Gradio Tutorial

> **[Getting Started With The Python Client](https://www.gradio.app/guides/getting-started-with-the-python-client)**
>
> A Step-by-Step Gradio Tutorial

> **[Inference Endpoints](https://huggingface.co/docs/inference-endpoints/index)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

---

<div class="post-metadata">

**Author:** ![rapPayne](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/rappayne/32/47152_2.png) [@rapPayne](https://discuss.huggingface.co/u/rapPayne)\
**Post date:** [May 9, 2025, 10:22pm UTC](https://discuss.huggingface.co/t/can-i-use-spaces-to-host-an-api-not-a-demo-site/154159/3 "2025-05-09T22:22:25Z")

</div>

@John6666 Thanks so much for the response. I read thru them and implemented like so:

```python
demo = gr.Interface(fn=predict, inputs='text', outputs='label')
demo.launch(strict_cors=False, share=True)

```

The log of my Space then says …

```auto
/usr/local/lib/python3.10/site-packages/gradio/blocks.py:2597: UserWarning: Setting share=True is not supported on Hugging Face Spaces
  warnings.warn(

To create a public link, set `share=True` in `launch()`.

```

This is super confusing. It looks like Hugging Face doesn’t allow API access to Spaces. What am I missing?

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [May 9, 2025, 11:27pm UTC](https://discuss.huggingface.co/t/can-i-use-spaces-to-host-an-api-not-a-demo-site/154159/4 "2025-05-09T23:27:44Z")

</div>

Yea. The warning is confusing, but it’s actually usable, so don’t worry about it. In the case of Private, there are occasional bugs, so it’s better to test with a Public mockup.
