Registry / http-networking / eventregistry

eventregistry

JSON →
library9.1pypypi✓ verified 90d ago

The `eventregistry` library is a Python client for interacting with the Event Registry API (eventregistry.org). It allows users to query for news articles, events, mentions, and perform text analytics. The current version is 9.1, and releases are made periodically to add new features and improve existing functionality.

pip install eventregistry
INSTALL
IMPORT
SIG · EVENTREGISTRY
E
eventregistry
http-networkingpythonv9.1
Install
3.4s avg
Import
652ms
Disk
24MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v9.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.681s · 26.1MB
glibc
py 3.10–3.910 runs
installs and imports cleanly · install 3.4s · import 0.623s · 27MB
24MB installed
● package 24MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

EventRegistry
✓ from eventregistry import EventRegistry
QueryArticles
✓ from eventregistry import QueryArticles
QueryEvents
✓ from eventregistry import QueryEvents
QueryMentions
✓ from eventregistry import QueryMentions
Introduced in v8.10. May require specific permissions to use.
EventRegistryException
✓ from eventregistry import EventRegistryException
Commonly used for API error handling.

This quickstart demonstrates how to initialize the `EventRegistry` client with an API key, construct a `QueryArticles` object to search for articles, execute the query, and print the titles of the retrieved articles. Ensure your API key is correctly set.

import os from eventregistry import EventRegistry, QueryArticles # Get API key from environment variable or replace with your key ER_API_KEY = os.environ.get('EVENT_REGISTRY_API_KEY', 'YOUR_API_KEY') if ER_API_KEY == 'YOUR_API_KEY': print("Warning: Please replace 'YOUR_API_KEY' with your actual Event Registry API key or set the EVENT_REGISTRY_API_KEY environment variable.") exit() # Initialize EventRegistry er = EventRegistry(apiKey=ER_API_KEY) # Create a query for articles about 'Python programming' in English q = QueryArticles(keywords = 'Python programming', lang = 'eng') # Execute the query and get up to 10 articles q.setRequestedResults(10) res = er.execQuery(q) # Print article titles if res and 'articles' in res and 'results' in res['articles']: print(f"Found {len(res['articles']['results'])} articles:") for article in res['articles']['results']: print(f"- {article['title']}") else: print("No articles found or an error occurred.")
Debug
Known issues
breakingVersion 9.0 and newer of the library dropped support for Python 2.x and Python <3.5. These versions now require Python 3.5+ due to the introduction of type hints.
fix
Upgrade your Python environment to version 3.5 or higher. If you need Python 2.x or older 3.x compatibility, pin `eventregistry` to a version less than 9.0 (e.g., `eventregistry==8.10`).
affects: >= 9.0
gotchaAll queries to the Event Registry API require a valid API key. Failing to provide one will result in `EventRegistryException` or similar authentication errors.
fix
Obtain an API key from eventregistry.org and pass it to the `EventRegistry` constructor, e.g., `EventRegistry(apiKey='YOUR_API_KEY')`. It's recommended to use environment variables for keys.
affects: All versions
breakingStarting from version 8.9, the library will raise exceptions (e.g., `EventRegistryException`) for specific non-200 HTTP status codes (204, 400, 401, 403). Previously, the library would repeatedly retry these requests, which could lead to indefinite loops or slow execution for invalid queries.
fix
Implement explicit error handling for `eventregistry.EventRegistryException` or other `requests.exceptions.RequestException` in your code to gracefully manage API errors and invalid requests.
affects: >= 8.9
gotchaFor advanced keyword search modes (e.g., logical 'OR' or 'AND' between keywords), the `keywordSearchMode` parameter was introduced in v9.1 for `QueryArticles`, `QueryEvents`, etc.
fix
When constructing queries, use `keywordSearchMode='OR'` or `keywordSearchMode='AND'` along with your keywords. Refer to the documentation for advanced usage examples.
affects: >= 9.1
Errors
Common errors & fixes
eventregistry.EventRegistryException: The API key 'YOUR_API_KEY' is not valid or has expired.
The provided API key is either incorrect, expired, or has exceeded its usage limits.
fix
Double-check your API key on eventregistry.org. Generate a new key if necessary, and ensure it's correctly passed to the `EventRegistry` constructor.
TypeError: QueryArticles.__init__() missing 1 required positional argument: 'keywords'
A required parameter for a query object (e.g., `keywords` for `QueryArticles` or `eventUri` for `QueryEvent`) was not provided.
fix
Consult the documentation or examples for the specific query class you are using and ensure all mandatory parameters are supplied during initialization. For `QueryArticles`, at least `keywords`, `conceptUri`, or `sourceUri` is usually needed.
ImportError: cannot import name 'EventRegistry' from 'eventregistry'
Typo in the import statement or an issue with the package installation.
fix
Verify the import statement is exactly `from eventregistry import EventRegistry`. If the error persists, try reinstalling the library: `pip install --upgrade eventregistry`.
No module named 'eventregistry'
The `eventregistry` library is not installed in the current Python environment.
fix
Install the library using pip: `pip install eventregistry`. Ensure you are running this command in the same environment where your Python script will execute.
Upgrade
Version history
9.1latest on PyPI · released Jun 23, 2023
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
eventregistry — pip install eventregistry · libregistry