How to have API call on streamlit?

I have built an app using Streamlit to show some graphs. In this app, I am collecting some small data from external source and then plot them. In there any facility by Streamlit to share the raw data using REST API, then others can use data?

Sure! You can call an API with any handy library – requests is the most popular choice.

import requests
import streamlit as st

data = requests.get("'https://jsonplaceholder.typicode.com/todos/1'").json()

st.write(data)
1 Like

Sorry, but what I mean by that was that, how I can use Streamlit as REST API.
In summary, I collect some data from external sources (like what you said) and I plot them by any library. In addition, I want to share these raw data for others(developers or researchers) so, they can analyze data in their own way. I want something like FastAPI to share it among others but I do not know how I can use it alongside Streamlit.

Ah, I see. No, there is not currently any way for Streamlit to also provide a REST API, unfortunately. That is definitely something we may consider adding in the future, but it’s not possible currently.

1 Like