ebird-api 3.0.6__tar.gz → 3.1.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.
Files changed (28) hide show
  1. {ebird-api-3.0.6 → ebird_api-3.1.0}/CHANGELOG.md +28 -18
  2. {ebird-api-3.0.6 → ebird_api-3.1.0}/LICENSE.txt +1 -1
  3. ebird_api-3.1.0/PKG-INFO +374 -0
  4. {ebird-api-3.0.6 → ebird_api-3.1.0}/README.md +74 -23
  5. ebird_api-3.1.0/pyproject.toml +127 -0
  6. {ebird-api-3.0.6 → ebird_api-3.1.0}/setup.cfg +0 -3
  7. ebird_api-3.1.0/setup.py +3 -0
  8. {ebird-api-3.0.6 → ebird_api-3.1.0/src}/ebird/api/__init__.py +14 -36
  9. {ebird-api-3.0.6 → ebird_api-3.1.0/src}/ebird/api/checklists.py +13 -9
  10. {ebird-api-3.0.6 → ebird_api-3.1.0/src}/ebird/api/client.py +112 -44
  11. ebird_api-3.1.0/src/ebird/api/constants.py +101 -0
  12. {ebird-api-3.0.6 → ebird_api-3.1.0/src}/ebird/api/hotspots.py +22 -19
  13. {ebird-api-3.0.6 → ebird_api-3.1.0/src}/ebird/api/observations.py +189 -111
  14. {ebird-api-3.0.6 → ebird_api-3.1.0/src}/ebird/api/regions.py +12 -11
  15. {ebird-api-3.0.6 → ebird_api-3.1.0/src}/ebird/api/statistics.py +20 -16
  16. {ebird-api-3.0.6 → ebird_api-3.1.0/src}/ebird/api/taxonomy.py +56 -24
  17. {ebird-api-3.0.6 → ebird_api-3.1.0/src}/ebird/api/utils.py +23 -24
  18. {ebird-api-3.0.6 → ebird_api-3.1.0/src}/ebird/api/validation.py +81 -62
  19. ebird_api-3.1.0/src/ebird_api.egg-info/PKG-INFO +374 -0
  20. ebird_api-3.1.0/src/ebird_api.egg-info/SOURCES.txt +20 -0
  21. ebird-api-3.0.6/MANIFEST.in +0 -2
  22. ebird-api-3.0.6/PKG-INFO +0 -319
  23. ebird-api-3.0.6/ebird/api/constants.py +0 -93
  24. ebird-api-3.0.6/ebird_api.egg-info/PKG-INFO +0 -319
  25. ebird-api-3.0.6/ebird_api.egg-info/SOURCES.txt +0 -21
  26. ebird-api-3.0.6/setup.py +0 -51
  27. {ebird-api-3.0.6 → ebird_api-3.1.0/src}/ebird_api.egg-info/dependency_links.txt +0 -0
  28. {ebird-api-3.0.6 → ebird_api-3.1.0/src}/ebird_api.egg-info/top_level.txt +0 -0
@@ -1,50 +1,60 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
- Only changes for the API functions are described here. Changes made
4
- to the internals and developing the package are not included. Check
3
+ Only changes for the API functions are described here. Changes made
4
+ to the internals and developing the package are not included. Check
5
5
  the git log for details.
6
6
 
7
7
  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.1.0] - 2024-12-30
12
+ ### Added
13
+ - get_taxonomy_locales which returns a list of all the languages
14
+ supported for species common names.
15
+
16
+ ## [3.0.7] - 2024-10-09
17
+ ### Changed
18
+ - get_taxonomy now passes "locale" as a parameter, not "sppLocale",
19
+ which was ignored so all names were returned in English.
20
+
11
21
  ## [3.0.6] - 2020-09-09
12
22
  ### Changed
13
23
  - Subnational1 and subnational2 codes were assumed to be at least two
14
- characters. Now they are at least 1 character.
24
+ characters. Now they are at least 1 character.
15
25
 
16
26
  ## [3.0.5] - 2019-08-31
17
27
  ### Changed
18
- - Replaced the checklistSort query parameter for the top_100 end-point
28
+ - Replaced the checklistSort query parameter for the top_100 end-point
19
29
  with rankedBy. This change was made by eBird as checklistSort was not
20
30
  working.
21
31
 
22
32
  ## [3.0.4] - 2019-07-22
23
33
  ### Changed
24
- - Update the functions for fetching observations to use the sppLocale
34
+ - Update the functions for fetching observations to use the sppLocale
25
35
  query parameter to match the recent changes made in the eBird API.
26
36
 
27
37
  ## [3.0.3] - 2019-07-16
28
38
  ### Changed
29
39
  - When fetching observations, the list of area may only contain 10 items.
30
- Previously more than 10 were allowed but this was a bug and was fixed to
31
- limit the load on the server.
40
+ Previously more than 10 were allowed but this was a bug and was fixed to
41
+ limit the load on the server.
32
42
 
33
43
  ## [3.0.2] - 2019-06-22
34
44
  ### Changed
35
- - Updated the validation check for region codes so it supports ISO 3166-2.
36
- - Disabled the validation check that limited the number of areas to 10 as
45
+ - Updated the validation check for region codes so it supports ISO 3166-2.
46
+ - Disabled the validation check that limited the number of areas to 10 as
37
47
  the eBird API does not currently enforce this.
38
48
 
39
49
  ## [3.0.1] - 2019-06-15
40
- ### Added
50
+ ### Added
41
51
  - Added the full list of locales support by eBird (but not necessarily by the API).
42
52
  - Added a convenience function for saving downloaded records to a file.
43
53
  ### Changed
44
54
  - Validating the locale now uses the list supported by eBird.
45
55
 
46
56
  ## [3.0.0] - 2019-06-06
47
- ### Added
57
+ ### Added
48
58
  - Rewritten to support eBird API 2.0
49
59
 
50
60
  ## [2.1.1] - 2019-05-14
@@ -56,31 +66,31 @@ and by implication, [Semantic Versioning](http://semver.org/).
56
66
  - Improved the documentation in the README.
57
67
  - Project now uses the MIT license.
58
68
 
59
- ### Added
69
+ ### Added
60
70
  - Added scripts so each API call can be made on the command line.
61
71
 
62
72
  ## [2.0.0] - 2017-02-27
63
- ### Changed
73
+ ### Changed
64
74
  - Moved all the functions into the 'api' module and changed the top-level
65
75
  'ebird' module to be namespaced (PEP420).
66
76
 
67
77
  ## [1.0.2] - 2017-02-23
68
- ### Changed
78
+ ### Changed
69
79
  - Corrected version number in python.
70
80
 
71
81
  ## [1.0.1] - 2017-02-21
72
- ### Added
82
+ ### Added
73
83
  - Updated docstrings to report exceptions raised.
74
84
 
75
85
  ## [1.0.0] - 2017-02-21
76
- ### Added
86
+ ### Added
77
87
  - Added function for Google Gadgets showing recent observations.
78
88
  - Added function for fetching lists of species.
79
89
  - Added function for fetching nearby hotspots.
80
90
  - Added function for fetching lists of hotspots for a region.
81
91
  ### Changed
82
- - Renamed list_locations() to list_regions() and find_locations() to
83
- find_regions() as "locations" refer to specific sites in the functions
92
+ - Renamed list_locations() to list_regions() and find_locations() to
93
+ find_regions() as "locations" refer to specific sites in the functions
84
94
  that fetch observations.
85
95
 
86
96
  ## [0.2.0] - 2017-02-18
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2019 ProjectBabbler
3
+ Copyright (c) 2019-2024 ProjectBabbler
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1,374 @@
1
+ Metadata-Version: 2.1
2
+ Name: ebird-api
3
+ Version: 3.1.0
4
+ Summary: Wrapper for accessing the eBird API
5
+ Author-email: Project Babbler <projectbabbler@gmail.com>
6
+ License: MIT License
7
+ Project-URL: Repository, https://github.com/ProjectBabbler/ebird-api.git
8
+ Project-URL: Issues, https://github.com/ProjectBabbler/ebird-api/issues
9
+ Project-URL: Changelog, https://github.com/ProjectBabbler/ebird-api/blob/master/CHANGELOG.md
10
+ Keywords: eBird,API,client
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: Implementation :: CPython
24
+ Classifier: Natural Language :: English
25
+ Classifier: Topic :: Utilities
26
+ Classifier: Topic :: Internet
27
+ Requires-Python: >=3.8
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE.txt
30
+
31
+ [![Build Status](https://travis-ci.org/ProjectBabbler/ebird-api.svg?branch=master)](https://travis-ci.org/ProjectBabbler/ebird-api)
32
+ [![PyPI version](https://badge.fury.io/py/ebird-api.svg)](https://badge.fury.io/py/ebird-api)
33
+ [![Supported Python Versions](https://img.shields.io/pypi/pyversions/ebird-api.svg)](https://img.shields.io/pypi/pyversions/ebird-api)
34
+
35
+ # eBird API
36
+
37
+ eBird API provides a set of wrapper functions for accessing the end-points
38
+ in the eBird API 2.0.
39
+
40
+ ## Install
41
+
42
+ ```sh
43
+ pip install ebird-api
44
+ ```
45
+
46
+ ## Usage
47
+
48
+ 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
52
+ getting statistics.
53
+
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
57
+ each end-point.
58
+
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
61
+ automatically.
62
+
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
66
+ what you want to do - they will be interested to hear it.
67
+
68
+ ### Observations
69
+
70
+ ```python
71
+ import os
72
+
73
+ from ebird.api import get_observations
74
+
75
+ # Always store secrets outside the code, so you don't accidentally
76
+ # commit them. Environment variables are ideal for this.
77
+ api_key = os.environ["EBIRD_API_KEY"]
78
+
79
+ # Get observations from Woodman Pond, Madison county, New York for the past week.
80
+ this_week = get_observations(api_key, 'L227544', back=7)
81
+
82
+ # Get observations from Madison county, New York
83
+ country_records = get_observations(api_key, 'US-NY-053')
84
+
85
+ # Get observations from New York
86
+ state_records = get_observations(api_key, 'US-NY')
87
+
88
+ # Get observations from the USA - don't overdo the data downloads
89
+ national_records = get_observations(api_key, 'US')
90
+ ```
91
+
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
94
+ regions:
95
+
96
+ ```python
97
+ import os
98
+
99
+ from ebird.api import get_observations
100
+
101
+ api_key = os.environ["EBIRD_API_KEY"]
102
+
103
+ # Get the observations for the most visited locations in Madison county, New York:
104
+ # Woodman Pond, Ditch Bank Rd., Cornell Biological Field Station and
105
+ # Anne V Pickard Memorial Wildlife Overlook.
106
+ locations = ['L227544', 'L273783', 'L677871', 'L2313391']
107
+ get_observations(api_key, locations, provisional=True, detail='full')
108
+
109
+ # Get the observations for Suffolk, Nassau and Queens counties in New York state.
110
+ counties = 'US-NY-103,US-NY-059,US-NY-81'
111
+ records = get_observations(api_key, locations, hotspot=False, category='species')
112
+ ```
113
+
114
+ The common name for species can be returned in different languages by
115
+ specifying locale in the functions that return observations, checklists
116
+ or taxonomy:
117
+
118
+ ```python
119
+ import os
120
+
121
+ from ebird.api import get_observations
122
+
123
+ api_key = os.environ["EBIRD_API_KEY"]
124
+
125
+ records = get_observations(api_key, 'CA-QC', locale='fr')
126
+ ```
127
+
128
+ 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
+ geographical area - useful for finding the nearest place to see a given
131
+ species:
132
+
133
+ ```python
134
+ import os
135
+
136
+ from ebird.api import get_nearby_observations
137
+
138
+ api_key = os.environ["EBIRD_API_KEY"]
139
+
140
+ # Get the most recent sightings of all species seen in the last week within
141
+ # 10km of Point Reyes National Seashore.
142
+ records = get_nearby_observations(api_key, 38.05, -122.94, dist=10, back=7)
143
+ ```
144
+
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
148
+ a small number of species:
149
+
150
+ ```python
151
+ import os
152
+
153
+ from ebird.api import (
154
+ get_notable_observations,
155
+ get_nearby_notable,
156
+ get_species_observations,
157
+ get_nearby_species,
158
+ )
159
+
160
+ api_key = os.environ["EBIRD_API_KEY"]
161
+
162
+ # Get the interesting birds seen in New York state.
163
+ notables = get_notable_observations(api_key, 'US-NY')
164
+
165
+ # Get the observations of Horned Lark (Eremophila alpestris) in New York state.
166
+ records = get_species_observations(api_key, 'horlar', 'US-NY')
167
+
168
+ # Get the interesting birds within 50kn of Point Reyes
169
+ nearby_notables = get_nearby_notable(api_key, 38.05, -122.94, dist=50)
170
+
171
+ # Find out if Barn Swallows have been seen in the area in the past 10 days
172
+ nearby_species = get_nearby_species(api_key, 'barswa', 38.05, -122.94, back=10)
173
+ ```
174
+
175
+ For the more travel-minded you can also find out the nearest place to see a given species:
176
+
177
+ ```python
178
+ import os
179
+
180
+ from ebird.api import get_nearest_species
181
+
182
+ api_key = os.environ["EBIRD_API_KEY"]
183
+
184
+ # Where is the closest place to Cornell Lab of Ornithology to see
185
+ # Tennessee Warbler.
186
+ locations = get_nearest_species(api_key, 'tenwar', 42.48, -76.45)
187
+ ```
188
+
189
+ Depending on what time of year you try this, you might have a long way to go.
190
+
191
+ ### Checklists
192
+
193
+ There are two functions for finding out what has been seen at a given location.
194
+ 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
+ checklist. You can then call get_checklist() to get the list of observations.
197
+
198
+ ```python
199
+ import os
200
+
201
+ from ebird.api import get_visits, get_checklist
202
+
203
+ api_key = os.environ["EBIRD_API_KEY"]
204
+
205
+ # Get visits made recently to locations in New York state:
206
+ visits = get_visits(api_key, 'US-NY')
207
+
208
+ # Get visits made recently to locations in New York state on Jan 1st 2010
209
+ recent_visits = get_visits(api_key, 'US-NY', '2010-01-01')
210
+
211
+ # Get the details of a checklist
212
+ checklist = get_checklist(api_key, 'S22536787')
213
+ ```
214
+
215
+ ### Hotspots
216
+
217
+ There are two functions for discovering hotspots. get_hotspots() list all
218
+ the locations in a given area. You can find all the hotspots visited recently
219
+ by given a value for the back argument. get_nearby_hotspots() is used to find
220
+ hotspots within a given radius. get_hotspot() can be used to get information
221
+ on the location of a given hotspot.
222
+
223
+ ```python
224
+ import os
225
+
226
+ from ebird.api import get_hotspots, get_nearby_hotspots, get_hotspot
227
+
228
+ api_key = os.environ["EBIRD_API_KEY"]
229
+
230
+ # List all the hotspots in New York state.
231
+ hotspots = get_hotspots(api_key, 'US-NY')
232
+
233
+ # List all the hotspots in New York state visited in the past week.
234
+ recent = get_hotspots(api_key, 'US-NY', back=7)
235
+
236
+ # List all the hotspots in within 50kn of Point Reyes
237
+ nearby = get_nearby_hotspots(api_key, 38.05, -122.94, dist=50)
238
+
239
+ # Get the details of Anne V Pickard Memorial Wildlife Overlook in New York state.
240
+ details = get_hotspot(api_key, 'L2313391')
241
+ ```
242
+
243
+ ### Regions
244
+
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
248
+ by a region use get_region().
249
+
250
+ ```python
251
+ import os
252
+
253
+ from ebird.api import get_regions, get_adjacent_regions, get_region
254
+
255
+ api_key = os.environ["EBIRD_API_KEY"]
256
+
257
+ # Get the list of countries in the world.
258
+ countries = get_regions(api_key, 'country', 'world')
259
+
260
+ # Get the list of states in the US.
261
+ states = get_regions(api_key, 'subnational1', 'US')
262
+
263
+ # Get the list of counties in New York state.
264
+ counties = get_regions(api_key, 'subnational2', 'US-NY')
265
+
266
+ # Get the list of states which border New York state.
267
+ nearby = get_adjacent_regions(api_key, 'US-NY')
268
+
269
+ # Get the approximate area covered by New York state.
270
+ bounds = get_region(api_key, 'US-NY')
271
+ ```
272
+
273
+ ### Taxonomy
274
+
275
+ You can get details of all the species, subspecies, forms
276
+ etc. in the taxonomy used by eBird. It's the easiest way
277
+ of getting the codes for each species or subspecies,
278
+ e.g. horlar (Horned Lark), cangoo (Canada Goose), etc.,
279
+ that are used in the other API calls.
280
+
281
+ ```python
282
+ import os
283
+
284
+ from ebird.api import get_taxonomy, get_taxonomy_forms, get_taxonomy_versions
285
+
286
+ api_key = os.environ["EBIRD_API_KEY"]
287
+
288
+ # Get all the species in the eBird taxonomy.
289
+ taxonomy = get_taxonomy(api_key)
290
+
291
+ # Get all the species in the eBird taxonomy with common names in Spanish
292
+ names = get_taxonomy(api_key, locale='es')
293
+
294
+ # Get all the taxonomy for Horned Lark
295
+ species = get_taxonomy(api_key, species='horlar')
296
+
297
+ # Get the codes for all the subspecies and froms recognised for Barn Swallow.
298
+ forms = get_taxonomy_forms(api_key, 'barswa')
299
+
300
+ # Get information on all the taxonomy revisions, i.e. versions.
301
+ # Usually only the latest is important.
302
+ versions = get_taxonomy_versions(api_key)
303
+ ```
304
+
305
+ ### Statistics
306
+
307
+ You can also get some statistics from the eBird data. The most interesting
308
+ is probably get_top_100() which returns the list of observers who have seen
309
+ 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
+ lots of people are out trying to get the greatest number of species.
312
+
313
+ ```python
314
+ import os
315
+
316
+ from datetime import date
317
+ from ebird.api import get_top_100, get_totals
318
+
319
+ api_key = os.environ["EBIRD_API_KEY"]
320
+
321
+ # Get the winner of the Global Big Day in New York, on 5th May 2018
322
+ winners = get_top_100(api_key, 'US-NY', '2018-05-05')
323
+
324
+ # Get the number of contributors, checklist submitted and species seen today
325
+ totals = get_totals(api_key, 'US-NY', date.today())
326
+ ```
327
+
328
+ ### Client
329
+
330
+ There is a simple Client class which wraps the various functions from the API.
331
+ You can set the API key and locale when creating a Client instance so you don't
332
+ have to keep passing them as arguments.
333
+
334
+ ```python
335
+ import os
336
+
337
+ from ebird.api import Client
338
+
339
+ api_key = os.environ["EBIRD_API_KEY"]
340
+ locale = 'es'
341
+
342
+ client = Client(api_key, locale)
343
+
344
+ client.get_observations('MX-OAX')
345
+
346
+ ```
347
+
348
+ The client supports all the API functions.
349
+
350
+ ## Formats
351
+
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
355
+ only returns JSON.
356
+
357
+ ## Compatibility
358
+
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
361
+ problems.
362
+
363
+ ## Links
364
+
365
+ Documentation for the eBird API: https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#intro
366
+ though it could do with a little love and attention.
367
+
368
+ Available translations for species names: http://help.ebird.org/customer/portal/articles/1596582
369
+
370
+ Information on the taxonomy used by eBird: http://help.ebird.org/customer/portal/articles/1006825-the-ebird-taxonomy
371
+
372
+ ## License
373
+
374
+ eBird API is available under the terms of the [MIT](https://opensource.org/licenses/MIT) licence.