ebird-api-requests 4.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ebird/api/requests/__init__.py +39 -0
- ebird/api/requests/checklists.py +101 -0
- ebird/api/requests/client.py +410 -0
- ebird/api/requests/constants.py +108 -0
- ebird/api/requests/hotspots.py +239 -0
- ebird/api/requests/observations.py +707 -0
- ebird/api/requests/regions.py +110 -0
- ebird/api/requests/species.py +37 -0
- ebird/api/requests/statistics.py +90 -0
- ebird/api/requests/taxonomy.py +213 -0
- ebird/api/requests/utils.py +164 -0
- ebird/api/requests/validation.py +348 -0
- ebird_api_requests-4.0.0.dist-info/METADATA +389 -0
- ebird_api_requests-4.0.0.dist-info/RECORD +17 -0
- ebird_api_requests-4.0.0.dist-info/WHEEL +5 -0
- ebird_api_requests-4.0.0.dist-info/licenses/LICENSE.txt +21 -0
- ebird_api_requests-4.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# flake8: noqa
|
|
2
|
+
|
|
3
|
+
"""A set of wrapper functions for accessing the eBird API."""
|
|
4
|
+
|
|
5
|
+
__version__ = "4.0.0"
|
|
6
|
+
|
|
7
|
+
from ebird.api.requests.checklists import get_checklist, get_visits
|
|
8
|
+
from ebird.api.requests.client import Client
|
|
9
|
+
from ebird.api.requests.constants import LOCALES
|
|
10
|
+
from ebird.api.requests.hotspots import (
|
|
11
|
+
get_hotspot,
|
|
12
|
+
get_hotspots,
|
|
13
|
+
get_location,
|
|
14
|
+
get_nearby_hotspots,
|
|
15
|
+
)
|
|
16
|
+
from ebird.api.requests.observations import (
|
|
17
|
+
get_historic_observations,
|
|
18
|
+
get_nearby_notable,
|
|
19
|
+
get_nearby_observations,
|
|
20
|
+
get_nearby_species,
|
|
21
|
+
get_nearest_species,
|
|
22
|
+
get_notable_observations,
|
|
23
|
+
get_observations,
|
|
24
|
+
get_species_observations,
|
|
25
|
+
)
|
|
26
|
+
from ebird.api.requests.regions import (
|
|
27
|
+
get_adjacent_regions,
|
|
28
|
+
get_region,
|
|
29
|
+
get_regions,
|
|
30
|
+
)
|
|
31
|
+
from ebird.api.requests.species import get_species_list
|
|
32
|
+
from ebird.api.requests.statistics import get_top_100, get_totals
|
|
33
|
+
from ebird.api.requests.taxonomy import (
|
|
34
|
+
get_taxonomy,
|
|
35
|
+
get_taxonomy_forms,
|
|
36
|
+
get_taxonomy_groups,
|
|
37
|
+
get_taxonomy_locales,
|
|
38
|
+
get_taxonomy_versions,
|
|
39
|
+
)
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"""Functions for fetching checklists and information about visits."""
|
|
2
|
+
|
|
3
|
+
from ebird.api.requests.utils import call
|
|
4
|
+
from ebird.api.requests.validation import (
|
|
5
|
+
clean_area,
|
|
6
|
+
clean_code,
|
|
7
|
+
clean_date,
|
|
8
|
+
clean_max_checklists,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
CHECKLISTS_DATE_URL = "https://api.ebird.org/v2/product/lists/%s/%s"
|
|
12
|
+
CHECKLISTS_RECENT_URL = "https://api.ebird.org/v2/product/lists/%s"
|
|
13
|
+
CHECKLIST_URL = "https://api.ebird.org/v2/product/checklist/view/%s"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def get_visits(token, area, date=None, max_results=10):
|
|
17
|
+
"""
|
|
18
|
+
Get the list of checklists for an area. The most recent checklists are
|
|
19
|
+
returned if a specific date is not given.
|
|
20
|
+
|
|
21
|
+
The maps to the two end points in the eBird API 2.0,
|
|
22
|
+
https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#4416a7cc-623b-4340-ab01-80c599ede73e
|
|
23
|
+
https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#95a206d1-a20d-44e0-8c27-acb09ccbea1a
|
|
24
|
+
which return results in the same format.
|
|
25
|
+
|
|
26
|
+
The eBird API call also has a sortKey parameter which returns records
|
|
27
|
+
ordered by observation date or by creation date. Since checklists are
|
|
28
|
+
often submitted a few days after the actual visit this parameter is
|
|
29
|
+
not currently supported. The results are returned ordered by observation
|
|
30
|
+
date.
|
|
31
|
+
|
|
32
|
+
:param token: the token needed to access the API.
|
|
33
|
+
|
|
34
|
+
:param area: the code for a country, subnational1 region, subnational2
|
|
35
|
+
region or location.
|
|
36
|
+
|
|
37
|
+
:param date: the date, since Jan 1st 1800.
|
|
38
|
+
|
|
39
|
+
:param max_results: the maximum number of checklists to return from
|
|
40
|
+
1 to 200. The default value is 10.
|
|
41
|
+
|
|
42
|
+
:return: the info for all the checklists submitted.
|
|
43
|
+
|
|
44
|
+
:raises ValueError: if any of the arguments fail the validation checks.
|
|
45
|
+
|
|
46
|
+
:raises URLError if there is an error with the connection to the
|
|
47
|
+
eBird site.
|
|
48
|
+
|
|
49
|
+
:raises HTTPError if the eBird API returns an error.
|
|
50
|
+
|
|
51
|
+
"""
|
|
52
|
+
if date is not None:
|
|
53
|
+
url = CHECKLISTS_DATE_URL % (clean_area(area), clean_date(date))
|
|
54
|
+
else:
|
|
55
|
+
url = CHECKLISTS_RECENT_URL % clean_area(area)
|
|
56
|
+
|
|
57
|
+
params = {
|
|
58
|
+
"maxVisits": clean_max_checklists(max_results),
|
|
59
|
+
"sortKey": "obs_dt",
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
headers = {
|
|
63
|
+
"X-eBirdApiToken": token,
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return call(url, params, headers)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def get_checklist(token, sub_id):
|
|
70
|
+
"""
|
|
71
|
+
Get the contents of a checklist.
|
|
72
|
+
|
|
73
|
+
The information returned include the checklist attributes, date, etc. and the
|
|
74
|
+
list of observations. Only the code for the location and subnational1 are
|
|
75
|
+
included you will need to call get_hotspot_info() to get the full details
|
|
76
|
+
of the location.
|
|
77
|
+
|
|
78
|
+
The maps to the end point in the eBird API 2.0,
|
|
79
|
+
https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#4416a7cc-623b-4340-ab01-80c599ede73e
|
|
80
|
+
|
|
81
|
+
:param token: the token needed to access the API.
|
|
82
|
+
|
|
83
|
+
:param sub_id: the unique identifier for the checklist, e.g. S22893621.
|
|
84
|
+
|
|
85
|
+
:return: the details of the checklist, including the list of observations
|
|
86
|
+
|
|
87
|
+
:raises ValueError: if any of the arguments fail the validation checks.
|
|
88
|
+
|
|
89
|
+
:raises URLError if there is an error with the connection to the
|
|
90
|
+
eBird site.
|
|
91
|
+
|
|
92
|
+
:raises HTTPError if the eBird API returns an error.
|
|
93
|
+
|
|
94
|
+
"""
|
|
95
|
+
url = CHECKLIST_URL % clean_code(sub_id)
|
|
96
|
+
|
|
97
|
+
headers = {
|
|
98
|
+
"X-eBirdApiToken": token,
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return call(url, {}, headers)
|
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
# pylint: disable=R0902,R0904
|
|
2
|
+
|
|
3
|
+
"""Classes for simplifying calls to the eBird API."""
|
|
4
|
+
|
|
5
|
+
import socket
|
|
6
|
+
|
|
7
|
+
from ebird.api.requests import (
|
|
8
|
+
checklists,
|
|
9
|
+
constants,
|
|
10
|
+
hotspots,
|
|
11
|
+
observations,
|
|
12
|
+
regions,
|
|
13
|
+
statistics,
|
|
14
|
+
taxonomy,
|
|
15
|
+
)
|
|
16
|
+
from ebird.api.requests.validation import clean_locale
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class Client:
|
|
20
|
+
"""Client class to simplify interacting with the API calls.
|
|
21
|
+
|
|
22
|
+
The arguments used to initialize the client are generally API parameters
|
|
23
|
+
which stay relatively fixed for a given application, e.g. including records
|
|
24
|
+
which have not been reviewed (provisional = True) or to include records
|
|
25
|
+
from private and hotspot locations (hotspots = False).
|
|
26
|
+
|
|
27
|
+
All methods raise ValueError if any of the arguments or default values
|
|
28
|
+
cannot be validated; URLError if there is an error with the connection
|
|
29
|
+
to the eBird site or HTTPError if the eBird API returns an error.
|
|
30
|
+
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
def __init__(self, api_key, locale):
|
|
34
|
+
self.api_key = api_key
|
|
35
|
+
self.locale = clean_locale(locale)
|
|
36
|
+
self.max_observations = None
|
|
37
|
+
self.max_visits = constants.API_MAX_RESULTS
|
|
38
|
+
self.max_observers = constants.DEFAULT_MAX_OBSERVERS
|
|
39
|
+
self.back = constants.DEFAULT_BACK
|
|
40
|
+
self.category = None
|
|
41
|
+
self.detail = "full"
|
|
42
|
+
self.dist = constants.DEFAULT_DISTANCE
|
|
43
|
+
self.hotspot = False
|
|
44
|
+
self.provisional = True
|
|
45
|
+
self.sort = "date"
|
|
46
|
+
socket.setdefaulttimeout(constants.DEFAULT_TIMEOUT)
|
|
47
|
+
|
|
48
|
+
def get_observations(self, area):
|
|
49
|
+
"""Get recent observations (up to 30 days ago) for a region or location.
|
|
50
|
+
|
|
51
|
+
:param area: a country, subnational1, subnational2 or location code
|
|
52
|
+
or a list of up to 10 codes. All codes must be same type.
|
|
53
|
+
|
|
54
|
+
:return: the list of observations in simple format.
|
|
55
|
+
|
|
56
|
+
"""
|
|
57
|
+
return observations.get_observations(
|
|
58
|
+
self.api_key,
|
|
59
|
+
area,
|
|
60
|
+
back=self.back,
|
|
61
|
+
max_results=self.max_observations,
|
|
62
|
+
locale=self.locale,
|
|
63
|
+
provisional=self.provisional,
|
|
64
|
+
hotspot=self.hotspot,
|
|
65
|
+
detail=self.detail,
|
|
66
|
+
category=self.category,
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
def get_notable_observations(self, area):
|
|
70
|
+
"""Get recent observations of a rare species for a region or location
|
|
71
|
+
|
|
72
|
+
:param area: a country, subnational1, subnational2 or location code
|
|
73
|
+
or a list of up to 10 codes. All codes must be same type.
|
|
74
|
+
|
|
75
|
+
:return: the list of observations.
|
|
76
|
+
|
|
77
|
+
"""
|
|
78
|
+
return observations.get_notable_observations(
|
|
79
|
+
self.api_key,
|
|
80
|
+
area,
|
|
81
|
+
back=self.back,
|
|
82
|
+
max_results=self.max_observations,
|
|
83
|
+
locale=self.locale,
|
|
84
|
+
hotspot=self.hotspot,
|
|
85
|
+
detail=self.detail,
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
def get_species_observations(self, species, area):
|
|
89
|
+
"""Get recent observations for a given species in a region.
|
|
90
|
+
|
|
91
|
+
:param species: the scientific name of the species.
|
|
92
|
+
|
|
93
|
+
:param area: a country, subnational1, subnational2 or location code
|
|
94
|
+
or a list of up to 10 codes. All codes must be same type.
|
|
95
|
+
|
|
96
|
+
:return: the list of observations in simple format.
|
|
97
|
+
|
|
98
|
+
"""
|
|
99
|
+
return observations.get_species_observations(
|
|
100
|
+
self.api_key,
|
|
101
|
+
species,
|
|
102
|
+
area,
|
|
103
|
+
back=self.back,
|
|
104
|
+
max_results=self.max_observations,
|
|
105
|
+
locale=self.locale,
|
|
106
|
+
provisional=self.provisional,
|
|
107
|
+
hotspot=self.hotspot,
|
|
108
|
+
detail=self.detail,
|
|
109
|
+
category=self.category,
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
def get_historic_observations(self, area, date):
|
|
113
|
+
"""Get recent observations for a region.
|
|
114
|
+
|
|
115
|
+
:param area: a country, subnational1, subnational2 or location code
|
|
116
|
+
or a list of up to 10 codes. All codes must be same type.
|
|
117
|
+
|
|
118
|
+
:param date: the date, since Jan 1st 1800.
|
|
119
|
+
|
|
120
|
+
:return: the list of observations in simple format.
|
|
121
|
+
|
|
122
|
+
"""
|
|
123
|
+
return observations.get_historic_observations(
|
|
124
|
+
self.api_key,
|
|
125
|
+
area,
|
|
126
|
+
date,
|
|
127
|
+
max_results=self.max_observations,
|
|
128
|
+
locale=self.locale,
|
|
129
|
+
provisional=self.provisional,
|
|
130
|
+
hotspot=self.hotspot,
|
|
131
|
+
detail=self.detail,
|
|
132
|
+
category=self.category,
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
def get_nearby_observations(self, lat, lng, dist=25):
|
|
136
|
+
"""Get nearby recent observations of each species.
|
|
137
|
+
|
|
138
|
+
:param lat: the latitude, which will be rounded to 2 decimal places.
|
|
139
|
+
|
|
140
|
+
:param lng: the longitude, which will be rounded to 2 decimal places.
|
|
141
|
+
|
|
142
|
+
:param dist: include all sites within this distance, from 0 to 50km
|
|
143
|
+
with a default of 25km.
|
|
144
|
+
|
|
145
|
+
:return: the list of observations in simple format.
|
|
146
|
+
|
|
147
|
+
"""
|
|
148
|
+
return observations.get_nearby_observations(
|
|
149
|
+
self.api_key,
|
|
150
|
+
lat,
|
|
151
|
+
lng,
|
|
152
|
+
dist=dist,
|
|
153
|
+
back=self.back,
|
|
154
|
+
max_results=self.max_observations,
|
|
155
|
+
locale=self.locale,
|
|
156
|
+
provisional=self.provisional,
|
|
157
|
+
hotspot=self.hotspot,
|
|
158
|
+
category=self.category,
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
def get_nearby_notable(self, lat, lng, dist=25):
|
|
162
|
+
"""Get the nearby, recent observations of rare species.
|
|
163
|
+
|
|
164
|
+
:param lat: the latitude, which will be rounded to 2 decimal places.
|
|
165
|
+
|
|
166
|
+
:param lng: the longitude, which will be rounded to 2 decimal places.
|
|
167
|
+
|
|
168
|
+
:param dist: include all sites within this distance, from 0 to 50km
|
|
169
|
+
with a default of 25km.
|
|
170
|
+
|
|
171
|
+
:return: the list of observations.
|
|
172
|
+
|
|
173
|
+
"""
|
|
174
|
+
return observations.get_nearby_notable(
|
|
175
|
+
self.api_key,
|
|
176
|
+
lat,
|
|
177
|
+
lng,
|
|
178
|
+
dist=dist,
|
|
179
|
+
back=self.back,
|
|
180
|
+
max_results=self.max_observations,
|
|
181
|
+
locale=self.locale,
|
|
182
|
+
hotspot=self.hotspot,
|
|
183
|
+
detail=self.detail,
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
def get_nearby_species(self, species, lat, lng, dist=25):
|
|
187
|
+
"""Get most recent observation of a species nearby.
|
|
188
|
+
|
|
189
|
+
:param species: the scientific name of the species.
|
|
190
|
+
|
|
191
|
+
:param lat: the latitude, which will be rounded to 2 decimal places.
|
|
192
|
+
|
|
193
|
+
:param lng: the longitude, which will be rounded to 2 decimal places.
|
|
194
|
+
|
|
195
|
+
:param dist: include all sites within this distance, from 0 to 50km
|
|
196
|
+
with a default of 25km.
|
|
197
|
+
|
|
198
|
+
:return: the list of observations in 'simple' form. See the eBird API
|
|
199
|
+
documentation for a description of the fields.
|
|
200
|
+
|
|
201
|
+
"""
|
|
202
|
+
return observations.get_nearby_species(
|
|
203
|
+
self.api_key,
|
|
204
|
+
species,
|
|
205
|
+
lat,
|
|
206
|
+
lng,
|
|
207
|
+
dist=dist,
|
|
208
|
+
back=self.back,
|
|
209
|
+
max_results=self.max_observations,
|
|
210
|
+
locale=self.locale,
|
|
211
|
+
provisional=self.provisional,
|
|
212
|
+
hotspot=self.hotspot,
|
|
213
|
+
category=self.category,
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
def get_nearest_species(self, species, lat, lng, dist=25):
|
|
217
|
+
"""Get most recent observation of a species nearby.
|
|
218
|
+
|
|
219
|
+
:param species: the scientific name of the species.
|
|
220
|
+
|
|
221
|
+
:param lat: the latitude, which will be rounded to 2 decimal places.
|
|
222
|
+
|
|
223
|
+
:param lng: the longitude, which will be rounded to 2 decimal places.
|
|
224
|
+
|
|
225
|
+
:param dist: include all sites within this distance, from 0 to 50km
|
|
226
|
+
with a default of 25km.
|
|
227
|
+
|
|
228
|
+
:return: the list of observations in 'simple' form.
|
|
229
|
+
|
|
230
|
+
"""
|
|
231
|
+
return observations.get_nearest_species(
|
|
232
|
+
self.api_key,
|
|
233
|
+
species,
|
|
234
|
+
lat,
|
|
235
|
+
lng,
|
|
236
|
+
dist=dist,
|
|
237
|
+
back=self.back,
|
|
238
|
+
max_results=self.max_observations,
|
|
239
|
+
locale=self.locale,
|
|
240
|
+
provisional=self.provisional,
|
|
241
|
+
hotspot=self.hotspot,
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
def get_hotspots(self, region, back=14):
|
|
245
|
+
"""List all hotspots within a region.
|
|
246
|
+
|
|
247
|
+
:param region: the code for a country, subnational1 or subnational2 region.
|
|
248
|
+
|
|
249
|
+
:param back: the past number of days to check, default is 14.
|
|
250
|
+
|
|
251
|
+
:return: the list of hotspots.
|
|
252
|
+
|
|
253
|
+
"""
|
|
254
|
+
return hotspots.get_hotspots(self.api_key, region, back)
|
|
255
|
+
|
|
256
|
+
def get_nearby_hotspots(self, lat, lng, dist=25):
|
|
257
|
+
"""Get the list of nearby hotspots.
|
|
258
|
+
|
|
259
|
+
:param lat: the latitude, which will be rounded to 2 decimal places.
|
|
260
|
+
|
|
261
|
+
:param lng: the longitude, which will be rounded to 2 decimal places.
|
|
262
|
+
|
|
263
|
+
:param dist: include all sites within this distance, from 0 to 50km
|
|
264
|
+
with a default of 25km.
|
|
265
|
+
|
|
266
|
+
:return: the list of hotspots nearest to the given set of coordinates.
|
|
267
|
+
|
|
268
|
+
"""
|
|
269
|
+
return hotspots.get_nearby_hotspots(
|
|
270
|
+
self.api_key, lat, lng, dist, back=self.back
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
def get_hotspot(self, loc_id):
|
|
274
|
+
"""Get the geographical details of a hotspot.
|
|
275
|
+
|
|
276
|
+
:param loc_id: the location code for a hotspot, eg. L374326.
|
|
277
|
+
|
|
278
|
+
:return: the latitude, longitude, name, region, etc. for the hotspot.
|
|
279
|
+
|
|
280
|
+
"""
|
|
281
|
+
return hotspots.get_hotspot(self.api_key, loc_id)
|
|
282
|
+
|
|
283
|
+
def get_regions(self, rtype, region):
|
|
284
|
+
"""Get the list of sub-regions or a given region.
|
|
285
|
+
|
|
286
|
+
:param rtype: the region type, either 'country', 'subnational1'
|
|
287
|
+
or 'subnational2'.
|
|
288
|
+
|
|
289
|
+
:param region: the name of the region, either 'world', a country
|
|
290
|
+
or a subnational1 code.
|
|
291
|
+
|
|
292
|
+
:return: the list of sub-regions within the given region.
|
|
293
|
+
|
|
294
|
+
"""
|
|
295
|
+
return regions.get_regions(self.api_key, rtype, region)
|
|
296
|
+
|
|
297
|
+
def get_adjacent_regions(self, region):
|
|
298
|
+
"""Get the regions adjacent to a given region.
|
|
299
|
+
|
|
300
|
+
:param region: the name of the region, either a country, a subnational1
|
|
301
|
+
or a subnational2 code.
|
|
302
|
+
|
|
303
|
+
:return: the list of regions bordering the specified region.
|
|
304
|
+
|
|
305
|
+
"""
|
|
306
|
+
return regions.get_adjacent_regions(self.api_key, region)
|
|
307
|
+
|
|
308
|
+
def get_region(self, region):
|
|
309
|
+
"""Get the geographical details of a country, region or sub-region.
|
|
310
|
+
|
|
311
|
+
:param region: the code for the region, eg. US-NV.
|
|
312
|
+
|
|
313
|
+
:return: the latitude, longitude, name, region, etc. for the area.
|
|
314
|
+
|
|
315
|
+
"""
|
|
316
|
+
return regions.get_region(self.api_key, region)
|
|
317
|
+
|
|
318
|
+
def get_visits(self, area, date=None):
|
|
319
|
+
"""
|
|
320
|
+
Get the list of checklists for an area. The most recent checklists are
|
|
321
|
+
returned if a specific date is not given.
|
|
322
|
+
|
|
323
|
+
:param area: the code for a country, subnational1 region, subnational2
|
|
324
|
+
region or location.
|
|
325
|
+
|
|
326
|
+
:param date: the date, since Jan 1st 1800.
|
|
327
|
+
|
|
328
|
+
:return: the info for all the checklists submitted.
|
|
329
|
+
|
|
330
|
+
"""
|
|
331
|
+
return checklists.get_visits(
|
|
332
|
+
self.api_key, area, date, max_results=self.max_visits
|
|
333
|
+
)
|
|
334
|
+
|
|
335
|
+
def get_checklist(self, sub_id):
|
|
336
|
+
"""
|
|
337
|
+
Get the contents of a checklist.
|
|
338
|
+
|
|
339
|
+
:param sub_id: the unique identifier for the checklist, e.g. S22893621.
|
|
340
|
+
|
|
341
|
+
:return: the details of the checklist, including the list of observations
|
|
342
|
+
|
|
343
|
+
"""
|
|
344
|
+
return checklists.get_checklist(self.api_key, sub_id)
|
|
345
|
+
|
|
346
|
+
def get_top_100(self, region, date, rank="spp"):
|
|
347
|
+
"""
|
|
348
|
+
Get the observers who have seen the most species or submitted the
|
|
349
|
+
greatest number of checklists on a given date.
|
|
350
|
+
|
|
351
|
+
:param region: the code for the region, eg. US-NV.
|
|
352
|
+
|
|
353
|
+
:param date: the date, since Jan 1st 1800.
|
|
354
|
+
|
|
355
|
+
:param rank: rank the observers by species seen (spp) or number of
|
|
356
|
+
checklists submitted (cl).
|
|
357
|
+
|
|
358
|
+
:return: the list of observers.
|
|
359
|
+
|
|
360
|
+
"""
|
|
361
|
+
return statistics.get_top_100(
|
|
362
|
+
self.api_key, region, date, rank=rank, max_results=self.max_observers
|
|
363
|
+
)
|
|
364
|
+
|
|
365
|
+
def get_totals(self, area, date):
|
|
366
|
+
"""
|
|
367
|
+
Get the number of contributors, checklists submitted and species
|
|
368
|
+
seen on a given date.
|
|
369
|
+
|
|
370
|
+
:param area: the code for a country subnational1 , subnational2
|
|
371
|
+
region or location
|
|
372
|
+
|
|
373
|
+
:param date: the date, since Jan 1st 1800.
|
|
374
|
+
|
|
375
|
+
:return: the totals for the given date
|
|
376
|
+
|
|
377
|
+
"""
|
|
378
|
+
return statistics.get_totals(self.api_key, area, date)
|
|
379
|
+
|
|
380
|
+
def get_taxonomy(self):
|
|
381
|
+
"""Get the full or specific subset of the taxonomy used by eBird.
|
|
382
|
+
|
|
383
|
+
:return: the complete list of species used by eBird.
|
|
384
|
+
|
|
385
|
+
"""
|
|
386
|
+
return taxonomy.get_taxonomy(self.api_key, self.category, locale=self.locale)
|
|
387
|
+
|
|
388
|
+
def get_taxonomy_forms(self, code):
|
|
389
|
+
"""Get all the sub-specific forms of a given species.
|
|
390
|
+
|
|
391
|
+
:return: the list of codes of each sub-species.
|
|
392
|
+
|
|
393
|
+
"""
|
|
394
|
+
return taxonomy.get_taxonomy_forms(self.api_key, code)
|
|
395
|
+
|
|
396
|
+
def get_taxonomy_groups(self):
|
|
397
|
+
"""Get the names of the groups of species used in the taxonomy.
|
|
398
|
+
|
|
399
|
+
:return: the list of species groups.
|
|
400
|
+
|
|
401
|
+
"""
|
|
402
|
+
return taxonomy.get_taxonomy_groups(self.api_key, locale=self.locale)
|
|
403
|
+
|
|
404
|
+
def get_taxonomy_versions(self):
|
|
405
|
+
"""Get all versions of the taxonomy, indicating which is the latest.
|
|
406
|
+
|
|
407
|
+
:return: a list of all the taxonomy versions used by eBird.
|
|
408
|
+
|
|
409
|
+
"""
|
|
410
|
+
return taxonomy.get_taxonomy_versions(self.api_key)
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"""Various constants and values used in the API."""
|
|
2
|
+
|
|
3
|
+
DEFAULT_BACK = 14
|
|
4
|
+
DEFAULT_DETAIL = "simple"
|
|
5
|
+
DEFAULT_DISTANCE = 25
|
|
6
|
+
DEFAULT_HOTSPOTS_ONLY = "false"
|
|
7
|
+
DEFAULT_PROVISIONAL = "false"
|
|
8
|
+
DEFAULT_LOCALE = "en"
|
|
9
|
+
DEFAULT_OBSERVATION_ORDER = "date"
|
|
10
|
+
DEFAULT_SPECIES_CATEGORY = None
|
|
11
|
+
DEFAULT_TAXONOMY_ORDER = "ebird"
|
|
12
|
+
DEFAULT_MAX_OBSERVATIONS = None
|
|
13
|
+
DEFAULT_MAX_OBSERVERS = 100
|
|
14
|
+
DEFAULT_MAX_CHECKLISTS = 10
|
|
15
|
+
DEFAULT_TOP_100_RANK = "spp"
|
|
16
|
+
|
|
17
|
+
API_MAX_RESULTS = 200
|
|
18
|
+
|
|
19
|
+
LOCALES = {
|
|
20
|
+
"Bulgarian": "bg",
|
|
21
|
+
"Chinese": "zh",
|
|
22
|
+
"Chinese (Simple)": "zh_SIM",
|
|
23
|
+
"Croatian": "hr",
|
|
24
|
+
"Czech": "cs",
|
|
25
|
+
"Dutch": "nl",
|
|
26
|
+
"Danish": "da",
|
|
27
|
+
"English": "en",
|
|
28
|
+
"English (Australia)": "en_AU",
|
|
29
|
+
"English (India)": "en_IN",
|
|
30
|
+
"English (IOC)": "en_IOC",
|
|
31
|
+
"English (Hawaii)": "en_HAW",
|
|
32
|
+
"English (Kenya)": "en_KE",
|
|
33
|
+
"English (Malaysia)": "en_MY",
|
|
34
|
+
"English (New Zealand)": "en_NZ",
|
|
35
|
+
"English (Philippines)": "en_PH",
|
|
36
|
+
"English (South Africa)": "en_ZA",
|
|
37
|
+
"English (United Arab Emirates)": "en_AE",
|
|
38
|
+
"English (Great Britain)": "en_UK",
|
|
39
|
+
"English (United States)": "en_US",
|
|
40
|
+
"Faroese": "fo",
|
|
41
|
+
"Finnish": "fi",
|
|
42
|
+
"French": "fr",
|
|
43
|
+
"French (AOU)": "fr_AOU",
|
|
44
|
+
"French (Canada)": "fr_CA",
|
|
45
|
+
"German": "de",
|
|
46
|
+
"French (Guadeloupe)": "fr_GP",
|
|
47
|
+
"French (Haiti)": "fr_HT",
|
|
48
|
+
"Haitian": "ht_HT",
|
|
49
|
+
"Hebrew": "iw",
|
|
50
|
+
"Hungarian": "hu",
|
|
51
|
+
"Indonesian": "id",
|
|
52
|
+
"Icelandic": "is",
|
|
53
|
+
"Italian": "it",
|
|
54
|
+
"Japanese": "ja",
|
|
55
|
+
"Korean": "ko",
|
|
56
|
+
"Latvian": "lv",
|
|
57
|
+
"Lithuanian": "lt",
|
|
58
|
+
"Malayalam": "ml",
|
|
59
|
+
"Mongolian": "mn",
|
|
60
|
+
"Norwegian": "no",
|
|
61
|
+
"Polish": "pl",
|
|
62
|
+
"Portuguese (Portugal)": "pt_PT",
|
|
63
|
+
"Portuguese (Brasil)": "pt_BR",
|
|
64
|
+
"Russian": "ru",
|
|
65
|
+
"Serbian": "sr",
|
|
66
|
+
"Slovenian": "sl",
|
|
67
|
+
"Spanish": "es",
|
|
68
|
+
"Spanish (Argentina)": "es_AR",
|
|
69
|
+
"Spanish (Chile)": "es_CL",
|
|
70
|
+
"Spanish (Costa Rica)": "es_CR",
|
|
71
|
+
"Spanish (Cuba)": "es_CU",
|
|
72
|
+
"Spanish (Dominican Republic)": "es_DO",
|
|
73
|
+
"Spanish (Ecuador)": "es_EC",
|
|
74
|
+
"Spanish (Spain)": "es_ES",
|
|
75
|
+
"Spanish (Mexico)": "es_MX",
|
|
76
|
+
"Spanish (Panama)": "es_PA",
|
|
77
|
+
"Spanish (Puerto Rico)": "es_PR",
|
|
78
|
+
"Spanish (Uruguay)": "es_UY",
|
|
79
|
+
"Spanish (Venezuela)": "es_VE",
|
|
80
|
+
"Swedish": "sv",
|
|
81
|
+
"Thai": "th",
|
|
82
|
+
"Turkish": "tr",
|
|
83
|
+
"Ukrainian": "uk",
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
SPECIES_CATEGORIES = [
|
|
87
|
+
"domestic",
|
|
88
|
+
"form",
|
|
89
|
+
"hybrid",
|
|
90
|
+
"intergrade",
|
|
91
|
+
"issf",
|
|
92
|
+
"slash",
|
|
93
|
+
"species",
|
|
94
|
+
"spuh",
|
|
95
|
+
]
|
|
96
|
+
|
|
97
|
+
SPECIES_ORDERING = ["ebird", "merlin"]
|
|
98
|
+
|
|
99
|
+
SPECIES_SORT = ["date", "species"]
|
|
100
|
+
|
|
101
|
+
REGION_TYPES = ["country", "subnational1", "subnational2"]
|
|
102
|
+
|
|
103
|
+
TOP_100_RANK = ["spp", "cl"]
|
|
104
|
+
|
|
105
|
+
# Just occasionally the connection to eBird freezes. The timeout
|
|
106
|
+
# will raise an error which is preferable to the sitting there
|
|
107
|
+
# waiting for something to happen, when it will not.
|
|
108
|
+
DEFAULT_TIMEOUT = 30
|