ebird-api 3.4.1__tar.gz → 3.4.2__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-3.4.2}/CHANGELOG.md +4 -0
- {ebird_api-3.4.1/src/ebird_api.egg-info → ebird_api-3.4.2}/PKG-INFO +56 -39
- {ebird_api-3.4.1 → ebird_api-3.4.2}/README.md +53 -37
- {ebird_api-3.4.1 → ebird_api-3.4.2}/pyproject.toml +2 -2
- {ebird_api-3.4.1 → ebird_api-3.4.2}/src/ebird/api/__init__.py +1 -1
- {ebird_api-3.4.1 → ebird_api-3.4.2}/src/ebird/api/client.py +3 -0
- {ebird_api-3.4.1 → ebird_api-3.4.2}/src/ebird/api/constants.py +5 -0
- {ebird_api-3.4.1 → ebird_api-3.4.2/src/ebird_api.egg-info}/PKG-INFO +56 -39
- {ebird_api-3.4.1 → ebird_api-3.4.2}/LICENSE.txt +0 -0
- {ebird_api-3.4.1 → ebird_api-3.4.2}/setup.cfg +0 -0
- {ebird_api-3.4.1 → ebird_api-3.4.2}/setup.py +0 -0
- {ebird_api-3.4.1 → ebird_api-3.4.2}/src/ebird/api/checklists.py +0 -0
- {ebird_api-3.4.1 → ebird_api-3.4.2}/src/ebird/api/hotspots.py +0 -0
- {ebird_api-3.4.1 → ebird_api-3.4.2}/src/ebird/api/observations.py +0 -0
- {ebird_api-3.4.1 → ebird_api-3.4.2}/src/ebird/api/regions.py +0 -0
- {ebird_api-3.4.1 → ebird_api-3.4.2}/src/ebird/api/species.py +0 -0
- {ebird_api-3.4.1 → ebird_api-3.4.2}/src/ebird/api/statistics.py +0 -0
- {ebird_api-3.4.1 → ebird_api-3.4.2}/src/ebird/api/taxonomy.py +0 -0
- {ebird_api-3.4.1 → ebird_api-3.4.2}/src/ebird/api/utils.py +0 -0
- {ebird_api-3.4.1 → ebird_api-3.4.2}/src/ebird/api/validation.py +0 -0
- {ebird_api-3.4.1 → ebird_api-3.4.2}/src/ebird_api.egg-info/SOURCES.txt +0 -0
- {ebird_api-3.4.1 → ebird_api-3.4.2}/src/ebird_api.egg-info/dependency_links.txt +0 -0
- {ebird_api-3.4.1 → ebird_api-3.4.2}/src/ebird_api.egg-info/top_level.txt +0 -0
|
@@ -8,6 +8,10 @@ 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
|
+
## [3.4.2] - 2025-04-05
|
|
12
|
+
- Added a timeout so the client will raise an error if the connection
|
|
13
|
+
to eBird freezes
|
|
14
|
+
|
|
11
15
|
## [3.4.1] - 2025-02-12
|
|
12
16
|
- Disallow lower case location codes
|
|
13
17
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: ebird-api
|
|
3
|
-
Version: 3.4.
|
|
3
|
+
Version: 3.4.2
|
|
4
4
|
Summary: Wrapper for accessing the eBird API
|
|
5
5
|
Author-email: Project Babbler <projectbabbler@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -27,6 +27,7 @@ Classifier: Topic :: Internet
|
|
|
27
27
|
Requires-Python: >=3.8
|
|
28
28
|
Description-Content-Type: text/markdown
|
|
29
29
|
License-File: LICENSE.txt
|
|
30
|
+
Dynamic: license-file
|
|
30
31
|
|
|
31
32
|
[](https://travis-ci.org/ProjectBabbler/ebird-api)
|
|
32
33
|
[](https://badge.fury.io/py/ebird-api)
|
|
@@ -46,23 +47,23 @@ pip install ebird-api
|
|
|
46
47
|
## Usage
|
|
47
48
|
|
|
48
49
|
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
|
|
50
|
+
two exceptions where API calls are essentially identical. The functions can
|
|
51
|
+
be grouped into five activities: fetching observations, getting information
|
|
52
|
+
on hotspots, getting information on regions, getting lists of species and
|
|
52
53
|
getting statistics.
|
|
53
54
|
|
|
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
|
|
55
|
+
All functions support arguments (with sensible defaults) for all the query
|
|
56
|
+
parameters supported by the eBird API. Check the docstring for each function
|
|
57
|
+
for more details. There you will also find a link to the documentation for
|
|
57
58
|
each end-point.
|
|
58
59
|
|
|
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
|
|
60
|
+
To use the API you will need to register for an API key. All you need to do is
|
|
61
|
+
fill out this [form](https://ebird.org/api/keygen) and the API key is generated
|
|
61
62
|
automatically.
|
|
62
63
|
|
|
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
|
|
64
|
+
NOTE: Use the API with some restraint. Data costs money so don't go downloading
|
|
65
|
+
all the checklists for the world or other excessive behaviour or your account will
|
|
66
|
+
get banned. If you have a project in mind get in touch with eBird and tell them
|
|
66
67
|
what you want to do - they will be interested to hear it.
|
|
67
68
|
|
|
68
69
|
### Observations
|
|
@@ -75,7 +76,7 @@ from ebird.api import get_observations
|
|
|
75
76
|
# Always store secrets outside the code, so you don't accidentally
|
|
76
77
|
# commit them. Environment variables are ideal for this.
|
|
77
78
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
78
|
-
|
|
79
|
+
|
|
79
80
|
# Get observations from Woodman Pond, Madison county, New York for the past week.
|
|
80
81
|
this_week = get_observations(api_key, 'L227544', back=7)
|
|
81
82
|
|
|
@@ -89,8 +90,8 @@ state_records = get_observations(api_key, 'US-NY')
|
|
|
89
90
|
national_records = get_observations(api_key, 'US')
|
|
90
91
|
```
|
|
91
92
|
|
|
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
|
|
93
|
+
Any where you pass in single location or region you can also pass in a
|
|
94
|
+
list or a comma-separated string. You can specify up to 10 locations or
|
|
94
95
|
regions:
|
|
95
96
|
|
|
96
97
|
```python
|
|
@@ -111,8 +112,8 @@ counties = 'US-NY-103,US-NY-059,US-NY-81'
|
|
|
111
112
|
records = get_observations(api_key, locations, hotspot=False, category='species')
|
|
112
113
|
```
|
|
113
114
|
|
|
114
|
-
The common name for species can be returned in different languages by
|
|
115
|
-
specifying locale in the functions that return observations, checklists
|
|
115
|
+
The common name for species can be returned in different languages by
|
|
116
|
+
specifying locale in the functions that return observations, checklists
|
|
116
117
|
or taxonomy:
|
|
117
118
|
|
|
118
119
|
```python
|
|
@@ -126,7 +127,7 @@ records = get_observations(api_key, 'CA-QC', locale='fr')
|
|
|
126
127
|
```
|
|
127
128
|
|
|
128
129
|
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
|
|
130
|
+
an area you can also get the latest observation of each species in a
|
|
130
131
|
geographical area - useful for finding the nearest place to see a given
|
|
131
132
|
species:
|
|
132
133
|
|
|
@@ -137,23 +138,23 @@ from ebird.api import get_nearby_observations
|
|
|
137
138
|
|
|
138
139
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
139
140
|
|
|
140
|
-
# Get the most recent sightings of all species seen in the last week within
|
|
141
|
+
# Get the most recent sightings of all species seen in the last week within
|
|
141
142
|
# 10km of Point Reyes National Seashore.
|
|
142
143
|
records = get_nearby_observations(api_key, 38.05, -122.94, dist=10, back=7)
|
|
143
144
|
```
|
|
144
145
|
|
|
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
|
|
146
|
+
The calls to get_observations() and get_nearby_observation() return all the
|
|
147
|
+
available records. You can limit the set of records returned to only include
|
|
148
|
+
notable ones (locally or nationally rare species) or limit the records to
|
|
148
149
|
a small number of species:
|
|
149
150
|
|
|
150
151
|
```python
|
|
151
152
|
import os
|
|
152
153
|
|
|
153
154
|
from ebird.api import (
|
|
154
|
-
get_notable_observations,
|
|
155
|
+
get_notable_observations,
|
|
155
156
|
get_nearby_notable,
|
|
156
|
-
get_species_observations,
|
|
157
|
+
get_species_observations,
|
|
157
158
|
get_nearby_species,
|
|
158
159
|
)
|
|
159
160
|
|
|
@@ -175,14 +176,14 @@ nearby_species = get_nearby_species(api_key, 'barswa', 38.05, -122.94, back=10)
|
|
|
175
176
|
For the more travel-minded you can also find out the nearest place to see a given species:
|
|
176
177
|
|
|
177
178
|
```python
|
|
178
|
-
import os
|
|
179
|
+
import os
|
|
179
180
|
|
|
180
181
|
from ebird.api import get_nearest_species
|
|
181
182
|
|
|
182
183
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
183
184
|
|
|
184
185
|
# Where is the closest place to Cornell Lab of Ornithology to see
|
|
185
|
-
# Tennessee Warbler.
|
|
186
|
+
# Tennessee Warbler.
|
|
186
187
|
locations = get_nearest_species(api_key, 'tenwar', 42.48, -76.45)
|
|
187
188
|
```
|
|
188
189
|
|
|
@@ -192,7 +193,7 @@ Depending on what time of year you try this, you might have a long way to go.
|
|
|
192
193
|
|
|
193
194
|
There are two functions for finding out what has been seen at a given location.
|
|
194
195
|
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
|
|
196
|
+
using get_visits(). Each result returned has the unique identifier for the
|
|
196
197
|
checklist. You can then call get_checklist() to get the list of observations.
|
|
197
198
|
|
|
198
199
|
```python
|
|
@@ -242,9 +243,9 @@ details = get_hotspot(api_key, 'L2313391')
|
|
|
242
243
|
|
|
243
244
|
### Regions
|
|
244
245
|
|
|
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
|
|
246
|
+
eBird divides the world into countries, subnational1 regions (states) or
|
|
247
|
+
subnational2 regions (counties). You can use get_regions() to get the
|
|
248
|
+
list of sub-regions for a given region. For the approximate area covered
|
|
248
249
|
by a region use get_region().
|
|
249
250
|
|
|
250
251
|
```python
|
|
@@ -274,7 +275,7 @@ bounds = get_region(api_key, 'US-NY')
|
|
|
274
275
|
|
|
275
276
|
You can get details of all the species, subspecies, forms
|
|
276
277
|
etc. in the taxonomy used by eBird. It's the easiest way
|
|
277
|
-
of getting the codes for each species or subspecies,
|
|
278
|
+
of getting the codes for each species or subspecies,
|
|
278
279
|
e.g. horlar (Horned Lark), cangoo (Canada Goose), etc.,
|
|
279
280
|
that are used in the other API calls.
|
|
280
281
|
|
|
@@ -307,7 +308,7 @@ versions = get_taxonomy_versions(api_key)
|
|
|
307
308
|
You can also get some statistics from the eBird data. The most interesting
|
|
308
309
|
is probably get_top_100() which returns the list of observers who have seen
|
|
309
310
|
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
|
|
311
|
+
just for a specific day so it is really only useful for "Big Days" when
|
|
311
312
|
lots of people are out trying to get the greatest number of species.
|
|
312
313
|
|
|
313
314
|
```python
|
|
@@ -349,20 +350,36 @@ The client supports all the API functions.
|
|
|
349
350
|
|
|
350
351
|
## Formats
|
|
351
352
|
|
|
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
|
|
353
|
+
Most of the eBird API calls return JSON. Some of the calls such as getting
|
|
354
|
+
the hotspots for a region or getting the taxonomy also support CSV. Since
|
|
355
|
+
converting JSON to CSV is simple this library is opinionated in that it
|
|
355
356
|
only returns JSON.
|
|
356
357
|
|
|
357
358
|
## Compatibility
|
|
358
359
|
|
|
359
|
-
ebird-api works with currently supported versions of Python, 3.8+. However,
|
|
360
|
-
it is known to work with earlier versions, at least 3.5 - 3.7, without any
|
|
360
|
+
ebird-api works with currently supported versions of Python, 3.8+. However,
|
|
361
|
+
it is known to work with earlier versions, at least 3.5 - 3.7, without any
|
|
361
362
|
problems.
|
|
362
363
|
|
|
364
|
+
## Troubleshooting
|
|
365
|
+
|
|
366
|
+
Just occasionally (rarely in fact), the connection to eBird will freeze. The
|
|
367
|
+
client will raise an error but if you use the API functions directly then your
|
|
368
|
+
program will sit there forever. To fix this set a default timeout all connections
|
|
369
|
+
using:
|
|
370
|
+
|
|
371
|
+
```python
|
|
372
|
+
import socket
|
|
373
|
+
|
|
374
|
+
socket.setdefaulttimeout(30)
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
Thirty seconds is a reasonable figure, however you might change it if your
|
|
378
|
+
internet connection is slow or the eBird servers are busy.
|
|
379
|
+
|
|
363
380
|
## Links
|
|
364
381
|
|
|
365
|
-
Documentation for the eBird API: https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#intro
|
|
382
|
+
Documentation for the eBird API: https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#intro
|
|
366
383
|
though it could do with a little love and attention.
|
|
367
384
|
|
|
368
385
|
Available translations for species names: http://help.ebird.org/customer/portal/articles/1596582
|
|
@@ -16,23 +16,23 @@ pip install ebird-api
|
|
|
16
16
|
## Usage
|
|
17
17
|
|
|
18
18
|
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
|
|
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
|
|
22
22
|
getting statistics.
|
|
23
23
|
|
|
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
|
|
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
|
|
27
27
|
each end-point.
|
|
28
28
|
|
|
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
|
|
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
|
|
31
31
|
automatically.
|
|
32
32
|
|
|
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
|
|
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
|
|
36
36
|
what you want to do - they will be interested to hear it.
|
|
37
37
|
|
|
38
38
|
### Observations
|
|
@@ -45,7 +45,7 @@ from ebird.api import get_observations
|
|
|
45
45
|
# Always store secrets outside the code, so you don't accidentally
|
|
46
46
|
# commit them. Environment variables are ideal for this.
|
|
47
47
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
# Get observations from Woodman Pond, Madison county, New York for the past week.
|
|
50
50
|
this_week = get_observations(api_key, 'L227544', back=7)
|
|
51
51
|
|
|
@@ -59,8 +59,8 @@ state_records = get_observations(api_key, 'US-NY')
|
|
|
59
59
|
national_records = get_observations(api_key, 'US')
|
|
60
60
|
```
|
|
61
61
|
|
|
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
|
|
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
|
|
64
64
|
regions:
|
|
65
65
|
|
|
66
66
|
```python
|
|
@@ -81,8 +81,8 @@ counties = 'US-NY-103,US-NY-059,US-NY-81'
|
|
|
81
81
|
records = get_observations(api_key, locations, hotspot=False, category='species')
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
The common name for species can be returned in different languages by
|
|
85
|
-
specifying locale in the functions that return observations, checklists
|
|
84
|
+
The common name for species can be returned in different languages by
|
|
85
|
+
specifying locale in the functions that return observations, checklists
|
|
86
86
|
or taxonomy:
|
|
87
87
|
|
|
88
88
|
```python
|
|
@@ -96,7 +96,7 @@ records = get_observations(api_key, 'CA-QC', locale='fr')
|
|
|
96
96
|
```
|
|
97
97
|
|
|
98
98
|
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
|
|
99
|
+
an area you can also get the latest observation of each species in a
|
|
100
100
|
geographical area - useful for finding the nearest place to see a given
|
|
101
101
|
species:
|
|
102
102
|
|
|
@@ -107,23 +107,23 @@ from ebird.api import get_nearby_observations
|
|
|
107
107
|
|
|
108
108
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
109
109
|
|
|
110
|
-
# Get the most recent sightings of all species seen in the last week within
|
|
110
|
+
# Get the most recent sightings of all species seen in the last week within
|
|
111
111
|
# 10km of Point Reyes National Seashore.
|
|
112
112
|
records = get_nearby_observations(api_key, 38.05, -122.94, dist=10, back=7)
|
|
113
113
|
```
|
|
114
114
|
|
|
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
|
|
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
|
|
118
118
|
a small number of species:
|
|
119
119
|
|
|
120
120
|
```python
|
|
121
121
|
import os
|
|
122
122
|
|
|
123
123
|
from ebird.api import (
|
|
124
|
-
get_notable_observations,
|
|
124
|
+
get_notable_observations,
|
|
125
125
|
get_nearby_notable,
|
|
126
|
-
get_species_observations,
|
|
126
|
+
get_species_observations,
|
|
127
127
|
get_nearby_species,
|
|
128
128
|
)
|
|
129
129
|
|
|
@@ -145,14 +145,14 @@ nearby_species = get_nearby_species(api_key, 'barswa', 38.05, -122.94, back=10)
|
|
|
145
145
|
For the more travel-minded you can also find out the nearest place to see a given species:
|
|
146
146
|
|
|
147
147
|
```python
|
|
148
|
-
import os
|
|
148
|
+
import os
|
|
149
149
|
|
|
150
150
|
from ebird.api import get_nearest_species
|
|
151
151
|
|
|
152
152
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
153
153
|
|
|
154
154
|
# Where is the closest place to Cornell Lab of Ornithology to see
|
|
155
|
-
# Tennessee Warbler.
|
|
155
|
+
# Tennessee Warbler.
|
|
156
156
|
locations = get_nearest_species(api_key, 'tenwar', 42.48, -76.45)
|
|
157
157
|
```
|
|
158
158
|
|
|
@@ -162,7 +162,7 @@ Depending on what time of year you try this, you might have a long way to go.
|
|
|
162
162
|
|
|
163
163
|
There are two functions for finding out what has been seen at a given location.
|
|
164
164
|
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
|
|
165
|
+
using get_visits(). Each result returned has the unique identifier for the
|
|
166
166
|
checklist. You can then call get_checklist() to get the list of observations.
|
|
167
167
|
|
|
168
168
|
```python
|
|
@@ -212,9 +212,9 @@ details = get_hotspot(api_key, 'L2313391')
|
|
|
212
212
|
|
|
213
213
|
### Regions
|
|
214
214
|
|
|
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
|
|
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
|
|
218
218
|
by a region use get_region().
|
|
219
219
|
|
|
220
220
|
```python
|
|
@@ -244,7 +244,7 @@ bounds = get_region(api_key, 'US-NY')
|
|
|
244
244
|
|
|
245
245
|
You can get details of all the species, subspecies, forms
|
|
246
246
|
etc. in the taxonomy used by eBird. It's the easiest way
|
|
247
|
-
of getting the codes for each species or subspecies,
|
|
247
|
+
of getting the codes for each species or subspecies,
|
|
248
248
|
e.g. horlar (Horned Lark), cangoo (Canada Goose), etc.,
|
|
249
249
|
that are used in the other API calls.
|
|
250
250
|
|
|
@@ -277,7 +277,7 @@ versions = get_taxonomy_versions(api_key)
|
|
|
277
277
|
You can also get some statistics from the eBird data. The most interesting
|
|
278
278
|
is probably get_top_100() which returns the list of observers who have seen
|
|
279
279
|
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
|
|
280
|
+
just for a specific day so it is really only useful for "Big Days" when
|
|
281
281
|
lots of people are out trying to get the greatest number of species.
|
|
282
282
|
|
|
283
283
|
```python
|
|
@@ -319,20 +319,36 @@ The client supports all the API functions.
|
|
|
319
319
|
|
|
320
320
|
## Formats
|
|
321
321
|
|
|
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
|
|
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
|
|
325
325
|
only returns JSON.
|
|
326
326
|
|
|
327
327
|
## Compatibility
|
|
328
328
|
|
|
329
|
-
ebird-api works with currently supported versions of Python, 3.8+. However,
|
|
330
|
-
it is known to work with earlier versions, at least 3.5 - 3.7, without any
|
|
329
|
+
ebird-api works with currently supported versions of Python, 3.8+. However,
|
|
330
|
+
it is known to work with earlier versions, at least 3.5 - 3.7, without any
|
|
331
331
|
problems.
|
|
332
332
|
|
|
333
|
+
## Troubleshooting
|
|
334
|
+
|
|
335
|
+
Just occasionally (rarely in fact), the connection to eBird will freeze. The
|
|
336
|
+
client will raise an error but if you use the API functions directly then your
|
|
337
|
+
program will sit there forever. To fix this set a default timeout all connections
|
|
338
|
+
using:
|
|
339
|
+
|
|
340
|
+
```python
|
|
341
|
+
import socket
|
|
342
|
+
|
|
343
|
+
socket.setdefaulttimeout(30)
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
Thirty seconds is a reasonable figure, however you might change it if your
|
|
347
|
+
internet connection is slow or the eBird servers are busy.
|
|
348
|
+
|
|
333
349
|
## Links
|
|
334
350
|
|
|
335
|
-
Documentation for the eBird API: https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#intro
|
|
351
|
+
Documentation for the eBird API: https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#intro
|
|
336
352
|
though it could do with a little love and attention.
|
|
337
353
|
|
|
338
354
|
Available translations for species names: http://help.ebird.org/customer/portal/articles/1596582
|
|
@@ -30,7 +30,7 @@ license = {text = "MIT License"}
|
|
|
30
30
|
name = "ebird-api"
|
|
31
31
|
readme = "README.md"
|
|
32
32
|
requires-python = ">= 3.8"
|
|
33
|
-
version = "3.4.
|
|
33
|
+
version = "3.4.2"
|
|
34
34
|
|
|
35
35
|
[project.urls]
|
|
36
36
|
Repository = "https://github.com/ProjectBabbler/ebird-api.git"
|
|
@@ -38,7 +38,7 @@ Issues = "https://github.com/ProjectBabbler/ebird-api/issues"
|
|
|
38
38
|
Changelog = "https://github.com/ProjectBabbler/ebird-api/blob/master/CHANGELOG.md"
|
|
39
39
|
|
|
40
40
|
[tool.bumpversion]
|
|
41
|
-
current_version = "3.4.
|
|
41
|
+
current_version = "3.4.2"
|
|
42
42
|
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
|
|
43
43
|
serialize = ["{major}.{minor}.{patch}"]
|
|
44
44
|
ignore_missing_version = false
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
"""Classes for simplifying calls to the eBird API."""
|
|
4
4
|
|
|
5
|
+
import socket
|
|
6
|
+
|
|
5
7
|
from ebird.api import (
|
|
6
8
|
checklists,
|
|
7
9
|
constants,
|
|
@@ -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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: ebird-api
|
|
3
|
-
Version: 3.4.
|
|
3
|
+
Version: 3.4.2
|
|
4
4
|
Summary: Wrapper for accessing the eBird API
|
|
5
5
|
Author-email: Project Babbler <projectbabbler@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -27,6 +27,7 @@ Classifier: Topic :: Internet
|
|
|
27
27
|
Requires-Python: >=3.8
|
|
28
28
|
Description-Content-Type: text/markdown
|
|
29
29
|
License-File: LICENSE.txt
|
|
30
|
+
Dynamic: license-file
|
|
30
31
|
|
|
31
32
|
[](https://travis-ci.org/ProjectBabbler/ebird-api)
|
|
32
33
|
[](https://badge.fury.io/py/ebird-api)
|
|
@@ -46,23 +47,23 @@ pip install ebird-api
|
|
|
46
47
|
## Usage
|
|
47
48
|
|
|
48
49
|
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
|
|
50
|
+
two exceptions where API calls are essentially identical. The functions can
|
|
51
|
+
be grouped into five activities: fetching observations, getting information
|
|
52
|
+
on hotspots, getting information on regions, getting lists of species and
|
|
52
53
|
getting statistics.
|
|
53
54
|
|
|
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
|
|
55
|
+
All functions support arguments (with sensible defaults) for all the query
|
|
56
|
+
parameters supported by the eBird API. Check the docstring for each function
|
|
57
|
+
for more details. There you will also find a link to the documentation for
|
|
57
58
|
each end-point.
|
|
58
59
|
|
|
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
|
|
60
|
+
To use the API you will need to register for an API key. All you need to do is
|
|
61
|
+
fill out this [form](https://ebird.org/api/keygen) and the API key is generated
|
|
61
62
|
automatically.
|
|
62
63
|
|
|
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
|
|
64
|
+
NOTE: Use the API with some restraint. Data costs money so don't go downloading
|
|
65
|
+
all the checklists for the world or other excessive behaviour or your account will
|
|
66
|
+
get banned. If you have a project in mind get in touch with eBird and tell them
|
|
66
67
|
what you want to do - they will be interested to hear it.
|
|
67
68
|
|
|
68
69
|
### Observations
|
|
@@ -75,7 +76,7 @@ from ebird.api import get_observations
|
|
|
75
76
|
# Always store secrets outside the code, so you don't accidentally
|
|
76
77
|
# commit them. Environment variables are ideal for this.
|
|
77
78
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
78
|
-
|
|
79
|
+
|
|
79
80
|
# Get observations from Woodman Pond, Madison county, New York for the past week.
|
|
80
81
|
this_week = get_observations(api_key, 'L227544', back=7)
|
|
81
82
|
|
|
@@ -89,8 +90,8 @@ state_records = get_observations(api_key, 'US-NY')
|
|
|
89
90
|
national_records = get_observations(api_key, 'US')
|
|
90
91
|
```
|
|
91
92
|
|
|
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
|
|
93
|
+
Any where you pass in single location or region you can also pass in a
|
|
94
|
+
list or a comma-separated string. You can specify up to 10 locations or
|
|
94
95
|
regions:
|
|
95
96
|
|
|
96
97
|
```python
|
|
@@ -111,8 +112,8 @@ counties = 'US-NY-103,US-NY-059,US-NY-81'
|
|
|
111
112
|
records = get_observations(api_key, locations, hotspot=False, category='species')
|
|
112
113
|
```
|
|
113
114
|
|
|
114
|
-
The common name for species can be returned in different languages by
|
|
115
|
-
specifying locale in the functions that return observations, checklists
|
|
115
|
+
The common name for species can be returned in different languages by
|
|
116
|
+
specifying locale in the functions that return observations, checklists
|
|
116
117
|
or taxonomy:
|
|
117
118
|
|
|
118
119
|
```python
|
|
@@ -126,7 +127,7 @@ records = get_observations(api_key, 'CA-QC', locale='fr')
|
|
|
126
127
|
```
|
|
127
128
|
|
|
128
129
|
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
|
|
130
|
+
an area you can also get the latest observation of each species in a
|
|
130
131
|
geographical area - useful for finding the nearest place to see a given
|
|
131
132
|
species:
|
|
132
133
|
|
|
@@ -137,23 +138,23 @@ from ebird.api import get_nearby_observations
|
|
|
137
138
|
|
|
138
139
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
139
140
|
|
|
140
|
-
# Get the most recent sightings of all species seen in the last week within
|
|
141
|
+
# Get the most recent sightings of all species seen in the last week within
|
|
141
142
|
# 10km of Point Reyes National Seashore.
|
|
142
143
|
records = get_nearby_observations(api_key, 38.05, -122.94, dist=10, back=7)
|
|
143
144
|
```
|
|
144
145
|
|
|
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
|
|
146
|
+
The calls to get_observations() and get_nearby_observation() return all the
|
|
147
|
+
available records. You can limit the set of records returned to only include
|
|
148
|
+
notable ones (locally or nationally rare species) or limit the records to
|
|
148
149
|
a small number of species:
|
|
149
150
|
|
|
150
151
|
```python
|
|
151
152
|
import os
|
|
152
153
|
|
|
153
154
|
from ebird.api import (
|
|
154
|
-
get_notable_observations,
|
|
155
|
+
get_notable_observations,
|
|
155
156
|
get_nearby_notable,
|
|
156
|
-
get_species_observations,
|
|
157
|
+
get_species_observations,
|
|
157
158
|
get_nearby_species,
|
|
158
159
|
)
|
|
159
160
|
|
|
@@ -175,14 +176,14 @@ nearby_species = get_nearby_species(api_key, 'barswa', 38.05, -122.94, back=10)
|
|
|
175
176
|
For the more travel-minded you can also find out the nearest place to see a given species:
|
|
176
177
|
|
|
177
178
|
```python
|
|
178
|
-
import os
|
|
179
|
+
import os
|
|
179
180
|
|
|
180
181
|
from ebird.api import get_nearest_species
|
|
181
182
|
|
|
182
183
|
api_key = os.environ["EBIRD_API_KEY"]
|
|
183
184
|
|
|
184
185
|
# Where is the closest place to Cornell Lab of Ornithology to see
|
|
185
|
-
# Tennessee Warbler.
|
|
186
|
+
# Tennessee Warbler.
|
|
186
187
|
locations = get_nearest_species(api_key, 'tenwar', 42.48, -76.45)
|
|
187
188
|
```
|
|
188
189
|
|
|
@@ -192,7 +193,7 @@ Depending on what time of year you try this, you might have a long way to go.
|
|
|
192
193
|
|
|
193
194
|
There are two functions for finding out what has been seen at a given location.
|
|
194
195
|
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
|
|
196
|
+
using get_visits(). Each result returned has the unique identifier for the
|
|
196
197
|
checklist. You can then call get_checklist() to get the list of observations.
|
|
197
198
|
|
|
198
199
|
```python
|
|
@@ -242,9 +243,9 @@ details = get_hotspot(api_key, 'L2313391')
|
|
|
242
243
|
|
|
243
244
|
### Regions
|
|
244
245
|
|
|
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
|
|
246
|
+
eBird divides the world into countries, subnational1 regions (states) or
|
|
247
|
+
subnational2 regions (counties). You can use get_regions() to get the
|
|
248
|
+
list of sub-regions for a given region. For the approximate area covered
|
|
248
249
|
by a region use get_region().
|
|
249
250
|
|
|
250
251
|
```python
|
|
@@ -274,7 +275,7 @@ bounds = get_region(api_key, 'US-NY')
|
|
|
274
275
|
|
|
275
276
|
You can get details of all the species, subspecies, forms
|
|
276
277
|
etc. in the taxonomy used by eBird. It's the easiest way
|
|
277
|
-
of getting the codes for each species or subspecies,
|
|
278
|
+
of getting the codes for each species or subspecies,
|
|
278
279
|
e.g. horlar (Horned Lark), cangoo (Canada Goose), etc.,
|
|
279
280
|
that are used in the other API calls.
|
|
280
281
|
|
|
@@ -307,7 +308,7 @@ versions = get_taxonomy_versions(api_key)
|
|
|
307
308
|
You can also get some statistics from the eBird data. The most interesting
|
|
308
309
|
is probably get_top_100() which returns the list of observers who have seen
|
|
309
310
|
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
|
|
311
|
+
just for a specific day so it is really only useful for "Big Days" when
|
|
311
312
|
lots of people are out trying to get the greatest number of species.
|
|
312
313
|
|
|
313
314
|
```python
|
|
@@ -349,20 +350,36 @@ The client supports all the API functions.
|
|
|
349
350
|
|
|
350
351
|
## Formats
|
|
351
352
|
|
|
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
|
|
353
|
+
Most of the eBird API calls return JSON. Some of the calls such as getting
|
|
354
|
+
the hotspots for a region or getting the taxonomy also support CSV. Since
|
|
355
|
+
converting JSON to CSV is simple this library is opinionated in that it
|
|
355
356
|
only returns JSON.
|
|
356
357
|
|
|
357
358
|
## Compatibility
|
|
358
359
|
|
|
359
|
-
ebird-api works with currently supported versions of Python, 3.8+. However,
|
|
360
|
-
it is known to work with earlier versions, at least 3.5 - 3.7, without any
|
|
360
|
+
ebird-api works with currently supported versions of Python, 3.8+. However,
|
|
361
|
+
it is known to work with earlier versions, at least 3.5 - 3.7, without any
|
|
361
362
|
problems.
|
|
362
363
|
|
|
364
|
+
## Troubleshooting
|
|
365
|
+
|
|
366
|
+
Just occasionally (rarely in fact), the connection to eBird will freeze. The
|
|
367
|
+
client will raise an error but if you use the API functions directly then your
|
|
368
|
+
program will sit there forever. To fix this set a default timeout all connections
|
|
369
|
+
using:
|
|
370
|
+
|
|
371
|
+
```python
|
|
372
|
+
import socket
|
|
373
|
+
|
|
374
|
+
socket.setdefaulttimeout(30)
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
Thirty seconds is a reasonable figure, however you might change it if your
|
|
378
|
+
internet connection is slow or the eBird servers are busy.
|
|
379
|
+
|
|
363
380
|
## Links
|
|
364
381
|
|
|
365
|
-
Documentation for the eBird API: https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#intro
|
|
382
|
+
Documentation for the eBird API: https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#intro
|
|
366
383
|
though it could do with a little love and attention.
|
|
367
384
|
|
|
368
385
|
Available translations for species names: http://help.ebird.org/customer/portal/articles/1596582
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|