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.
@@ -0,0 +1,707 @@
1
+ # pylint: disable=R0913,R0914
2
+
3
+ """Functions for fetching information about what species have been seen."""
4
+
5
+ from ebird.api.requests.utils import call
6
+ from ebird.api.requests.validation import (
7
+ clean_areas,
8
+ clean_back,
9
+ clean_categories,
10
+ clean_detail,
11
+ clean_dist,
12
+ clean_hotspot,
13
+ clean_lat,
14
+ clean_lng,
15
+ clean_locale,
16
+ clean_max_observations,
17
+ clean_provisional,
18
+ clean_sort,
19
+ )
20
+
21
+ OBSERVATIONS_URL = "https://api.ebird.org/v2/data/obs/%s/recent"
22
+ NOTABLE_OBSERVATIONS_URL = "https://api.ebird.org/v2/data/obs/%s/recent/notable"
23
+ SPECIES_OBSERVATIONS_URL = "https://api.ebird.org/v2/data/obs/%s/recent/%s"
24
+
25
+ NEARBY_OBSERVATIONS_URL = "https://api.ebird.org/v2/data/obs/geo/recent"
26
+ NEARBY_NOTABLE_URL = "https://api.ebird.org/v2/data/obs/geo/recent/notable"
27
+ NEARBY_SPECIES_URL = "https://api.ebird.org/v2/data/obs/geo/recent/%s"
28
+
29
+
30
+ NEAREST_SPECIES_URL = "https://api.ebird.org/v2/data/nearest/geo/recent/%s"
31
+
32
+ HISTORIC_OBSERVATIONS_URL = "https://api.ebird.org/v2/data/obs/%s/historic/%s"
33
+
34
+
35
+ def get_observations(
36
+ token,
37
+ area,
38
+ back=14,
39
+ max_results=None,
40
+ locale="en",
41
+ provisional=False,
42
+ hotspot=False,
43
+ detail="simple",
44
+ category=None,
45
+ ):
46
+ """Get recent observations (up to 30 days ago) for a region or location.
47
+
48
+ The maps to the end point in the eBird API 2.0,
49
+ https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#3d2a17c1-2129-475c-b4c8-7d362d6000cd
50
+
51
+ :param token: the token needed to access the API.
52
+
53
+ :param area: a country, subnational1, subnational2 or location code
54
+ or a list of up to 10 codes. All codes must be same type.
55
+
56
+ :param back: the number of days in the past to include. Ranges from
57
+ 1 to 30 with a default of 14 days.
58
+
59
+ :param max_results: the maximum number of observations to return from
60
+ 1 to 10000. The default value is None which means all observations will
61
+ be returned.
62
+
63
+ :param locale: the language (to use) for the species common names. The
64
+ default of 'en' will use species names from the eBird/Clements checklist.
65
+ This can be any locale for which eBird has translations available. For a
66
+ complete list see, http://help.ebird.org/customer/portal/articles/1596582.
67
+
68
+ :param provisional: include records which have not yet been reviewed.
69
+ Either True or False, the default is False.
70
+
71
+ :param hotspot: return records only from hotspots, True or include both
72
+ hotspots and private locations, False (the default).
73
+
74
+ :param detail: return records in 'simple' or 'full' format. See the eBird
75
+ API documentation for a description of the fields.
76
+
77
+ :param category: one or more categories of species to return: 'domestic',
78
+ 'form', 'hybrid', 'intergrade', 'issf', 'slash', 'species' or 'spuh'.
79
+ More than one value can be given in a comma-separated string. The default
80
+ value is None and records from all categories will be returned.
81
+
82
+ :return: the list of observations in simple format.
83
+
84
+ :raises ValueError: if any of the arguments fail the validation checks.
85
+
86
+ :raises URLError if there is an error with the connection to the
87
+ eBird site.
88
+
89
+ :raises HTTPError if the eBird API returns an error.
90
+
91
+ """
92
+
93
+ cleaned = clean_areas(area)
94
+
95
+ url = OBSERVATIONS_URL % cleaned[0]
96
+
97
+ params = {
98
+ "back": clean_back(back),
99
+ "maxObservations": clean_max_observations(max_results),
100
+ "sppLocale": clean_locale(locale),
101
+ "includeProvisional": clean_provisional(provisional),
102
+ "hotspot": clean_hotspot(hotspot),
103
+ "detail": clean_detail(detail),
104
+ }
105
+
106
+ if category is not None:
107
+ params["cat"] = ",".join(clean_categories(category))
108
+
109
+ if len(cleaned) > 1:
110
+ params["r"] = ",".join(cleaned)
111
+
112
+ headers = {
113
+ "X-eBirdApiToken": token,
114
+ }
115
+
116
+ return call(url, params, headers)
117
+
118
+
119
+ def get_notable_observations(
120
+ token, area, back=14, max_results=None, locale="en", hotspot=False, detail="simple"
121
+ ):
122
+ """Get recent observations of a rare species for a region or location
123
+
124
+ Get all the recent observations (up to 30 days ago) of species classes
125
+ as rare (locally or nationally) for a country, subnational1 region,
126
+ subnational2 region or location.
127
+
128
+ The maps to the end point in the eBird API 2.0,
129
+ https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#397b9b8c-4ab9-4136-baae-3ffa4e5b26e4
130
+
131
+ :param token: the token needed to access the API.
132
+
133
+ :param area: a country, subnational1, subnational2 or location code
134
+ or a list of up to 10 codes. All codes must be same type.
135
+
136
+ :param back: the number of days in the past to include. Ranges from
137
+ 1 to 30 with a default of 14 days.
138
+
139
+ :param max_results: the maximum number of observations to return from
140
+ 1 to 10000. The default value is None which means all observations will
141
+ be returned.
142
+
143
+ :param locale: the language (to use) for the species common names. The
144
+ default of 'en' will use species names from the eBird/Clements checklist.
145
+ This can be any locale for which eBird has translations available. For a
146
+ complete list see, http://help.ebird.org/customer/portal/articles/1596582.
147
+
148
+ :param hotspot: return records only from hotspots, True or include both
149
+ hotspots and private locations, False (the default).
150
+
151
+ :param detail: return records in 'simple' or 'full' format. See the eBird
152
+ API documentation for a description of the fields.
153
+
154
+ :return: the list of observations.
155
+
156
+ :raises ValueError: if any of the arguments fail the validation checks.
157
+
158
+ :raises URLError if there is an error with the connection to the
159
+ eBird site.
160
+
161
+ :raises HTTPError if the eBird API returns an error.
162
+
163
+ """
164
+ cleaned = clean_areas(area)
165
+
166
+ url = NOTABLE_OBSERVATIONS_URL % cleaned[0]
167
+
168
+ params = {
169
+ "back": clean_back(back),
170
+ "maxObservations": clean_max_observations(max_results),
171
+ "sppLocale": clean_locale(locale),
172
+ "hotspot": clean_hotspot(hotspot),
173
+ "detail": clean_detail(detail),
174
+ }
175
+
176
+ if len(cleaned) > 1:
177
+ params["r"] = ",".join(cleaned)
178
+
179
+ headers = {
180
+ "X-eBirdApiToken": token,
181
+ }
182
+
183
+ return call(url, params, headers)
184
+
185
+
186
+ def get_species_observations(
187
+ token,
188
+ species,
189
+ area,
190
+ back=14,
191
+ max_results=None,
192
+ locale="en",
193
+ provisional=False,
194
+ hotspot=False,
195
+ detail="simple",
196
+ category=None,
197
+ ):
198
+ """Get recent observations for a given species in a region.
199
+
200
+ Get all the recent observations (up to 30 days ago) for a species
201
+ in a given region.
202
+
203
+ The maps to the end point in the eBird API 2.0,
204
+ https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#755ce9ab-dc27-4cfc-953f-c69fb0f282d9
205
+
206
+ :param token: the token needed to access the API.
207
+
208
+ :param species: the scientific name of the species.
209
+
210
+ :param area: a country, subnational1, subnational2 or location code
211
+ or a list of up to 10 codes. All codes must be same type.
212
+
213
+ :param back: the number of days in the past to include. Ranges from
214
+ 1 to 30 with a default of 14 days.
215
+
216
+ :param max_results: the maximum number of observations to return from
217
+ 1 to 10000. The default value is None which means all observations will
218
+ be returned.
219
+
220
+ :param locale: the language (to use) for the species common names. The
221
+ default of 'en' will use species names from the eBird/Clements checklist.
222
+ This can be any locale for which eBird has translations available. For a
223
+ complete list see, http://help.ebird.org/customer/portal/articles/1596582.
224
+
225
+ :param provisional: include records which have not yet been reviewed.
226
+ Either True or False, the default is False.
227
+
228
+ :param hotspot: return records only from hotspots, True or include both
229
+ hotspots and private locations, False (the default).
230
+
231
+ :param detail: return records in 'simple' or 'full' format. See the eBird
232
+ API documentation for a description of the fields.
233
+
234
+ :param category: one or more categories of species to return: 'domestic',
235
+ 'form', 'hybrid', 'intergrade', 'issf', 'slash', 'species' or 'spuh'.
236
+ More than one value can be given in a comma-separated string. The default
237
+ value is None and records from all categories will be returned. It's not clear
238
+ what the purpose of this parameter is given the species is being specified.
239
+ It is not documented on the eBird API page but it is supported by the code.
240
+
241
+ :return: the list of observations in simple format.
242
+
243
+ :raises ValueError: if any of the arguments fail the validation checks.
244
+
245
+ :raises URLError if there is an error with the connection to the
246
+ eBird site.
247
+
248
+ :raises HTTPError if the eBird API returns an error.
249
+
250
+ """
251
+ cleaned = clean_areas(area)
252
+
253
+ url = SPECIES_OBSERVATIONS_URL % (cleaned[0], species)
254
+
255
+ params = {
256
+ "back": clean_back(back),
257
+ "maxObservations": clean_max_observations(max_results),
258
+ "sppLocale": clean_locale(locale),
259
+ "includeProvisional": clean_provisional(provisional),
260
+ "hotspot": clean_hotspot(hotspot),
261
+ "detail": clean_detail(detail),
262
+ }
263
+
264
+ if category is not None:
265
+ params["cat"] = ",".join(clean_categories(category))
266
+
267
+ if len(cleaned) > 1:
268
+ params["r"] = ",".join(cleaned)
269
+
270
+ headers = {
271
+ "X-eBirdApiToken": token,
272
+ }
273
+
274
+ return call(url, params, headers)
275
+
276
+
277
+ def get_nearby_observations(
278
+ token,
279
+ lat,
280
+ lng,
281
+ dist=25,
282
+ back=14,
283
+ max_results=None,
284
+ locale="en",
285
+ provisional=False,
286
+ hotspot=False,
287
+ category=None,
288
+ sort="date",
289
+ ):
290
+ """Get nearby recent observations of each species.
291
+
292
+ Get recent observations (up to 30 days ago) of each species from all
293
+ locations in an area centered on a set of coordinates (latitude,
294
+ longitude) and optional distance (up to 50km away, with a default
295
+ distance of 25km).
296
+
297
+ NOTE: Only the most recent record of each species is returned.
298
+
299
+ The maps to the end point in the eBird API 1.1,
300
+ https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#62b5ffb3-006e-4e8a-8e50-21d90d036edc
301
+
302
+ :param token: the token needed to access the API.
303
+
304
+ :param lat: the latitude, which will be rounded to 2 decimal places.
305
+
306
+ :param lng: the longitude, which will be rounded to 2 decimal places.
307
+
308
+ :param dist: include all sites within this distance, from 0 to 50km
309
+ with a default of 25km.
310
+
311
+ :param back: the number of days in the past to include. Ranges from
312
+ 1 to 30 with a default of 14 days.
313
+
314
+ :param max_results: the maximum number of observations to return from
315
+ 1 to 10000. The default value is None which means all observations will
316
+ be returned.
317
+
318
+ :param locale: the language (to use) for the species common names. The
319
+ default of 'en_US' will use species names from the eBird/Clements checklist.
320
+ This can be any locale for which eBird has translations available. For a
321
+ complete list see, http://help.ebird.org/customer/portal/articles/1596582.
322
+
323
+ :param provisional: include records which have not yet been reviewed.
324
+ Either True or False, the default is False.
325
+
326
+ :param hotspot: get only observations from hotspots, in other words
327
+ exclude private locations. The default is False so observations will
328
+ be returned from all locations.
329
+
330
+ :param category: one or more categories of species to return: 'domestic',
331
+ 'form', 'hybrid', 'intergrade', 'issf', 'slash', 'species' or 'spuh'.
332
+ More than one value can be given in a comma-separated string. The default
333
+ value is None and records from all categories will be returned.
334
+
335
+ :param sort: return the records sorted by date, 'date' or taxonomy, 'species'.
336
+
337
+ :return: the list of observations in simple format.
338
+
339
+ :raises ValueError: if any of the arguments fail the validation checks.
340
+
341
+ :raises URLError if there is an error with the connection to the
342
+ eBird site.
343
+
344
+ :raises HTTPError if the eBird API returns an error.
345
+
346
+ """
347
+ params = {
348
+ "lat": clean_lat(lat),
349
+ "lng": clean_lng(lng),
350
+ "dist": clean_dist(dist),
351
+ "back": clean_back(back),
352
+ "maxObservations": clean_max_observations(max_results),
353
+ "sppLocale": clean_locale(locale),
354
+ "includeProvisional": clean_provisional(provisional),
355
+ "hotspot": clean_hotspot(hotspot),
356
+ "sort": clean_sort(sort),
357
+ }
358
+
359
+ if category is not None:
360
+ params["cat"] = ",".join(clean_categories(category))
361
+
362
+ headers = {
363
+ "X-eBirdApiToken": token,
364
+ }
365
+
366
+ return call(NEARBY_OBSERVATIONS_URL, params, headers)
367
+
368
+
369
+ def get_nearby_species(
370
+ token,
371
+ species,
372
+ lat,
373
+ lng,
374
+ dist=25,
375
+ back=14,
376
+ max_results=None,
377
+ locale="en",
378
+ provisional=False,
379
+ hotspot=False,
380
+ category=None,
381
+ ):
382
+ """Get most recent observation of a species nearby.
383
+
384
+ Get the most recent observation (up to 30 days ago) for a species seen at
385
+ any locations in an area centered on a set of coordinates (latitude,
386
+ longitude) and optional distance (up to 50km away).
387
+
388
+ The maps to the end point in the eBird API 1.1,
389
+ https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#20fb2c3b-ee7f-49ae-a912-9c3f16a40397
390
+
391
+ :param token: the token needed to access the API.
392
+
393
+ :param species: the scientific name of the species.
394
+
395
+ :param lat: the latitude, which will be rounded to 2 decimal places.
396
+
397
+ :param lng: the longitude, which will be rounded to 2 decimal places.
398
+
399
+ :param dist: include all sites within this distance, from 0 to 50km
400
+ with a default of 25km.
401
+
402
+ :param back: the number of days in the past to include. Ranges from
403
+ 1 to 30 with a default of 14 days.
404
+
405
+ :param max_results: the maximum number of observations to return from
406
+ 1 to 10000. The default value is None which means all observations will
407
+ be returned.
408
+
409
+ :param locale: the language (to use) for the species common names. The
410
+ default of 'en_US' will use species names from the eBird/Clements checklist.
411
+ This can be any locale for which eBird has translations available. For a
412
+ complete list see, http://help.ebird.org/customer/portal/articles/1596582.
413
+
414
+ :param provisional: include records which have not yet been reviewed.
415
+ Either True or False, the default is False.
416
+
417
+ :param hotspot: get only observations from hotspots, in other words exclude
418
+ private locations. The default is False so observations will be returned from
419
+ all locations.
420
+
421
+ :param category: one or more categories of species to return: 'domestic',
422
+ 'form', 'hybrid', 'intergrade', 'issf', 'slash', 'species' or 'spuh'.
423
+ More than one value can be given in a comma-separated string. The default
424
+ value is None and records from all categories will be returned. It's not
425
+ clear what the purpose of this parameter is given the species is being
426
+ specified. It is not documented on the eBird API page but it is supported
427
+ by the code.
428
+
429
+ :return: the list of observations in 'simple' form. See the eBird API
430
+ documentation for a description of the fields.
431
+
432
+ :raises ValueError: if any of the arguments fail the validation checks.
433
+
434
+ :raises URLError if there is an error with the connection to the
435
+ eBird site.
436
+
437
+ :raises HTTPError if the eBird API returns an error.
438
+
439
+ """
440
+ url = NEARBY_SPECIES_URL % species
441
+
442
+ params = {
443
+ "lat": clean_lat(lat),
444
+ "lng": clean_lng(lng),
445
+ "dist": clean_dist(dist),
446
+ "back": clean_back(back),
447
+ "maxObservations": clean_max_observations(max_results),
448
+ "sppLocale": clean_locale(locale),
449
+ "includeProvisional": clean_provisional(provisional),
450
+ "hotspot": clean_hotspot(hotspot),
451
+ }
452
+
453
+ if category is not None:
454
+ params["cat"] = ",".join(clean_categories(category))
455
+
456
+ headers = {
457
+ "X-eBirdApiToken": token,
458
+ }
459
+
460
+ return call(url, params, headers)
461
+
462
+
463
+ def get_nearby_notable(
464
+ token,
465
+ lat,
466
+ lng,
467
+ dist=25,
468
+ back=14,
469
+ max_results=None,
470
+ locale="en",
471
+ hotspot=False,
472
+ detail="simple",
473
+ ):
474
+ """Get the nearby, recent observations of rare species.
475
+
476
+ Get all the recent observations (up to 30 days ago) for a species seen at
477
+ locations in an area centered on a set of coordinates (latitude, longitude)
478
+ and optional distance (up to 50km away) which are locally or nationally
479
+ rare.
480
+
481
+ The maps to the end point in the eBird API 2.0,
482
+ https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#caa348bb-71f6-471c-b203-9e1643377cbc
483
+
484
+ :param token: the token needed to access the API.
485
+
486
+ :param lat: the latitude, which will be rounded to 2 decimal places.
487
+
488
+ :param lng: the longitude, which will be rounded to 2 decimal places.
489
+
490
+ :param dist: include all sites within this distance, from 0 to 50km
491
+ with a default of 25km.
492
+
493
+ :param back: the number of days in the past to include. Ranges from
494
+ 1 to 30 with a default of 14 days.
495
+
496
+ :param max_results: the maximum number of observations to return from
497
+ 1 to 10000. The default value is None which means all observations will
498
+ be returned.
499
+
500
+ :param locale: the language (to use) for the species common names. The
501
+ default of 'en_US' will use species names from the eBird/Clements checklist.
502
+ This can be any locale for which eBird has translations available. For a
503
+ complete list see, http://help.ebird.org/customer/portal/articles/1596582.
504
+
505
+ :param hotspot: get only observations from hotspots, in other words
506
+ exclude private locations. The default is False so observations will be
507
+ returned from all locations.
508
+
509
+ :param detail: return records in 'simple' or 'full' format. See the eBird
510
+ API documentation for a description of the fields.
511
+
512
+ :return: the list of observations.
513
+
514
+ :raises ValueError: if any of the arguments fail the validation checks.
515
+
516
+ :raises URLError if there is an error with the connection to the
517
+ eBird site.
518
+
519
+ :raises HTTPError if the eBird API returns an error.
520
+
521
+ """
522
+ params = {
523
+ "lat": clean_lat(lat),
524
+ "lng": clean_lng(lng),
525
+ "dist": clean_dist(dist),
526
+ "back": clean_back(back),
527
+ "maxObservations": clean_max_observations(max_results),
528
+ "sppLocale": clean_locale(locale),
529
+ "hotspot": clean_hotspot(hotspot),
530
+ "detail": clean_detail(detail),
531
+ }
532
+
533
+ headers = {
534
+ "X-eBirdApiToken": token,
535
+ }
536
+
537
+ return call(NEARBY_NOTABLE_URL, params, headers)
538
+
539
+
540
+ def get_nearest_species(
541
+ token,
542
+ species,
543
+ lat,
544
+ lng,
545
+ dist=25,
546
+ back=14,
547
+ max_results=None,
548
+ locale="en",
549
+ provisional=False,
550
+ hotspot=False,
551
+ ):
552
+ """Get the nearest, recent, observations of a species.
553
+
554
+ Get the recent observations (up to 30 days ago) for a species seen at
555
+ locations closest to a set of coordinates (latitude, longitude).
556
+
557
+ IMPORTANT: As of 2019-05-27 the dist parameter does not appear to be
558
+ respected and so this call will return records from anywhere the
559
+ specified species are reported. Also the English common name for the
560
+ species is always returned regardless of which locale is specified.
561
+
562
+ The maps to the end point in the eBird API 1.1,
563
+ https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#6bded97f-9997-477f-ab2f-94f254954ccb
564
+
565
+ :param token: the token needed to access the API.
566
+
567
+ :param species: the scientific name of the species.
568
+
569
+ :param lat: the latitude, which will be rounded to 2 decimal places.
570
+
571
+ :param lng: the longitude, which will be rounded to 2 decimal places.
572
+
573
+ :param dist: include all sites within this distance, from 0 to 50km
574
+ with a default of 25km.
575
+
576
+ :param back: the number of days in the past to include. Ranges from
577
+ 1 to 30 with a default of 14 days.
578
+
579
+ :param max_results: the maximum number of observations to return from
580
+ 1 to 1000. The default value is None which means all observations will
581
+ be returned.
582
+
583
+ :param locale: the language (to use) for the species common names. The
584
+ default of 'en_US' will use species names from the eBird/Clements checklist.
585
+ This can be any locale for which eBird has translations available. For a
586
+ complete list see, http://help.ebird.org/customer/portal/articles/1596582.
587
+
588
+ :param provisional: include records which have not yet been reviewed.
589
+ Either True or False, the default is False.
590
+
591
+ :param hotspot: get only observations from hotspots, in other words
592
+ exclude private locations. The default is False so observations will
593
+ be returned from all locations.
594
+
595
+ :return: the list of observations in 'simple' form. See the eBird API
596
+ documentation for a description of the fields.
597
+
598
+ :raises ValueError: if any of the arguments fail the validation checks.
599
+
600
+ :raises URLError if there is an error with the connection to the
601
+ eBird site.
602
+
603
+ :raises HTTPError if the eBird API returns an error.
604
+
605
+ """
606
+ url = NEAREST_SPECIES_URL % species
607
+
608
+ params = {
609
+ "lat": clean_lat(lat),
610
+ "lng": clean_lng(lng),
611
+ "back": clean_back(back),
612
+ "dist": clean_dist(dist),
613
+ "maxObservations": clean_max_observations(max_results),
614
+ "sppLocale": clean_locale(locale),
615
+ "includeProvisional": clean_provisional(provisional),
616
+ "hotspot": clean_hotspot(hotspot),
617
+ }
618
+
619
+ headers = {
620
+ "X-eBirdApiToken": token,
621
+ }
622
+
623
+ return call(url, params, headers)
624
+
625
+
626
+ def get_historic_observations(
627
+ token,
628
+ area,
629
+ date,
630
+ max_results=None,
631
+ locale="en",
632
+ provisional=False,
633
+ hotspot=False,
634
+ detail="simple",
635
+ category=None,
636
+ ):
637
+ """Get recent observations for a region.
638
+
639
+ Get all the recent observations (up to 30 days ago) for a region.
640
+
641
+ The maps to the end point in the eBird API 2.0,
642
+ https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#2d8c6ee8-c435-4e91-9f66-6d3eeb09edd2
643
+
644
+ :param token: the token needed to access the API.
645
+
646
+ :param area: a country, subnational1, subnational2 or location code
647
+ or a list of up to 10 codes. All codes must be same type.
648
+
649
+ :param date: the date, since Jan 1st 1800.
650
+
651
+ :param max_results: the maximum number of observations to return from
652
+ 1 to 10000. The default value is None which means all observations will
653
+ be returned.
654
+
655
+ :param locale: the language (to use) for the species common names. The
656
+ default of 'en_US' will use species names from the eBird/Clements checklist.
657
+ This can be any locale for which eBird has translations available. For a
658
+ complete list see, http://help.ebird.org/customer/portal/articles/1596582.
659
+
660
+ :param provisional: include records which have not yet been reviewed.
661
+ Either True or False, the default is False.
662
+
663
+ :param hotspot: return records only from hotspots, True or include both
664
+ hotspots and private locations, False (the default).
665
+
666
+ :param detail: return records in 'simple' or 'full' format. See the
667
+ eBird API documentation for a description of the fields.
668
+
669
+ :param category: one or more categories of species to return: 'domestic',
670
+ 'form', 'hybrid', 'intergrade', 'issf', 'slash', 'species' or 'spuh'.
671
+ More than one value can be given in a comma-separated string. The default
672
+ value is None and records from all categories will be returned.
673
+
674
+ :return: the list of observations in simple format.
675
+
676
+ :raises ValueError: if any of the arguments fail the validation checks.
677
+
678
+ :raises URLError if there is an error with the connection to the
679
+ eBird site.
680
+
681
+ :raises HTTPError if the eBird API returns an error.
682
+
683
+ """
684
+ cleaned = clean_areas(area)
685
+
686
+ url = HISTORIC_OBSERVATIONS_URL % (cleaned[0], date.strftime("%Y/%m/%d"))
687
+
688
+ params = {
689
+ "rank": "mrec",
690
+ "detail": clean_detail(detail),
691
+ "sppLocale": clean_locale(locale),
692
+ "includeProvisional": clean_provisional(provisional),
693
+ "hotspot": clean_hotspot(hotspot),
694
+ "maxObservations": clean_max_observations(max_results),
695
+ }
696
+
697
+ if len(cleaned) > 1:
698
+ params["r"] = ",".join(cleaned)
699
+
700
+ if category is not None:
701
+ params["cat"] = ",".join(clean_categories(category))
702
+
703
+ headers = {
704
+ "X-eBirdApiToken": token,
705
+ }
706
+
707
+ return call(url, params, headers)