{"id":9727,"library":"eventregistry","title":"Event Registry Python Client","description":"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.","status":"active","version":"9.1","language":"en","source_language":"en","source_url":"https://github.com/EventRegistry/event-registry-python","tags":["api-client","news","events","data-mining","text-analytics"],"install":[{"cmd":"pip install eventregistry","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"EventRegistry","correct":"from eventregistry import EventRegistry"},{"symbol":"QueryArticles","correct":"from eventregistry import QueryArticles"},{"symbol":"QueryEvents","correct":"from eventregistry import QueryEvents"},{"note":"Introduced in v8.10. May require specific permissions to use.","symbol":"QueryMentions","correct":"from eventregistry import QueryMentions"},{"note":"Commonly used for API error handling.","symbol":"EventRegistryException","correct":"from eventregistry import EventRegistryException"}],"quickstart":{"code":"import os\nfrom eventregistry import EventRegistry, QueryArticles\n\n# Get API key from environment variable or replace with your key\nER_API_KEY = os.environ.get('EVENT_REGISTRY_API_KEY', 'YOUR_API_KEY')\n\nif ER_API_KEY == 'YOUR_API_KEY':\n    print(\"Warning: Please replace 'YOUR_API_KEY' with your actual Event Registry API key or set the EVENT_REGISTRY_API_KEY environment variable.\")\n    exit()\n\n# Initialize EventRegistry\ner = EventRegistry(apiKey=ER_API_KEY)\n\n# Create a query for articles about 'Python programming' in English\nq = QueryArticles(keywords = 'Python programming', lang = 'eng')\n\n# Execute the query and get up to 10 articles\nq.setRequestedResults(10)\nres = er.execQuery(q)\n\n# Print article titles\nif res and 'articles' in res and 'results' in res['articles']:\n    print(f\"Found {len(res['articles']['results'])} articles:\")\n    for article in res['articles']['results']:\n        print(f\"- {article['title']}\")\nelse:\n    print(\"No articles found or an error occurred.\")\n","lang":"python","description":"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."},"warnings":[{"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`).","message":"Version 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.","severity":"breaking","affected_versions":">= 9.0"},{"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.","message":"All queries to the Event Registry API require a valid API key. Failing to provide one will result in `EventRegistryException` or similar authentication errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Implement explicit error handling for `eventregistry.EventRegistryException` or other `requests.exceptions.RequestException` in your code to gracefully manage API errors and invalid requests.","message":"Starting 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.","severity":"breaking","affected_versions":">= 8.9"},{"fix":"When constructing queries, use `keywordSearchMode='OR'` or `keywordSearchMode='AND'` along with your keywords. Refer to the documentation for advanced usage examples.","message":"For advanced keyword search modes (e.g., logical 'OR' or 'AND' between keywords), the `keywordSearchMode` parameter was introduced in v9.1 for `QueryArticles`, `QueryEvents`, etc.","severity":"gotcha","affected_versions":">= 9.1"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"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.","cause":"The provided API key is either incorrect, expired, or has exceeded its usage limits.","error":"eventregistry.EventRegistryException: The API key 'YOUR_API_KEY' is not valid or has expired."},{"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.","cause":"A required parameter for a query object (e.g., `keywords` for `QueryArticles` or `eventUri` for `QueryEvent`) was not provided.","error":"TypeError: QueryArticles.__init__() missing 1 required positional argument: 'keywords'"},{"fix":"Verify the import statement is exactly `from eventregistry import EventRegistry`. If the error persists, try reinstalling the library: `pip install --upgrade eventregistry`.","cause":"Typo in the import statement or an issue with the package installation.","error":"ImportError: cannot import name 'EventRegistry' from 'eventregistry'"},{"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.","cause":"The `eventregistry` library is not installed in the current Python environment.","error":"No module named 'eventregistry'"}]}