You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Added**
- added use of the typing module. All parameters in the method calls use typing support to make it easier to understand what type is expected.
- added autosuggest methods `suggestEventTypes`, `suggestIndustries`, `getSdgUris`, `getSasbUris` - all to be used only when querying mentions
-
**Updated**
- `QueryArticles` class. Added filters `authorsFilter`, `videosFilter`, `linksFilter`
- `QueryMentions` class. Added several filters: `industryUri`, `sdgUri`, `sasbUri`, `esgUri`, `minSentenceIndex`, `maxSentenceIndex`, `showDuplicates`
- updated several code example files
## Accessing Event Registry's News API through Python
2
-
3
-
This library contains classes and methods that allow one to obtain from Event Registry (http://eventregistry.org) all available data, such as news articles, events, trends, etc.
4
-
5
-
The detailed documentation on how to use the library is available at the [project's wiki page](https://github.com/EventRegistry/event-registry-python/wiki). Examples of use are in the [Examples folder in the repository](https://github.com/EventRegistry/event-registry-python/tree/master/eventregistry/examples).
6
-
7
-
Changes introduced in the different versions of the module are described in the [CHANGELOG.md](https://github.com/EventRegistry/event-registry-python/blob/master/CHANGELOG.md) as well as on the [Releases](https://github.com/EventRegistry/event-registry-python/releases) page.
1
+
Event Registry is a Python package that can be used to easily access the news data available in [Event Registry](http://eventregistry.org/) through the API. The package can be used to query for articles or events by filtering using a large set of filters, like keywords, concepts, topics, sources, sentiment, date, etc. Details about the News API are available on the [landing page of the product](https://newsapi.ai/).
8
2
9
3
## Installation
10
4
11
5
Event Registry package can be installed using Python's pip installer. In the command line, simply type:
12
6
13
7
pip install eventregistry
14
8
15
-
and the package should be installed. Alternatively, you can also clone the package from the GitHub repository at https://github.com/EventRegistry/event-registry-python. After cloning it, open the command line and run:
9
+
and the package should be installed. Alternatively, you can also clone the package from the [GitHub repository](https://github.com/EventRegistry/event-registry-python). After cloning it, open the command line and run:
16
10
17
11
python setup.py install
18
12
@@ -24,7 +18,7 @@ To ensure the package has been properly installed run python and type:
24
18
import eventregistry
25
19
```
26
20
27
-
If you don't get any error messages then your installation has been successful.
21
+
If you don't get any error messages, then your installation has been successful.
28
22
29
23
### Updating the package
30
24
@@ -34,51 +28,112 @@ As features are added to the package you will need at some point to update it. I
34
28
35
29
### Authentication and API key
36
30
37
-
When making queries to Event Registry you will have to use an API key that you can obtain for free. The details how to obtain and use the key are described in the [Authorization](../../wiki/EventRegistry-class#authorization) section.
31
+
When making queries to Event Registry you will have to use an API key that you can obtain for free. The details on how to obtain and use the key are described in the [Authorization](../../wiki/EventRegistry-class#authorization) section.
38
32
39
-
## Three simple examples to make you interested
33
+
## Four simple examples to get you interested
40
34
41
-
**Find news articles that mention Tesla in the article title**
35
+
**Print a list of recently articles or blog posts from *US based sources**with positive sentiment* mentioning phrases *"George Clooney"* or *"Sandra Bullock"***
# obtain at most 500 newest articles or blog posts, remove maxItems to get all
51
+
for art in q.execQuery(er, sortBy="date", maxItems=500):
50
52
print(art)
51
53
```
52
54
53
-
**Print a list of recently added articles mentioning George Clooney**
55
+
**Print a list of most relevant *business*articles from the last month related to *Microsoft* or *Google*. The articles should be in any language (including Chinese, Arabic, ...)**
q.setRequestedResult(RequestEventsInfo(sortBy="date", count=10)) # return event details for last 10 events
70
-
print er.execQuery(q)
82
+
83
+
q = QueryEvents(keywords="Star Wars")
84
+
q.setRequestedResult(RequestEventsInfo(sortBy="date", count=50)) # request event details for latest 50 events
85
+
86
+
# get the full list of 50 events at once
87
+
print(er.execQuery(q))
71
88
```
72
89
73
-
## Run a Jupyter notebook
90
+
**Search for articles that (a) mention immigration, (b) are related to business, and (c) were published by news sources located in New York City**
74
91
75
-
We've also prepared an interactive Jupyter notebook where we demonstrate how you can use the SDK. You can run it online and modify the individual examples.
92
+
```python
93
+
from eventregistry import*
94
+
er = EventRegistry(apiKey=YOUR_API_KEY)
76
95
77
-
**[Run Jupyter notebook with examples](https://mybinder.org/v2/gh/EventRegistry/event-registry-python-intro/master)**
96
+
q = QueryArticlesIter(
97
+
# here we don't use keywords so we will also get articles that mention immigration using various synonyms
98
+
conceptUri= er.getConceptUri("immigration"),
99
+
categoryUri= er.getCategoryUri("business"),
100
+
sourceLocationUri= er.getLocationUri("New York City"))
78
101
79
-
## Where to next?
102
+
# obtain 500 articles that have were shared the most on social media
103
+
for art in q.execQuery(er, sortBy="socialScore", maxItems=500):
104
+
print(art)
105
+
```
80
106
81
-
Depending on your interest and existing knowledge of the `eventregistry` package you can check different things:
107
+
**What are the currently trending topics**
108
+
109
+
```python
110
+
from eventregistry import*
111
+
er = EventRegistry(apiKey=YOUR_API_KEY)
112
+
113
+
# top 10 trending concepts in the news
114
+
q = GetTrendingConcepts(source="news", count=10)
115
+
print(er.execQuery(q))
116
+
```
117
+
118
+
## Learning from examples
119
+
120
+
We believe that it's easiest to learn how to use our service by looking at examples. For this reason, we have prepared examples of various most used features. View the examples grouped by main search actions:
121
+
122
+
[View examples of searching for articles](https://github.com/EventRegistry/event-registry-python/blob/master/eventregistry/examples/QueryArticlesExamples.py)
123
+
124
+
[View examples of searching for events](https://github.com/EventRegistry/event-registry-python/blob/master/eventregistry/examples/QueryEventsExamples.py)
125
+
126
+
[View examples of obtaining information about an individual event](https://github.com/EventRegistry/event-registry-python/blob/master/eventregistry/examples/QueryEventExamples.py)
127
+
128
+
[Examples of how to obtain the full feed of articles](https://github.com/EventRegistry/event-registry-python/blob/master/eventregistry/examples/FeedOfNewArticlesExamples.py)
129
+
130
+
[Examples of how to obtain the full feed of events](https://github.com/EventRegistry/event-registry-python/blob/master/eventregistry/examples/FeedOfNewEventsExamples.py)
131
+
132
+
## Play with interactive Jupyter notebook
133
+
134
+
To interactively learn about how to use the SDK, see examples of use, see how to get extra meta-data properties, and more, please open [this Binder](https://mybinder.org/v2/gh/EventRegistry/event-registry-python-intro/master). You'll be able to view and modify the examples.
135
+
136
+
## Where to next?
82
137
83
138
**[Terminology](../../wiki/Terminology)**. There are numerous terms in the Event Registry that you will constantly see. If you don't know what we mean by an *event*, *story*, *concept* or *category*, you should definitely check this page first.
84
139
@@ -94,10 +149,6 @@ Depending on your interest and existing knowledge of the `eventregistry` package
94
149
95
150
**[Articles and events shared the most on social media](../../wiki/Social-shares)**. Do you want to get the list of articles that have been shared the most on Facebook and Twitter on a particular date? What about the most relevant event based on shares on social media?
96
151
97
-
**[Daily mentions and sentiment of concepts and categories](../../wiki/Number-of-mentions-in-news-or-social-media)**. Are you interested in knowing how often was a particular concept or category mentioned in the news in the previous two years? How about the sentiment expressed on social media about your favorite politician?
98
-
99
-
**[Correlations of concepts](../../wiki/Correlations)**. Do you have some time series of daily measurements? Why not find the concepts that correlate the most with it based on the number of mentions in the news.
100
-
101
152
## Data access and usage restrictions
102
153
103
-
Event Registry is a commercial service but it allows also unsubscribed users to perform a certain number of operations. Free users are not allowed to use the obtained data for any commercial purposes (see the details on our [Terms of Service page](https://newsapi.ai/terms)). In order to avoid these restrictions please contact us about the [available plans](https://newsapi.ai/plans).
154
+
Event Registry is a commercial service but it allows also unsubscribed users to perform a certain number of operations. Non-paying users are not allowed to use the obtained data for any commercial purposes (see the details on our [Terms of Service page](http://newsapi.ai/terms)) and have access to only last 30 days of content. In order to avoid these restrictions please contact us about the [available plans](http://newsapi.ai/plans).
0 commit comments