Add an API to my Streamlit app

Please I want to add an API in my app on streamlit and I don’t know how! The API stands for natural language query (NLQ). Thank you

Hi - me again! :slight_smile:

It’d be helpful to clarify if you want your Streamlit app to host an API (i.e. to allow external client apps to call it), or if you want your Streamlit app to call or query external APIs (such as a NLQ to Azure Cognitive Services or OpenAI GTP-3)?

Arvindra

the 2nd option , after integrating my powerBI dashboard in streamlit app i want to call NLQ API to manipulate my data

In that case the requests HTTP library is probably all you need. You should manage API keys or security tokens (if you need authentication) in an external .env of config file. Do not include them in plain text in your Python program.

See: Requests: HTTP for Humans™ — Requests 2.26.0 documentation

1 Like

Thank you i’ll try it

What about the first case?

Not possible to expose an API via Streamlit Cloud hosted apps. You’d have to host the API yourself in another public cloud (as an API app or API microservice) where external requests can be routed to it (and authenticated, etc.).

@asehmi

Hi, please correct if i am wrong. In streamlit,

  1. it is possible to use external third party API and build the application.
  2. It is not possible to serve streamlit cloud community as backend

regards
sridhar

1, 2 are both true. In 2 you can only access the Streamlit backend via the Streamlit frontend app.

1 Like