Update the eventregistry package
masterTo update to the latest version:
If installed via pip:
pip install eventregistry --upgradeIf installed from source:
Perform a git pull within your local repository.
pip install eventregistry --upgraderepository·master·Indexed 42 days ago
https://github.com/eventregistry/event-registry-pythonA Python SDK for accessing news data via the Event Registry API. It enables developers to query articles and events using filters for sentiment, location, concepts, and categories, and provides tools to retrieve trending concepts.
To update to the latest version:
If installed via pip:
pip install eventregistry --upgradeIf installed from source:
Perform a git pull within your local repository.
pip install eventregistry --upgradeAll queries to the Event Registry API require an API key. You can obtain a key (including a free tier) from the Event Registry website. When initializing the EventRegistry class, pass your key to the apiKey parameter.
from eventregistry import *
er = EventRegistry(apiKey = 'YOUR_API_KEY')To verify that the package is installed correctly, attempt to import it in a Python shell. If no error is raised, the installation was successful.
import eventregistryYou can install the eventregistry package using pip or by cloning the GitHub repository and running the setup script.
Using pip:
pip install eventregistryFrom source:
python setup.py installpip install eventregistryUse QueryArticlesIter to search for articles or blog posts. You can filter by keywords, concepts, categories, sentiment, and location.
Key features:
QueryItems.OR([...]) to search for multiple phrases.er.getConceptUri() or er.getCategoryUri() to get the required URIs for filtering.er.getLocationUri() to filter by geographic area..execQuery(er, ...) on the query object. Use maxItems to limit results (remove it to get all available results).from eventregistry import *
er = EventRegistry(apiKey = 'YOUR_API_KEY')
# Example: Search for articles mentioning specific keywords in the USA
usUri = er.getLocationUri("USA")
q = QueryArticlesIter(
keywords = QueryItems.OR(["George Clooney", "Sandra Bullock"]),
minSentiment = 0.4,
sourceLocationUri = usUri,
dataType = ["news", "blog"]
)
for art in q.execQuery(er, sortBy = "date", maxItems = 500):
print(art)Use QueryEvents to find events related to specific keywords.
To control the output, use .setRequestedResult() with a RequestEventsInfo object to specify sorting and the number of events to return.
from eventregistry import *
er = EventRegistry(apiKey = 'YOUR_API_KEY')
q = QueryEvents(keywords = "Star Wars")
q.setRequestedResult(RequestEventsInfo(sortBy = "date", count = 50))
# Execute and print the list of events
print(er.execQuery(q))Use GetTrendingConcepts to retrieve the most popular topics currently appearing in the news.
from eventregistry import *
er = EventRegistry(apiKey = 'YOUR_API_KEY')
# Get top 10 trending concepts in the news
q = GetTrendingConcepts(source = "news", count = 10)
print(er.execQuery(q))