ebird-api 3.4.1__tar.gz → 4.0.0__tar.gz
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-3.4.1 → ebird_api-4.0.0}/CHANGELOG.md +8 -0
- {ebird_api-3.4.1/src/ebird_api.egg-info → ebird_api-4.0.0}/PKG-INFO +72 -57
- {ebird_api-3.4.1 → ebird_api-4.0.0}/README.md +67 -52
- {ebird_api-3.4.1 → ebird_api-4.0.0}/pyproject.toml +6 -7
- ebird_api-4.0.0/src/ebird/api/requests/__init__.py +39 -0
- {ebird_api-3.4.1/src/ebird/api → ebird_api-4.0.0/src/ebird/api/requests}/checklists.py +2 -2
- {ebird_api-3.4.1/src/ebird/api → ebird_api-4.0.0/src/ebird/api/requests}/client.py +5 -2
- {ebird_api-3.4.1/src/ebird/api → ebird_api-4.0.0/src/ebird/api/requests}/constants.py +5 -0
- {ebird_api-3.4.1/src/ebird/api → ebird_api-4.0.0/src/ebird/api/requests}/hotspots.py +2 -2
- {ebird_api-3.4.1/src/ebird/api → ebird_api-4.0.0/src/ebird/api/requests}/observations.py +2 -2
- {ebird_api-3.4.1/src/ebird/api → ebird_api-4.0.0/src/ebird/api/requests}/regions.py +2 -2
- {ebird_api-3.4.1/src/ebird/api → ebird_api-4.0.0/src/ebird/api/requests}/species.py +2 -2
- {ebird_api-3.4.1/src/ebird/api → ebird_api-4.0.0/src/ebird/api/requests}/statistics.py +2 -2
- {ebird_api-3.4.1/src/ebird/api → ebird_api-4.0.0/src/ebird/api/requests}/taxonomy.py +2 -2
- {ebird_api-3.4.1/src/ebird/api → ebird_api-4.0.0/src/ebird/api/requests}/utils.py +1 -1
- {ebird_api-3.4.1/src/ebird/api → ebird_api-4.0.0/src/ebird/api/requests}/validation.py +1 -1
- {ebird_api-3.4.1 → ebird_api-4.0.0/src/ebird_api.egg-info}/PKG-INFO +72 -57
- ebird_api-4.0.0/src/ebird_api.egg-info/SOURCES.txt +21 -0
- ebird_api-3.4.1/src/ebird/api/__init__.py +0 -35
- ebird_api-3.4.1/src/ebird_api.egg-info/SOURCES.txt +0 -21
- {ebird_api-3.4.1 → ebird_api-4.0.0}/LICENSE.txt +0 -0
- {ebird_api-3.4.1 → ebird_api-4.0.0}/setup.cfg +0 -0
- {ebird_api-3.4.1 → ebird_api-4.0.0}/setup.py +0 -0
- {ebird_api-3.4.1 → ebird_api-4.0.0}/src/ebird_api.egg-info/dependency_links.txt +0 -0
- {ebird_api-3.4.1 → ebird_api-4.0.0}/src/ebird_api.egg-info/top_level.txt +0 -0
|
@@ -8,6 +8,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
|
|
|
8
8
|
This project adheres to [PEP440](https://www.python.org/dev/peps/pep-0440/)
|
|
9
9
|
and by implication, [Semantic Versioning](http://semver.org/).
|
|
10
10
|
|
|
11
|
+
## [4.0.0] - 2025-07-09
|
|
12
|
+
- Moved the package to ebird.api.requests to make space for other projects.
|
|
13
|
+
- Changed the minimum supported python version to 3.10
|
|
14
|
+
|
|
15
|
+
## [3.4.2] - 2025-04-05
|
|
16
|
+
- Added a timeout so the client will raise an error if the connection
|
|
17
|
+
to eBird freezes
|
|
18
|
+
|
|
11
19
|
## [3.4.1] - 2025-02-12
|
|
12
20
|
- Disallow lower case location codes
|
|
13
21
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: ebird-api
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.0.0
|
|
4
4
|
Summary: Wrapper for accessing the eBird API
|
|
5
5
|
Author-email: Project Babbler <projectbabbler@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -15,27 +15,26 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
15
15
|
Classifier: Operating System :: OS Independent
|
|
16
16
|
Classifier: Programming Language :: Python
|
|
17
17
|
Classifier: Programming Language :: Python :: 3
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
20
18
|
Classifier: Programming Language :: Python :: 3.10
|
|
21
19
|
Classifier: Programming Language :: Python :: 3.11
|
|
22
20
|
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
22
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
24
23
|
Classifier: Natural Language :: English
|
|
25
24
|
Classifier: Topic :: Utilities
|
|
26
25
|
Classifier: Topic :: Internet
|
|
27
|
-
Requires-Python: >=3.
|
|
26
|
+
Requires-Python: >=3.10
|
|
28
27
|
Description-Content-Type: text/markdown
|
|
29
28
|
License-File: LICENSE.txt
|
|
29
|
+
Dynamic: license-file
|
|
30
30
|
|
|
31
|
-
[](https://travis-ci.org/ProjectBabbler/ebird-api)
|
|
32
31
|
[](https://badge.fury.io/py/ebird-api)
|
|
33
32
|
[](https://img.shields.io/pypi/pyversions/ebird-api)
|
|
34
33
|
|
|
35
34
|
# eBird API
|
|
36
35
|
|
|
37
|
-
eBird API provides a set of wrapper functions for accessing the
|
|
38
|
-
in the eBird API 2.0.
|
|
36
|
+
eBird API Requests provides a set of wrapper functions for accessing the
|
|
37
|
+
end-points in the eBird API 2.0.
|
|
39
38
|
|
|
40
39
|
## Install
|
|
41
40
|
|
|
@@ -46,23 +45,23 @@ pip install ebird-api
|
|
|
46
45
|
## Usage
|
|
47
46
|
|
|
48
47
|
Each of the functions map to a specific end-point in the API - with one or
|
|
49
|
-
two exceptions where API calls are essentially identical. The functions can
|
|
50
|
-
be grouped into five activities: fetching observations, getting information
|
|
51
|
-
on hotspots, getting information on regions, getting lists of species and
|
|
48
|
+
two exceptions where API calls are essentially identical. The functions can
|
|
49
|
+
be grouped into five activities: fetching observations, getting information
|
|
50
|
+
on hotspots, getting information on regions, getting lists of species and
|
|
52
51
|
getting statistics.
|
|
53
52
|
|
|
54
|
-
All functions support arguments (with sensible defaults) for all the query
|
|
55
|
-
parameters supported by the eBird API. Check the docstring for each function
|
|
56
|
-
for more details. There you will also find a link to the documentation for
|
|
53
|
+
All functions support arguments (with sensible defaults) for all the query
|
|
54
|
+
parameters supported by the eBird API. Check the docstring for each function
|
|
55
|
+
for more details. There you will also find a link to the documentation for
|
|
57
56
|
each end-point.
|
|
58
57
|
|
|
59
|
-
To use the API you will need to register for an API key. All you need to do is
|
|
60
|
-
fill out this [form](https://ebird.org/api/keygen) and the API key is generated
|
|
58
|
+
To use the API you will need to register for an API key. All you need to do is
|
|
59
|
+
fill out this [form](https://ebird.org/api/keygen) and the API key is generated
|
|
61
60
|
automatically.
|
|
62
61
|
|
|
63
|
-
NOTE: Use the API with some restraint. Data costs money so don't go downloading
|
|
64
|
-
all the checklists for the world or other excessive behaviour or your account will
|
|
65
|
-
get banned. If you have a project in mind get in touch with eBird and tell them
|
|
62
|
+
NOTE: Use the API with some restraint. Data costs money so don't go downloading
|
|
63
|
+
all the checklists for the world or other excessive behaviour or your account will
|
|
64
|
+
get banned. If you have a project in mind get in touch with eBird and tell them
|
|
66
65
|
what you want to do - they will be interested to hear it.
|
|
67
66
|
|
|
68
67
|
### Observations
|
|
@@ -70,12 +69,12 @@ what you want to do - they will be interested to hear it.
|
|
|
70
69
|
```python
|
|
71
70
|
import os
|
|
72
71
|
|
|
73
|
-
from ebird.api import get_observations
|
|
72
|
+
from ebird.api.requests import get_observations
|
|
74
73
|
|
|
75
74
|
# Always store secrets outside the code, so you don't accidentally
|
|
76
75
|
# commit them. Environment variables are ideal for this.
|
|
77
76
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
78
|
-
|
|
77
|
+
|
|
79
78
|
# Get observations from Woodman Pond, Madison county, New York for the past week.
|
|
80
79
|
this_week = get_observations(api_key, 'L227544', back=7)
|
|
81
80
|
|
|
@@ -89,14 +88,14 @@ state_records = get_observations(api_key, 'US-NY')
|
|
|
89
88
|
national_records = get_observations(api_key, 'US')
|
|
90
89
|
```
|
|
91
90
|
|
|
92
|
-
Any where you pass in single location or region you can also pass in a
|
|
93
|
-
list or a comma-separated string. You can specify up to 10 locations or
|
|
91
|
+
Any where you pass in single location or region you can also pass in a
|
|
92
|
+
list or a comma-separated string. You can specify up to 10 locations or
|
|
94
93
|
regions:
|
|
95
94
|
|
|
96
95
|
```python
|
|
97
96
|
import os
|
|
98
97
|
|
|
99
|
-
from ebird.api import get_observations
|
|
98
|
+
from ebird.api.requests import get_observations
|
|
100
99
|
|
|
101
100
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
102
101
|
|
|
@@ -111,14 +110,14 @@ counties = 'US-NY-103,US-NY-059,US-NY-81'
|
|
|
111
110
|
records = get_observations(api_key, locations, hotspot=False, category='species')
|
|
112
111
|
```
|
|
113
112
|
|
|
114
|
-
The common name for species can be returned in different languages by
|
|
115
|
-
specifying locale in the functions that return observations, checklists
|
|
113
|
+
The common name for species can be returned in different languages by
|
|
114
|
+
specifying locale in the functions that return observations, checklists
|
|
116
115
|
or taxonomy:
|
|
117
116
|
|
|
118
117
|
```python
|
|
119
118
|
import os
|
|
120
119
|
|
|
121
|
-
from ebird.api import get_observations
|
|
120
|
+
from ebird.api.requests import get_observations
|
|
122
121
|
|
|
123
122
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
124
123
|
|
|
@@ -126,34 +125,34 @@ records = get_observations(api_key, 'CA-QC', locale='fr')
|
|
|
126
125
|
```
|
|
127
126
|
|
|
128
127
|
In addition to getting all the observations for a given location or in
|
|
129
|
-
an area you can also get the latest observation of each species in a
|
|
128
|
+
an area you can also get the latest observation of each species in a
|
|
130
129
|
geographical area - useful for finding the nearest place to see a given
|
|
131
130
|
species:
|
|
132
131
|
|
|
133
132
|
```python
|
|
134
133
|
import os
|
|
135
134
|
|
|
136
|
-
from ebird.api import get_nearby_observations
|
|
135
|
+
from ebird.api.requests import get_nearby_observations
|
|
137
136
|
|
|
138
137
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
139
138
|
|
|
140
|
-
# Get the most recent sightings of all species seen in the last week within
|
|
139
|
+
# Get the most recent sightings of all species seen in the last week within
|
|
141
140
|
# 10km of Point Reyes National Seashore.
|
|
142
141
|
records = get_nearby_observations(api_key, 38.05, -122.94, dist=10, back=7)
|
|
143
142
|
```
|
|
144
143
|
|
|
145
|
-
The calls to get_observations() and get_nearby_observation() return all the
|
|
146
|
-
available records. You can limit the set of records returned to only include
|
|
147
|
-
notable ones (locally or nationally rare species) or limit the records to
|
|
144
|
+
The calls to get_observations() and get_nearby_observation() return all the
|
|
145
|
+
available records. You can limit the set of records returned to only include
|
|
146
|
+
notable ones (locally or nationally rare species) or limit the records to
|
|
148
147
|
a small number of species:
|
|
149
148
|
|
|
150
149
|
```python
|
|
151
150
|
import os
|
|
152
151
|
|
|
153
|
-
from ebird.api import (
|
|
154
|
-
get_notable_observations,
|
|
152
|
+
from ebird.api.requests import (
|
|
153
|
+
get_notable_observations,
|
|
155
154
|
get_nearby_notable,
|
|
156
|
-
get_species_observations,
|
|
155
|
+
get_species_observations,
|
|
157
156
|
get_nearby_species,
|
|
158
157
|
)
|
|
159
158
|
|
|
@@ -175,14 +174,14 @@ nearby_species = get_nearby_species(api_key, 'barswa', 38.05, -122.94, back=10)
|
|
|
175
174
|
For the more travel-minded you can also find out the nearest place to see a given species:
|
|
176
175
|
|
|
177
176
|
```python
|
|
178
|
-
import os
|
|
177
|
+
import os
|
|
179
178
|
|
|
180
|
-
from ebird.api import get_nearest_species
|
|
179
|
+
from ebird.api.requests import get_nearest_species
|
|
181
180
|
|
|
182
181
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
183
182
|
|
|
184
183
|
# Where is the closest place to Cornell Lab of Ornithology to see
|
|
185
|
-
# Tennessee Warbler.
|
|
184
|
+
# Tennessee Warbler.
|
|
186
185
|
locations = get_nearest_species(api_key, 'tenwar', 42.48, -76.45)
|
|
187
186
|
```
|
|
188
187
|
|
|
@@ -192,13 +191,13 @@ Depending on what time of year you try this, you might have a long way to go.
|
|
|
192
191
|
|
|
193
192
|
There are two functions for finding out what has been seen at a given location.
|
|
194
193
|
First you can get the list of checklists for a given country, region or location
|
|
195
|
-
using get_visits(). Each result returned has the unique identifier for the
|
|
194
|
+
using get_visits(). Each result returned has the unique identifier for the
|
|
196
195
|
checklist. You can then call get_checklist() to get the list of observations.
|
|
197
196
|
|
|
198
197
|
```python
|
|
199
198
|
import os
|
|
200
199
|
|
|
201
|
-
from ebird.api import get_visits, get_checklist
|
|
200
|
+
from ebird.api.requests import get_visits, get_checklist
|
|
202
201
|
|
|
203
202
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
204
203
|
|
|
@@ -223,7 +222,7 @@ on the location of a given hotspot.
|
|
|
223
222
|
```python
|
|
224
223
|
import os
|
|
225
224
|
|
|
226
|
-
from ebird.api import get_hotspots, get_nearby_hotspots, get_hotspot
|
|
225
|
+
from ebird.api.requests import get_hotspots, get_nearby_hotspots, get_hotspot
|
|
227
226
|
|
|
228
227
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
229
228
|
|
|
@@ -242,15 +241,15 @@ details = get_hotspot(api_key, 'L2313391')
|
|
|
242
241
|
|
|
243
242
|
### Regions
|
|
244
243
|
|
|
245
|
-
eBird divides the world into countries, subnational1 regions (states) or
|
|
246
|
-
subnational2 regions (counties). You can use get_regions() to get the
|
|
247
|
-
list of sub-regions for a given region. For the approximate area covered
|
|
244
|
+
eBird divides the world into countries, subnational1 regions (states) or
|
|
245
|
+
subnational2 regions (counties). You can use get_regions() to get the
|
|
246
|
+
list of sub-regions for a given region. For the approximate area covered
|
|
248
247
|
by a region use get_region().
|
|
249
248
|
|
|
250
249
|
```python
|
|
251
250
|
import os
|
|
252
251
|
|
|
253
|
-
from ebird.api import get_regions, get_adjacent_regions, get_region
|
|
252
|
+
from ebird.api.requests import get_regions, get_adjacent_regions, get_region
|
|
254
253
|
|
|
255
254
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
256
255
|
|
|
@@ -274,14 +273,14 @@ bounds = get_region(api_key, 'US-NY')
|
|
|
274
273
|
|
|
275
274
|
You can get details of all the species, subspecies, forms
|
|
276
275
|
etc. in the taxonomy used by eBird. It's the easiest way
|
|
277
|
-
of getting the codes for each species or subspecies,
|
|
276
|
+
of getting the codes for each species or subspecies,
|
|
278
277
|
e.g. horlar (Horned Lark), cangoo (Canada Goose), etc.,
|
|
279
278
|
that are used in the other API calls.
|
|
280
279
|
|
|
281
280
|
```python
|
|
282
281
|
import os
|
|
283
282
|
|
|
284
|
-
from ebird.api import get_taxonomy, get_taxonomy_forms, get_taxonomy_versions
|
|
283
|
+
from ebird.api.requests import get_taxonomy, get_taxonomy_forms, get_taxonomy_versions
|
|
285
284
|
|
|
286
285
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
287
286
|
|
|
@@ -307,14 +306,14 @@ versions = get_taxonomy_versions(api_key)
|
|
|
307
306
|
You can also get some statistics from the eBird data. The most interesting
|
|
308
307
|
is probably get_top_100() which returns the list of observers who have seen
|
|
309
308
|
the most species or submitted the largest number of checklists. The list is
|
|
310
|
-
just for a specific day so it is really only useful for "Big Days" when
|
|
309
|
+
just for a specific day so it is really only useful for "Big Days" when
|
|
311
310
|
lots of people are out trying to get the greatest number of species.
|
|
312
311
|
|
|
313
312
|
```python
|
|
314
313
|
import os
|
|
315
314
|
|
|
316
315
|
from datetime import date
|
|
317
|
-
from ebird.api import get_top_100, get_totals
|
|
316
|
+
from ebird.api.requests import get_top_100, get_totals
|
|
318
317
|
|
|
319
318
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
320
319
|
|
|
@@ -334,7 +333,7 @@ have to keep passing them as arguments.
|
|
|
334
333
|
```python
|
|
335
334
|
import os
|
|
336
335
|
|
|
337
|
-
from ebird.api import Client
|
|
336
|
+
from ebird.api.requests import Client
|
|
338
337
|
|
|
339
338
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
340
339
|
locale = 'es'
|
|
@@ -349,20 +348,36 @@ The client supports all the API functions.
|
|
|
349
348
|
|
|
350
349
|
## Formats
|
|
351
350
|
|
|
352
|
-
Most of the eBird API calls return JSON. Some of the calls such as getting
|
|
353
|
-
the hotspots for a region or getting the taxonomy also support CSV. Since
|
|
354
|
-
converting JSON to CSV is simple this library is opinionated in that it
|
|
351
|
+
Most of the eBird API calls return JSON. Some of the calls such as getting
|
|
352
|
+
the hotspots for a region or getting the taxonomy also support CSV. Since
|
|
353
|
+
converting JSON to CSV is simple this library is opinionated in that it
|
|
355
354
|
only returns JSON.
|
|
356
355
|
|
|
357
356
|
## Compatibility
|
|
358
357
|
|
|
359
|
-
ebird-api works with currently supported versions of Python, 3.
|
|
360
|
-
it is known to work with earlier versions, at least 3.5 - 3.
|
|
358
|
+
ebird-api works with currently supported versions of Python, 3.10+. However,
|
|
359
|
+
it is known to work with earlier versions, at least 3.5 - 3.8, without any
|
|
361
360
|
problems.
|
|
362
361
|
|
|
362
|
+
## Troubleshooting
|
|
363
|
+
|
|
364
|
+
Just occasionally (rarely in fact), the connection to eBird will freeze. The
|
|
365
|
+
client will raise an error but if you use the API functions directly then your
|
|
366
|
+
program will sit there forever. To fix this set a default timeout all connections
|
|
367
|
+
using:
|
|
368
|
+
|
|
369
|
+
```python
|
|
370
|
+
import socket
|
|
371
|
+
|
|
372
|
+
socket.setdefaulttimeout(30)
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
Thirty seconds is a reasonable figure, however you might change it if your
|
|
376
|
+
internet connection is slow or the eBird servers are busy.
|
|
377
|
+
|
|
363
378
|
## Links
|
|
364
379
|
|
|
365
|
-
Documentation for the eBird API: https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#intro
|
|
380
|
+
Documentation for the eBird API: https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#intro
|
|
366
381
|
though it could do with a little love and attention.
|
|
367
382
|
|
|
368
383
|
Available translations for species names: http://help.ebird.org/customer/portal/articles/1596582
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
[](https://travis-ci.org/ProjectBabbler/ebird-api)
|
|
2
1
|
[](https://badge.fury.io/py/ebird-api)
|
|
3
2
|
[](https://img.shields.io/pypi/pyversions/ebird-api)
|
|
4
3
|
|
|
5
4
|
# eBird API
|
|
6
5
|
|
|
7
|
-
eBird API provides a set of wrapper functions for accessing the
|
|
8
|
-
in the eBird API 2.0.
|
|
6
|
+
eBird API Requests provides a set of wrapper functions for accessing the
|
|
7
|
+
end-points in the eBird API 2.0.
|
|
9
8
|
|
|
10
9
|
## Install
|
|
11
10
|
|
|
@@ -16,23 +15,23 @@ pip install ebird-api
|
|
|
16
15
|
## Usage
|
|
17
16
|
|
|
18
17
|
Each of the functions map to a specific end-point in the API - with one or
|
|
19
|
-
two exceptions where API calls are essentially identical. The functions can
|
|
20
|
-
be grouped into five activities: fetching observations, getting information
|
|
21
|
-
on hotspots, getting information on regions, getting lists of species and
|
|
18
|
+
two exceptions where API calls are essentially identical. The functions can
|
|
19
|
+
be grouped into five activities: fetching observations, getting information
|
|
20
|
+
on hotspots, getting information on regions, getting lists of species and
|
|
22
21
|
getting statistics.
|
|
23
22
|
|
|
24
|
-
All functions support arguments (with sensible defaults) for all the query
|
|
25
|
-
parameters supported by the eBird API. Check the docstring for each function
|
|
26
|
-
for more details. There you will also find a link to the documentation for
|
|
23
|
+
All functions support arguments (with sensible defaults) for all the query
|
|
24
|
+
parameters supported by the eBird API. Check the docstring for each function
|
|
25
|
+
for more details. There you will also find a link to the documentation for
|
|
27
26
|
each end-point.
|
|
28
27
|
|
|
29
|
-
To use the API you will need to register for an API key. All you need to do is
|
|
30
|
-
fill out this [form](https://ebird.org/api/keygen) and the API key is generated
|
|
28
|
+
To use the API you will need to register for an API key. All you need to do is
|
|
29
|
+
fill out this [form](https://ebird.org/api/keygen) and the API key is generated
|
|
31
30
|
automatically.
|
|
32
31
|
|
|
33
|
-
NOTE: Use the API with some restraint. Data costs money so don't go downloading
|
|
34
|
-
all the checklists for the world or other excessive behaviour or your account will
|
|
35
|
-
get banned. If you have a project in mind get in touch with eBird and tell them
|
|
32
|
+
NOTE: Use the API with some restraint. Data costs money so don't go downloading
|
|
33
|
+
all the checklists for the world or other excessive behaviour or your account will
|
|
34
|
+
get banned. If you have a project in mind get in touch with eBird and tell them
|
|
36
35
|
what you want to do - they will be interested to hear it.
|
|
37
36
|
|
|
38
37
|
### Observations
|
|
@@ -40,12 +39,12 @@ what you want to do - they will be interested to hear it.
|
|
|
40
39
|
```python
|
|
41
40
|
import os
|
|
42
41
|
|
|
43
|
-
from ebird.api import get_observations
|
|
42
|
+
from ebird.api.requests import get_observations
|
|
44
43
|
|
|
45
44
|
# Always store secrets outside the code, so you don't accidentally
|
|
46
45
|
# commit them. Environment variables are ideal for this.
|
|
47
46
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
48
|
-
|
|
47
|
+
|
|
49
48
|
# Get observations from Woodman Pond, Madison county, New York for the past week.
|
|
50
49
|
this_week = get_observations(api_key, 'L227544', back=7)
|
|
51
50
|
|
|
@@ -59,14 +58,14 @@ state_records = get_observations(api_key, 'US-NY')
|
|
|
59
58
|
national_records = get_observations(api_key, 'US')
|
|
60
59
|
```
|
|
61
60
|
|
|
62
|
-
Any where you pass in single location or region you can also pass in a
|
|
63
|
-
list or a comma-separated string. You can specify up to 10 locations or
|
|
61
|
+
Any where you pass in single location or region you can also pass in a
|
|
62
|
+
list or a comma-separated string. You can specify up to 10 locations or
|
|
64
63
|
regions:
|
|
65
64
|
|
|
66
65
|
```python
|
|
67
66
|
import os
|
|
68
67
|
|
|
69
|
-
from ebird.api import get_observations
|
|
68
|
+
from ebird.api.requests import get_observations
|
|
70
69
|
|
|
71
70
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
72
71
|
|
|
@@ -81,14 +80,14 @@ counties = 'US-NY-103,US-NY-059,US-NY-81'
|
|
|
81
80
|
records = get_observations(api_key, locations, hotspot=False, category='species')
|
|
82
81
|
```
|
|
83
82
|
|
|
84
|
-
The common name for species can be returned in different languages by
|
|
85
|
-
specifying locale in the functions that return observations, checklists
|
|
83
|
+
The common name for species can be returned in different languages by
|
|
84
|
+
specifying locale in the functions that return observations, checklists
|
|
86
85
|
or taxonomy:
|
|
87
86
|
|
|
88
87
|
```python
|
|
89
88
|
import os
|
|
90
89
|
|
|
91
|
-
from ebird.api import get_observations
|
|
90
|
+
from ebird.api.requests import get_observations
|
|
92
91
|
|
|
93
92
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
94
93
|
|
|
@@ -96,34 +95,34 @@ records = get_observations(api_key, 'CA-QC', locale='fr')
|
|
|
96
95
|
```
|
|
97
96
|
|
|
98
97
|
In addition to getting all the observations for a given location or in
|
|
99
|
-
an area you can also get the latest observation of each species in a
|
|
98
|
+
an area you can also get the latest observation of each species in a
|
|
100
99
|
geographical area - useful for finding the nearest place to see a given
|
|
101
100
|
species:
|
|
102
101
|
|
|
103
102
|
```python
|
|
104
103
|
import os
|
|
105
104
|
|
|
106
|
-
from ebird.api import get_nearby_observations
|
|
105
|
+
from ebird.api.requests import get_nearby_observations
|
|
107
106
|
|
|
108
107
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
109
108
|
|
|
110
|
-
# Get the most recent sightings of all species seen in the last week within
|
|
109
|
+
# Get the most recent sightings of all species seen in the last week within
|
|
111
110
|
# 10km of Point Reyes National Seashore.
|
|
112
111
|
records = get_nearby_observations(api_key, 38.05, -122.94, dist=10, back=7)
|
|
113
112
|
```
|
|
114
113
|
|
|
115
|
-
The calls to get_observations() and get_nearby_observation() return all the
|
|
116
|
-
available records. You can limit the set of records returned to only include
|
|
117
|
-
notable ones (locally or nationally rare species) or limit the records to
|
|
114
|
+
The calls to get_observations() and get_nearby_observation() return all the
|
|
115
|
+
available records. You can limit the set of records returned to only include
|
|
116
|
+
notable ones (locally or nationally rare species) or limit the records to
|
|
118
117
|
a small number of species:
|
|
119
118
|
|
|
120
119
|
```python
|
|
121
120
|
import os
|
|
122
121
|
|
|
123
|
-
from ebird.api import (
|
|
124
|
-
get_notable_observations,
|
|
122
|
+
from ebird.api.requests import (
|
|
123
|
+
get_notable_observations,
|
|
125
124
|
get_nearby_notable,
|
|
126
|
-
get_species_observations,
|
|
125
|
+
get_species_observations,
|
|
127
126
|
get_nearby_species,
|
|
128
127
|
)
|
|
129
128
|
|
|
@@ -145,14 +144,14 @@ nearby_species = get_nearby_species(api_key, 'barswa', 38.05, -122.94, back=10)
|
|
|
145
144
|
For the more travel-minded you can also find out the nearest place to see a given species:
|
|
146
145
|
|
|
147
146
|
```python
|
|
148
|
-
import os
|
|
147
|
+
import os
|
|
149
148
|
|
|
150
|
-
from ebird.api import get_nearest_species
|
|
149
|
+
from ebird.api.requests import get_nearest_species
|
|
151
150
|
|
|
152
151
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
153
152
|
|
|
154
153
|
# Where is the closest place to Cornell Lab of Ornithology to see
|
|
155
|
-
# Tennessee Warbler.
|
|
154
|
+
# Tennessee Warbler.
|
|
156
155
|
locations = get_nearest_species(api_key, 'tenwar', 42.48, -76.45)
|
|
157
156
|
```
|
|
158
157
|
|
|
@@ -162,13 +161,13 @@ Depending on what time of year you try this, you might have a long way to go.
|
|
|
162
161
|
|
|
163
162
|
There are two functions for finding out what has been seen at a given location.
|
|
164
163
|
First you can get the list of checklists for a given country, region or location
|
|
165
|
-
using get_visits(). Each result returned has the unique identifier for the
|
|
164
|
+
using get_visits(). Each result returned has the unique identifier for the
|
|
166
165
|
checklist. You can then call get_checklist() to get the list of observations.
|
|
167
166
|
|
|
168
167
|
```python
|
|
169
168
|
import os
|
|
170
169
|
|
|
171
|
-
from ebird.api import get_visits, get_checklist
|
|
170
|
+
from ebird.api.requests import get_visits, get_checklist
|
|
172
171
|
|
|
173
172
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
174
173
|
|
|
@@ -193,7 +192,7 @@ on the location of a given hotspot.
|
|
|
193
192
|
```python
|
|
194
193
|
import os
|
|
195
194
|
|
|
196
|
-
from ebird.api import get_hotspots, get_nearby_hotspots, get_hotspot
|
|
195
|
+
from ebird.api.requests import get_hotspots, get_nearby_hotspots, get_hotspot
|
|
197
196
|
|
|
198
197
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
199
198
|
|
|
@@ -212,15 +211,15 @@ details = get_hotspot(api_key, 'L2313391')
|
|
|
212
211
|
|
|
213
212
|
### Regions
|
|
214
213
|
|
|
215
|
-
eBird divides the world into countries, subnational1 regions (states) or
|
|
216
|
-
subnational2 regions (counties). You can use get_regions() to get the
|
|
217
|
-
list of sub-regions for a given region. For the approximate area covered
|
|
214
|
+
eBird divides the world into countries, subnational1 regions (states) or
|
|
215
|
+
subnational2 regions (counties). You can use get_regions() to get the
|
|
216
|
+
list of sub-regions for a given region. For the approximate area covered
|
|
218
217
|
by a region use get_region().
|
|
219
218
|
|
|
220
219
|
```python
|
|
221
220
|
import os
|
|
222
221
|
|
|
223
|
-
from ebird.api import get_regions, get_adjacent_regions, get_region
|
|
222
|
+
from ebird.api.requests import get_regions, get_adjacent_regions, get_region
|
|
224
223
|
|
|
225
224
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
226
225
|
|
|
@@ -244,14 +243,14 @@ bounds = get_region(api_key, 'US-NY')
|
|
|
244
243
|
|
|
245
244
|
You can get details of all the species, subspecies, forms
|
|
246
245
|
etc. in the taxonomy used by eBird. It's the easiest way
|
|
247
|
-
of getting the codes for each species or subspecies,
|
|
246
|
+
of getting the codes for each species or subspecies,
|
|
248
247
|
e.g. horlar (Horned Lark), cangoo (Canada Goose), etc.,
|
|
249
248
|
that are used in the other API calls.
|
|
250
249
|
|
|
251
250
|
```python
|
|
252
251
|
import os
|
|
253
252
|
|
|
254
|
-
from ebird.api import get_taxonomy, get_taxonomy_forms, get_taxonomy_versions
|
|
253
|
+
from ebird.api.requests import get_taxonomy, get_taxonomy_forms, get_taxonomy_versions
|
|
255
254
|
|
|
256
255
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
257
256
|
|
|
@@ -277,14 +276,14 @@ versions = get_taxonomy_versions(api_key)
|
|
|
277
276
|
You can also get some statistics from the eBird data. The most interesting
|
|
278
277
|
is probably get_top_100() which returns the list of observers who have seen
|
|
279
278
|
the most species or submitted the largest number of checklists. The list is
|
|
280
|
-
just for a specific day so it is really only useful for "Big Days" when
|
|
279
|
+
just for a specific day so it is really only useful for "Big Days" when
|
|
281
280
|
lots of people are out trying to get the greatest number of species.
|
|
282
281
|
|
|
283
282
|
```python
|
|
284
283
|
import os
|
|
285
284
|
|
|
286
285
|
from datetime import date
|
|
287
|
-
from ebird.api import get_top_100, get_totals
|
|
286
|
+
from ebird.api.requests import get_top_100, get_totals
|
|
288
287
|
|
|
289
288
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
290
289
|
|
|
@@ -304,7 +303,7 @@ have to keep passing them as arguments.
|
|
|
304
303
|
```python
|
|
305
304
|
import os
|
|
306
305
|
|
|
307
|
-
from ebird.api import Client
|
|
306
|
+
from ebird.api.requests import Client
|
|
308
307
|
|
|
309
308
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
310
309
|
locale = 'es'
|
|
@@ -319,20 +318,36 @@ The client supports all the API functions.
|
|
|
319
318
|
|
|
320
319
|
## Formats
|
|
321
320
|
|
|
322
|
-
Most of the eBird API calls return JSON. Some of the calls such as getting
|
|
323
|
-
the hotspots for a region or getting the taxonomy also support CSV. Since
|
|
324
|
-
converting JSON to CSV is simple this library is opinionated in that it
|
|
321
|
+
Most of the eBird API calls return JSON. Some of the calls such as getting
|
|
322
|
+
the hotspots for a region or getting the taxonomy also support CSV. Since
|
|
323
|
+
converting JSON to CSV is simple this library is opinionated in that it
|
|
325
324
|
only returns JSON.
|
|
326
325
|
|
|
327
326
|
## Compatibility
|
|
328
327
|
|
|
329
|
-
ebird-api works with currently supported versions of Python, 3.
|
|
330
|
-
it is known to work with earlier versions, at least 3.5 - 3.
|
|
328
|
+
ebird-api works with currently supported versions of Python, 3.10+. However,
|
|
329
|
+
it is known to work with earlier versions, at least 3.5 - 3.8, without any
|
|
331
330
|
problems.
|
|
332
331
|
|
|
332
|
+
## Troubleshooting
|
|
333
|
+
|
|
334
|
+
Just occasionally (rarely in fact), the connection to eBird will freeze. The
|
|
335
|
+
client will raise an error but if you use the API functions directly then your
|
|
336
|
+
program will sit there forever. To fix this set a default timeout all connections
|
|
337
|
+
using:
|
|
338
|
+
|
|
339
|
+
```python
|
|
340
|
+
import socket
|
|
341
|
+
|
|
342
|
+
socket.setdefaulttimeout(30)
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
Thirty seconds is a reasonable figure, however you might change it if your
|
|
346
|
+
internet connection is slow or the eBird servers are busy.
|
|
347
|
+
|
|
333
348
|
## Links
|
|
334
349
|
|
|
335
|
-
Documentation for the eBird API: https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#intro
|
|
350
|
+
Documentation for the eBird API: https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#intro
|
|
336
351
|
though it could do with a little love and attention.
|
|
337
352
|
|
|
338
353
|
Available translations for species names: http://help.ebird.org/customer/portal/articles/1596582
|
|
@@ -14,11 +14,10 @@ classifiers = [
|
|
|
14
14
|
"Operating System :: OS Independent",
|
|
15
15
|
"Programming Language :: Python",
|
|
16
16
|
"Programming Language :: Python :: 3",
|
|
17
|
-
"Programming Language :: Python :: 3.8",
|
|
18
|
-
"Programming Language :: Python :: 3.9",
|
|
19
17
|
"Programming Language :: Python :: 3.10",
|
|
20
18
|
"Programming Language :: Python :: 3.11",
|
|
21
19
|
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Programming Language :: Python :: 3.13",
|
|
22
21
|
"Programming Language :: Python :: Implementation :: CPython",
|
|
23
22
|
"Natural Language :: English",
|
|
24
23
|
"Topic :: Utilities",
|
|
@@ -29,8 +28,8 @@ keywords = ["eBird", "API", "client"]
|
|
|
29
28
|
license = {text = "MIT License"}
|
|
30
29
|
name = "ebird-api"
|
|
31
30
|
readme = "README.md"
|
|
32
|
-
requires-python = ">= 3.
|
|
33
|
-
version = "
|
|
31
|
+
requires-python = ">= 3.10"
|
|
32
|
+
version = "4.0.0"
|
|
34
33
|
|
|
35
34
|
[project.urls]
|
|
36
35
|
Repository = "https://github.com/ProjectBabbler/ebird-api.git"
|
|
@@ -38,7 +37,7 @@ Issues = "https://github.com/ProjectBabbler/ebird-api/issues"
|
|
|
38
37
|
Changelog = "https://github.com/ProjectBabbler/ebird-api/blob/master/CHANGELOG.md"
|
|
39
38
|
|
|
40
39
|
[tool.bumpversion]
|
|
41
|
-
current_version = "
|
|
40
|
+
current_version = "4.0.0"
|
|
42
41
|
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
|
|
43
42
|
serialize = ["{major}.{minor}.{patch}"]
|
|
44
43
|
ignore_missing_version = false
|
|
@@ -52,7 +51,7 @@ message = "New version: {current_version} → {new_version}"
|
|
|
52
51
|
commit_args = ""
|
|
53
52
|
|
|
54
53
|
[[tool.bumpversion.files]]
|
|
55
|
-
filename = "src/ebird/api/__init__.py"
|
|
54
|
+
filename = "src/ebird/api/requests/__init__.py"
|
|
56
55
|
search = '__version__ = "{current_version}"'
|
|
57
56
|
replace = '__version__ = "{new_version}"'
|
|
58
57
|
|
|
@@ -98,7 +97,7 @@ legacy_tox_ini = """
|
|
|
98
97
|
requires =
|
|
99
98
|
tox>=4.2
|
|
100
99
|
tox-uv>=1.11.3
|
|
101
|
-
envlist =
|
|
100
|
+
envlist = py310, py311, py312, py313
|
|
102
101
|
|
|
103
102
|
[testenv]
|
|
104
103
|
commands = pytest
|
|
@@ -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
|
+
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Functions for fetching checklists and information about visits."""
|
|
2
2
|
|
|
3
|
-
from ebird.api.utils import call
|
|
4
|
-
from ebird.api.validation import (
|
|
3
|
+
from ebird.api.requests.utils import call
|
|
4
|
+
from ebird.api.requests.validation import (
|
|
5
5
|
clean_area,
|
|
6
6
|
clean_code,
|
|
7
7
|
clean_date,
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
"""Classes for simplifying calls to the eBird API."""
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import socket
|
|
6
|
+
|
|
7
|
+
from ebird.api.requests import (
|
|
6
8
|
checklists,
|
|
7
9
|
constants,
|
|
8
10
|
hotspots,
|
|
@@ -11,7 +13,7 @@ from ebird.api import (
|
|
|
11
13
|
statistics,
|
|
12
14
|
taxonomy,
|
|
13
15
|
)
|
|
14
|
-
from ebird.api.validation import clean_locale
|
|
16
|
+
from ebird.api.requests.validation import clean_locale
|
|
15
17
|
|
|
16
18
|
|
|
17
19
|
class Client:
|
|
@@ -41,6 +43,7 @@ class Client:
|
|
|
41
43
|
self.hotspot = False
|
|
42
44
|
self.provisional = True
|
|
43
45
|
self.sort = "date"
|
|
46
|
+
socket.setdefaulttimeout(constants.DEFAULT_TIMEOUT)
|
|
44
47
|
|
|
45
48
|
def get_observations(self, area):
|
|
46
49
|
"""Get recent observations (up to 30 days ago) for a region or location.
|
|
@@ -101,3 +101,8 @@ SPECIES_SORT = ["date", "species"]
|
|
|
101
101
|
REGION_TYPES = ["country", "subnational1", "subnational2"]
|
|
102
102
|
|
|
103
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
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
"""Functions for fetching information about what species have been seen."""
|
|
4
4
|
|
|
5
|
-
from ebird.api.utils import call
|
|
6
|
-
from ebird.api.validation import (
|
|
5
|
+
from ebird.api.requests.utils import call
|
|
6
|
+
from ebird.api.requests.validation import (
|
|
7
7
|
clean_areas,
|
|
8
8
|
clean_back,
|
|
9
9
|
clean_categories,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Functions for fetching information about regions."""
|
|
2
2
|
|
|
3
|
-
from ebird.api.utils import call
|
|
4
|
-
from ebird.api.validation import clean_region, clean_region_type
|
|
3
|
+
from ebird.api.requests.utils import call
|
|
4
|
+
from ebird.api.requests.validation import clean_region, clean_region_type
|
|
5
5
|
|
|
6
6
|
REGION_LIST_URL = "https://api.ebird.org/v2/ref/region/list/%s/%s"
|
|
7
7
|
ADJACENT_REGIONS_URL = "https://api.ebird.org/v2/ref/adjacent/%s"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Functions for fetching information about species."""
|
|
2
2
|
|
|
3
|
-
from ebird.api.utils import call
|
|
4
|
-
from ebird.api.validation import clean_area
|
|
3
|
+
from ebird.api.requests.utils import call
|
|
4
|
+
from ebird.api.requests.validation import clean_area
|
|
5
5
|
|
|
6
6
|
SPECIES_LIST_URL = "https://api.ebird.org/v2/product/spplist/%s"
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Functions for fetching basic statistics about observers and observations."""
|
|
2
2
|
|
|
3
|
-
from ebird.api.utils import call
|
|
4
|
-
from ebird.api.validation import (
|
|
3
|
+
from ebird.api.requests.utils import call
|
|
4
|
+
from ebird.api.requests.validation import (
|
|
5
5
|
clean_area,
|
|
6
6
|
clean_date,
|
|
7
7
|
clean_max_observers,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Functions for fetching information about the taxonomy used by eBird."""
|
|
2
2
|
|
|
3
|
-
from ebird.api.utils import call
|
|
4
|
-
from ebird.api.validation import (
|
|
3
|
+
from ebird.api.requests.utils import call
|
|
4
|
+
from ebird.api.requests.validation import (
|
|
5
5
|
clean_categories,
|
|
6
6
|
clean_codes,
|
|
7
7
|
clean_locale,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: ebird-api
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.0.0
|
|
4
4
|
Summary: Wrapper for accessing the eBird API
|
|
5
5
|
Author-email: Project Babbler <projectbabbler@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -15,27 +15,26 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
15
15
|
Classifier: Operating System :: OS Independent
|
|
16
16
|
Classifier: Programming Language :: Python
|
|
17
17
|
Classifier: Programming Language :: Python :: 3
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
20
18
|
Classifier: Programming Language :: Python :: 3.10
|
|
21
19
|
Classifier: Programming Language :: Python :: 3.11
|
|
22
20
|
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
22
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
24
23
|
Classifier: Natural Language :: English
|
|
25
24
|
Classifier: Topic :: Utilities
|
|
26
25
|
Classifier: Topic :: Internet
|
|
27
|
-
Requires-Python: >=3.
|
|
26
|
+
Requires-Python: >=3.10
|
|
28
27
|
Description-Content-Type: text/markdown
|
|
29
28
|
License-File: LICENSE.txt
|
|
29
|
+
Dynamic: license-file
|
|
30
30
|
|
|
31
|
-
[](https://travis-ci.org/ProjectBabbler/ebird-api)
|
|
32
31
|
[](https://badge.fury.io/py/ebird-api)
|
|
33
32
|
[](https://img.shields.io/pypi/pyversions/ebird-api)
|
|
34
33
|
|
|
35
34
|
# eBird API
|
|
36
35
|
|
|
37
|
-
eBird API provides a set of wrapper functions for accessing the
|
|
38
|
-
in the eBird API 2.0.
|
|
36
|
+
eBird API Requests provides a set of wrapper functions for accessing the
|
|
37
|
+
end-points in the eBird API 2.0.
|
|
39
38
|
|
|
40
39
|
## Install
|
|
41
40
|
|
|
@@ -46,23 +45,23 @@ pip install ebird-api
|
|
|
46
45
|
## Usage
|
|
47
46
|
|
|
48
47
|
Each of the functions map to a specific end-point in the API - with one or
|
|
49
|
-
two exceptions where API calls are essentially identical. The functions can
|
|
50
|
-
be grouped into five activities: fetching observations, getting information
|
|
51
|
-
on hotspots, getting information on regions, getting lists of species and
|
|
48
|
+
two exceptions where API calls are essentially identical. The functions can
|
|
49
|
+
be grouped into five activities: fetching observations, getting information
|
|
50
|
+
on hotspots, getting information on regions, getting lists of species and
|
|
52
51
|
getting statistics.
|
|
53
52
|
|
|
54
|
-
All functions support arguments (with sensible defaults) for all the query
|
|
55
|
-
parameters supported by the eBird API. Check the docstring for each function
|
|
56
|
-
for more details. There you will also find a link to the documentation for
|
|
53
|
+
All functions support arguments (with sensible defaults) for all the query
|
|
54
|
+
parameters supported by the eBird API. Check the docstring for each function
|
|
55
|
+
for more details. There you will also find a link to the documentation for
|
|
57
56
|
each end-point.
|
|
58
57
|
|
|
59
|
-
To use the API you will need to register for an API key. All you need to do is
|
|
60
|
-
fill out this [form](https://ebird.org/api/keygen) and the API key is generated
|
|
58
|
+
To use the API you will need to register for an API key. All you need to do is
|
|
59
|
+
fill out this [form](https://ebird.org/api/keygen) and the API key is generated
|
|
61
60
|
automatically.
|
|
62
61
|
|
|
63
|
-
NOTE: Use the API with some restraint. Data costs money so don't go downloading
|
|
64
|
-
all the checklists for the world or other excessive behaviour or your account will
|
|
65
|
-
get banned. If you have a project in mind get in touch with eBird and tell them
|
|
62
|
+
NOTE: Use the API with some restraint. Data costs money so don't go downloading
|
|
63
|
+
all the checklists for the world or other excessive behaviour or your account will
|
|
64
|
+
get banned. If you have a project in mind get in touch with eBird and tell them
|
|
66
65
|
what you want to do - they will be interested to hear it.
|
|
67
66
|
|
|
68
67
|
### Observations
|
|
@@ -70,12 +69,12 @@ what you want to do - they will be interested to hear it.
|
|
|
70
69
|
```python
|
|
71
70
|
import os
|
|
72
71
|
|
|
73
|
-
from ebird.api import get_observations
|
|
72
|
+
from ebird.api.requests import get_observations
|
|
74
73
|
|
|
75
74
|
# Always store secrets outside the code, so you don't accidentally
|
|
76
75
|
# commit them. Environment variables are ideal for this.
|
|
77
76
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
78
|
-
|
|
77
|
+
|
|
79
78
|
# Get observations from Woodman Pond, Madison county, New York for the past week.
|
|
80
79
|
this_week = get_observations(api_key, 'L227544', back=7)
|
|
81
80
|
|
|
@@ -89,14 +88,14 @@ state_records = get_observations(api_key, 'US-NY')
|
|
|
89
88
|
national_records = get_observations(api_key, 'US')
|
|
90
89
|
```
|
|
91
90
|
|
|
92
|
-
Any where you pass in single location or region you can also pass in a
|
|
93
|
-
list or a comma-separated string. You can specify up to 10 locations or
|
|
91
|
+
Any where you pass in single location or region you can also pass in a
|
|
92
|
+
list or a comma-separated string. You can specify up to 10 locations or
|
|
94
93
|
regions:
|
|
95
94
|
|
|
96
95
|
```python
|
|
97
96
|
import os
|
|
98
97
|
|
|
99
|
-
from ebird.api import get_observations
|
|
98
|
+
from ebird.api.requests import get_observations
|
|
100
99
|
|
|
101
100
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
102
101
|
|
|
@@ -111,14 +110,14 @@ counties = 'US-NY-103,US-NY-059,US-NY-81'
|
|
|
111
110
|
records = get_observations(api_key, locations, hotspot=False, category='species')
|
|
112
111
|
```
|
|
113
112
|
|
|
114
|
-
The common name for species can be returned in different languages by
|
|
115
|
-
specifying locale in the functions that return observations, checklists
|
|
113
|
+
The common name for species can be returned in different languages by
|
|
114
|
+
specifying locale in the functions that return observations, checklists
|
|
116
115
|
or taxonomy:
|
|
117
116
|
|
|
118
117
|
```python
|
|
119
118
|
import os
|
|
120
119
|
|
|
121
|
-
from ebird.api import get_observations
|
|
120
|
+
from ebird.api.requests import get_observations
|
|
122
121
|
|
|
123
122
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
124
123
|
|
|
@@ -126,34 +125,34 @@ records = get_observations(api_key, 'CA-QC', locale='fr')
|
|
|
126
125
|
```
|
|
127
126
|
|
|
128
127
|
In addition to getting all the observations for a given location or in
|
|
129
|
-
an area you can also get the latest observation of each species in a
|
|
128
|
+
an area you can also get the latest observation of each species in a
|
|
130
129
|
geographical area - useful for finding the nearest place to see a given
|
|
131
130
|
species:
|
|
132
131
|
|
|
133
132
|
```python
|
|
134
133
|
import os
|
|
135
134
|
|
|
136
|
-
from ebird.api import get_nearby_observations
|
|
135
|
+
from ebird.api.requests import get_nearby_observations
|
|
137
136
|
|
|
138
137
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
139
138
|
|
|
140
|
-
# Get the most recent sightings of all species seen in the last week within
|
|
139
|
+
# Get the most recent sightings of all species seen in the last week within
|
|
141
140
|
# 10km of Point Reyes National Seashore.
|
|
142
141
|
records = get_nearby_observations(api_key, 38.05, -122.94, dist=10, back=7)
|
|
143
142
|
```
|
|
144
143
|
|
|
145
|
-
The calls to get_observations() and get_nearby_observation() return all the
|
|
146
|
-
available records. You can limit the set of records returned to only include
|
|
147
|
-
notable ones (locally or nationally rare species) or limit the records to
|
|
144
|
+
The calls to get_observations() and get_nearby_observation() return all the
|
|
145
|
+
available records. You can limit the set of records returned to only include
|
|
146
|
+
notable ones (locally or nationally rare species) or limit the records to
|
|
148
147
|
a small number of species:
|
|
149
148
|
|
|
150
149
|
```python
|
|
151
150
|
import os
|
|
152
151
|
|
|
153
|
-
from ebird.api import (
|
|
154
|
-
get_notable_observations,
|
|
152
|
+
from ebird.api.requests import (
|
|
153
|
+
get_notable_observations,
|
|
155
154
|
get_nearby_notable,
|
|
156
|
-
get_species_observations,
|
|
155
|
+
get_species_observations,
|
|
157
156
|
get_nearby_species,
|
|
158
157
|
)
|
|
159
158
|
|
|
@@ -175,14 +174,14 @@ nearby_species = get_nearby_species(api_key, 'barswa', 38.05, -122.94, back=10)
|
|
|
175
174
|
For the more travel-minded you can also find out the nearest place to see a given species:
|
|
176
175
|
|
|
177
176
|
```python
|
|
178
|
-
import os
|
|
177
|
+
import os
|
|
179
178
|
|
|
180
|
-
from ebird.api import get_nearest_species
|
|
179
|
+
from ebird.api.requests import get_nearest_species
|
|
181
180
|
|
|
182
181
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
183
182
|
|
|
184
183
|
# Where is the closest place to Cornell Lab of Ornithology to see
|
|
185
|
-
# Tennessee Warbler.
|
|
184
|
+
# Tennessee Warbler.
|
|
186
185
|
locations = get_nearest_species(api_key, 'tenwar', 42.48, -76.45)
|
|
187
186
|
```
|
|
188
187
|
|
|
@@ -192,13 +191,13 @@ Depending on what time of year you try this, you might have a long way to go.
|
|
|
192
191
|
|
|
193
192
|
There are two functions for finding out what has been seen at a given location.
|
|
194
193
|
First you can get the list of checklists for a given country, region or location
|
|
195
|
-
using get_visits(). Each result returned has the unique identifier for the
|
|
194
|
+
using get_visits(). Each result returned has the unique identifier for the
|
|
196
195
|
checklist. You can then call get_checklist() to get the list of observations.
|
|
197
196
|
|
|
198
197
|
```python
|
|
199
198
|
import os
|
|
200
199
|
|
|
201
|
-
from ebird.api import get_visits, get_checklist
|
|
200
|
+
from ebird.api.requests import get_visits, get_checklist
|
|
202
201
|
|
|
203
202
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
204
203
|
|
|
@@ -223,7 +222,7 @@ on the location of a given hotspot.
|
|
|
223
222
|
```python
|
|
224
223
|
import os
|
|
225
224
|
|
|
226
|
-
from ebird.api import get_hotspots, get_nearby_hotspots, get_hotspot
|
|
225
|
+
from ebird.api.requests import get_hotspots, get_nearby_hotspots, get_hotspot
|
|
227
226
|
|
|
228
227
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
229
228
|
|
|
@@ -242,15 +241,15 @@ details = get_hotspot(api_key, 'L2313391')
|
|
|
242
241
|
|
|
243
242
|
### Regions
|
|
244
243
|
|
|
245
|
-
eBird divides the world into countries, subnational1 regions (states) or
|
|
246
|
-
subnational2 regions (counties). You can use get_regions() to get the
|
|
247
|
-
list of sub-regions for a given region. For the approximate area covered
|
|
244
|
+
eBird divides the world into countries, subnational1 regions (states) or
|
|
245
|
+
subnational2 regions (counties). You can use get_regions() to get the
|
|
246
|
+
list of sub-regions for a given region. For the approximate area covered
|
|
248
247
|
by a region use get_region().
|
|
249
248
|
|
|
250
249
|
```python
|
|
251
250
|
import os
|
|
252
251
|
|
|
253
|
-
from ebird.api import get_regions, get_adjacent_regions, get_region
|
|
252
|
+
from ebird.api.requests import get_regions, get_adjacent_regions, get_region
|
|
254
253
|
|
|
255
254
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
256
255
|
|
|
@@ -274,14 +273,14 @@ bounds = get_region(api_key, 'US-NY')
|
|
|
274
273
|
|
|
275
274
|
You can get details of all the species, subspecies, forms
|
|
276
275
|
etc. in the taxonomy used by eBird. It's the easiest way
|
|
277
|
-
of getting the codes for each species or subspecies,
|
|
276
|
+
of getting the codes for each species or subspecies,
|
|
278
277
|
e.g. horlar (Horned Lark), cangoo (Canada Goose), etc.,
|
|
279
278
|
that are used in the other API calls.
|
|
280
279
|
|
|
281
280
|
```python
|
|
282
281
|
import os
|
|
283
282
|
|
|
284
|
-
from ebird.api import get_taxonomy, get_taxonomy_forms, get_taxonomy_versions
|
|
283
|
+
from ebird.api.requests import get_taxonomy, get_taxonomy_forms, get_taxonomy_versions
|
|
285
284
|
|
|
286
285
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
287
286
|
|
|
@@ -307,14 +306,14 @@ versions = get_taxonomy_versions(api_key)
|
|
|
307
306
|
You can also get some statistics from the eBird data. The most interesting
|
|
308
307
|
is probably get_top_100() which returns the list of observers who have seen
|
|
309
308
|
the most species or submitted the largest number of checklists. The list is
|
|
310
|
-
just for a specific day so it is really only useful for "Big Days" when
|
|
309
|
+
just for a specific day so it is really only useful for "Big Days" when
|
|
311
310
|
lots of people are out trying to get the greatest number of species.
|
|
312
311
|
|
|
313
312
|
```python
|
|
314
313
|
import os
|
|
315
314
|
|
|
316
315
|
from datetime import date
|
|
317
|
-
from ebird.api import get_top_100, get_totals
|
|
316
|
+
from ebird.api.requests import get_top_100, get_totals
|
|
318
317
|
|
|
319
318
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
320
319
|
|
|
@@ -334,7 +333,7 @@ have to keep passing them as arguments.
|
|
|
334
333
|
```python
|
|
335
334
|
import os
|
|
336
335
|
|
|
337
|
-
from ebird.api import Client
|
|
336
|
+
from ebird.api.requests import Client
|
|
338
337
|
|
|
339
338
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
340
339
|
locale = 'es'
|
|
@@ -349,20 +348,36 @@ The client supports all the API functions.
|
|
|
349
348
|
|
|
350
349
|
## Formats
|
|
351
350
|
|
|
352
|
-
Most of the eBird API calls return JSON. Some of the calls such as getting
|
|
353
|
-
the hotspots for a region or getting the taxonomy also support CSV. Since
|
|
354
|
-
converting JSON to CSV is simple this library is opinionated in that it
|
|
351
|
+
Most of the eBird API calls return JSON. Some of the calls such as getting
|
|
352
|
+
the hotspots for a region or getting the taxonomy also support CSV. Since
|
|
353
|
+
converting JSON to CSV is simple this library is opinionated in that it
|
|
355
354
|
only returns JSON.
|
|
356
355
|
|
|
357
356
|
## Compatibility
|
|
358
357
|
|
|
359
|
-
ebird-api works with currently supported versions of Python, 3.
|
|
360
|
-
it is known to work with earlier versions, at least 3.5 - 3.
|
|
358
|
+
ebird-api works with currently supported versions of Python, 3.10+. However,
|
|
359
|
+
it is known to work with earlier versions, at least 3.5 - 3.8, without any
|
|
361
360
|
problems.
|
|
362
361
|
|
|
362
|
+
## Troubleshooting
|
|
363
|
+
|
|
364
|
+
Just occasionally (rarely in fact), the connection to eBird will freeze. The
|
|
365
|
+
client will raise an error but if you use the API functions directly then your
|
|
366
|
+
program will sit there forever. To fix this set a default timeout all connections
|
|
367
|
+
using:
|
|
368
|
+
|
|
369
|
+
```python
|
|
370
|
+
import socket
|
|
371
|
+
|
|
372
|
+
socket.setdefaulttimeout(30)
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
Thirty seconds is a reasonable figure, however you might change it if your
|
|
376
|
+
internet connection is slow or the eBird servers are busy.
|
|
377
|
+
|
|
363
378
|
## Links
|
|
364
379
|
|
|
365
|
-
Documentation for the eBird API: https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#intro
|
|
380
|
+
Documentation for the eBird API: https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#intro
|
|
366
381
|
though it could do with a little love and attention.
|
|
367
382
|
|
|
368
383
|
Available translations for species names: http://help.ebird.org/customer/portal/articles/1596582
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
CHANGELOG.md
|
|
2
|
+
LICENSE.txt
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
setup.py
|
|
6
|
+
src/ebird/api/requests/__init__.py
|
|
7
|
+
src/ebird/api/requests/checklists.py
|
|
8
|
+
src/ebird/api/requests/client.py
|
|
9
|
+
src/ebird/api/requests/constants.py
|
|
10
|
+
src/ebird/api/requests/hotspots.py
|
|
11
|
+
src/ebird/api/requests/observations.py
|
|
12
|
+
src/ebird/api/requests/regions.py
|
|
13
|
+
src/ebird/api/requests/species.py
|
|
14
|
+
src/ebird/api/requests/statistics.py
|
|
15
|
+
src/ebird/api/requests/taxonomy.py
|
|
16
|
+
src/ebird/api/requests/utils.py
|
|
17
|
+
src/ebird/api/requests/validation.py
|
|
18
|
+
src/ebird_api.egg-info/PKG-INFO
|
|
19
|
+
src/ebird_api.egg-info/SOURCES.txt
|
|
20
|
+
src/ebird_api.egg-info/dependency_links.txt
|
|
21
|
+
src/ebird_api.egg-info/top_level.txt
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# flake8: noqa
|
|
2
|
-
|
|
3
|
-
"""A set of wrapper functions for accessing the eBird API."""
|
|
4
|
-
|
|
5
|
-
__version__ = "3.4.1"
|
|
6
|
-
|
|
7
|
-
from ebird.api.checklists import get_checklist, get_visits
|
|
8
|
-
from ebird.api.client import Client
|
|
9
|
-
from ebird.api.constants import LOCALES
|
|
10
|
-
from ebird.api.hotspots import (
|
|
11
|
-
get_hotspot,
|
|
12
|
-
get_hotspots,
|
|
13
|
-
get_location,
|
|
14
|
-
get_nearby_hotspots,
|
|
15
|
-
)
|
|
16
|
-
from ebird.api.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.regions import get_adjacent_regions, get_region, get_regions
|
|
27
|
-
from ebird.api.species import get_species_list
|
|
28
|
-
from ebird.api.statistics import get_top_100, get_totals
|
|
29
|
-
from ebird.api.taxonomy import (
|
|
30
|
-
get_taxonomy,
|
|
31
|
-
get_taxonomy_forms,
|
|
32
|
-
get_taxonomy_groups,
|
|
33
|
-
get_taxonomy_locales,
|
|
34
|
-
get_taxonomy_versions,
|
|
35
|
-
)
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
CHANGELOG.md
|
|
2
|
-
LICENSE.txt
|
|
3
|
-
README.md
|
|
4
|
-
pyproject.toml
|
|
5
|
-
setup.py
|
|
6
|
-
src/ebird/api/__init__.py
|
|
7
|
-
src/ebird/api/checklists.py
|
|
8
|
-
src/ebird/api/client.py
|
|
9
|
-
src/ebird/api/constants.py
|
|
10
|
-
src/ebird/api/hotspots.py
|
|
11
|
-
src/ebird/api/observations.py
|
|
12
|
-
src/ebird/api/regions.py
|
|
13
|
-
src/ebird/api/species.py
|
|
14
|
-
src/ebird/api/statistics.py
|
|
15
|
-
src/ebird/api/taxonomy.py
|
|
16
|
-
src/ebird/api/utils.py
|
|
17
|
-
src/ebird/api/validation.py
|
|
18
|
-
src/ebird_api.egg-info/PKG-INFO
|
|
19
|
-
src/ebird_api.egg-info/SOURCES.txt
|
|
20
|
-
src/ebird_api.egg-info/dependency_links.txt
|
|
21
|
-
src/ebird_api.egg-info/top_level.txt
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|