Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dcarpintero/st-newsapi-connector
Streamlit Data Connector to NewsAPI. Available as a PyPi package.
https://github.com/dcarpintero/st-newsapi-connector
newsapi python streamlit streamlit-component streamlit-connection
Last synced: 3 months ago
JSON representation
Streamlit Data Connector to NewsAPI. Available as a PyPi package.
- Host: GitHub
- URL: https://github.com/dcarpintero/st-newsapi-connector
- Owner: dcarpintero
- License: mit
- Created: 2023-08-02T06:53:18.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-16T22:33:42.000Z (about 1 year ago)
- Last Synced: 2024-11-13T14:19:28.071Z (3 months ago)
- Topics: newsapi, python, streamlit, streamlit-component, streamlit-connection
- Language: Python
- Homepage: https://newsapi-connector.streamlit.app/
- Size: 17.8 MB
- Stars: 17
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Open_inStreamlit](https://img.shields.io/badge/Open%20In-Streamlit-red?logo=Streamlit)](https://newsapi-connector.streamlit.app/)
[![Python](https://img.shields.io/badge/python-%203.8-blue.svg)](https://www.python.org/)
[![PyPi](https://img.shields.io/pypi/v/st-newsapi-connector)](https://pypi.org/project/st-newsapi-connector/)
[![Build](https://img.shields.io/github/actions/workflow/status/dcarpintero/st-newsapi-connector/codecov.yml?branch=main)](https://pypi.org/project/st-newsapi-connector/)
[![CodeFactor](https://www.codefactor.io/repository/github/dcarpintero/st-newsapi-connector/badge)](https://www.codefactor.io/repository/github/dcarpintero/st-newsapi-connector)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/dcarpintero/st-newsapi-connector/blob/main/LICENSE)# 📰 Streamlit-NewsAPI Data Connector
Streamlit Data Connector component that extends Streamlit to easily integrate the [NewsAPI](https://newsapi.org/) in Streamlit Apps. Works with Streamlit >= 1.28.
## 🚀 Quickstart
1. Clone the repository:
```
git clone [email protected]:dcarpintero/st-newsapi-connector.git
```2. Create and Activate a Virtual Environment:
```
Windows:py -m venv .venv
.venv\scripts\activatemacOS/Linux
python3 -m venv .venv
source .venv/bin/activate
```3. Install dependencies:
```
pip install -r requirements.txt
```4. Launch Web Application
```
streamlit run ./app.py
```## 📄 Minimal Integration
```python
# src/app.pyimport streamlit as st
from st_newsapi_connector.connection import NewsAPIConnectionconn_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)
``````toml
# .streamlit/secrets.tomlNEWSAPI_KEY = 'your-newsapi-key'
NEWSAPI_BASE_URL = 'https://newsapi.org/v2/'
``````txt
# requirements.txtpandas==1.5.1
pycountry==22.3.5
requests==2.31.0
streamlit==1.30.1
```## 👩💻 Streamlit Web App
Demo Web App deployed to [Streamlit Cloud](https://streamlit.io/cloud) and available at https://newsapi-connector.streamlit.app/
## 📚 References
- [Streamlit BaseConnection](https://docs.streamlit.io/library/api-reference/connections/st.connections.baseconnection)
- [Streamlit Connection](https://docs.streamlit.io/library/api-reference/connections/st.connection)
- [Get Started with Streamlit Cloud](https://docs.streamlit.io/streamlit-community-cloud/get-started)
- [NewsAPI Dcoumentation](https://newsapi.org/docs)