A Python package to query data from NewsAPI in Streamlit apps
Project description
📰 Streamlit-NewsAPI Data Connector
Connect to NewsAPI from your Streamlit app. Powered by st.experimental_connection()
. Works with Streamlit >= 1.22. Read more about Streamlit Connections in the official docs.
Contributions to this repo are welcome. If you are interested in helping to maintain it, reach out to us.
🚀 Quickstart
- Clone the repository:
git clone git@github.com:dcarpintero/st-newsapi-connector.git
- Create and Activate a Virtual Environment:
Windows:
py -m venv .venv
.venv\scripts\activate
macOS/Linux
python3 -m venv .venv
source .venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
- Launch Web Application
streamlit run ./app.py
📄 Minimal Integration
# src/app.py
import streamlit as st
from newsapi.connection import NewsAPIConnection
conn_newsapi = st.experimental_connection("NewsAPI", type=NewsAPIConnection)
# Retrieves News Articles on a specific topic from the NewsAPI
df = conn_newsapi.everything(topic="ChatGPT")
st.dataframe(df)
# Retrieves Top-Headlines in a country and category from the NewsAPI
df = conn_newsapi.top_headlines(country='US', category='Science')
st.dataframe(df)
# .streamlit/secrets.toml
NEWSAPI_KEY = 'your-newsapi-key'
NEWSAPI_BASE_URL = 'https://newsapi.org/v2/'
# requirements.txt
pandas==1.5.1
pycountry==22.3.5
pytest==7.4.0
requests==2.31.0
streamlit==1.25.0
👩💻 Streamlit Web App
Demo Web App deployed to Streamlit Cloud and available at https://newsapi-connector.streamlit.app/
📚 References
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for st-newsapi-connector-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 995e2ec5de770aa1c9714df32eb491fdc7a65776aa2e0d548602a6583b5b2529 |
|
MD5 | 6374aeee644cc5bb158d1a07fea65cbf |
|
BLAKE2b-256 | 0be2b2825dc9878357457282a5bc285ca16dcf16d8ae8a6ae0ae17dbe4de1de6 |
Close
Hashes for st_newsapi_connector-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b21e5151a1e6e1b54539ed2c246bbd8ab5c8c9b4a505ccae99f11f7c47ace336 |
|
MD5 | db5d2c66e720b31958da3a83c55e7c68 |
|
BLAKE2b-256 | 9afd35975888608df28728e3d1bafeb341b79de4d0bf432a316aa35353856382 |