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 st_newsapi_connector.connection import NewsAPIConnection
conn_newsapi = st.connection("NewsAPI", type=NewsAPIConnection)
# Retrieves News Articles on a specific topic from the NewsAPI
df = conn_newsapi.everything(topic="AI, LLMs")
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
requests==2.31.0
streamlit==1.28.1
👩💻 Streamlit Web App
Demo Web App deployed to Streamlit Cloud and available at https://st-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.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a54b5d620a1cee7b47ecfe007b53cc4a672339cdff6a28526ffba5419ac31657 |
|
MD5 | 03559e5390004ec4e1c4b9176e79abf5 |
|
BLAKE2b-256 | d4fc602af382b2e4747f32e5ab2d99d5b3546db9c90935cf9edf63651bd3b1a2 |
Close
Hashes for st_newsapi_connector-0.1.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3fa84aed575187613d297190c0d31da2af01563ca062e0f60bce3e13ab1db1d |
|
MD5 | e1a64e2c8b2708b7e21ed249ca475ca5 |
|
BLAKE2b-256 | 297c14e7154ac9df00aaae3ea9fc412eefbd0e2f0918d2f64b68f657df598e3b |