ebird-api-data 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,48 @@
1
+ from django.db import models
2
+ from django.utils.translation import gettext_lazy as _
3
+
4
+
5
+ class Observer(models.Model):
6
+ class Meta:
7
+ verbose_name = _("observer")
8
+ verbose_name_plural = _("observers")
9
+
10
+ identifier = models.TextField(
11
+ verbose_name=_("identifier"),
12
+ help_text=_("The code for the person submitted the checklist."),
13
+ )
14
+
15
+ name = models.TextField(
16
+ verbose_name=_("name"),
17
+ help_text=_("The display name of the observer."),
18
+ )
19
+
20
+ original = models.TextField(
21
+ verbose_name=_("original name"),
22
+ help_text=_("The original name of the observer from eBird."),
23
+ )
24
+
25
+ multiple = models.BooleanField(
26
+ default=False,
27
+ verbose_name=_("Multiple accounts"),
28
+ help_text=_("Is the name used by more than one eBird account."),
29
+ )
30
+
31
+ enabled = models.BooleanField(
32
+ default=True,
33
+ verbose_name=_("Enabled"),
34
+ help_text=_("Load checklists from the eBird observer."),
35
+ )
36
+
37
+ data = models.JSONField(
38
+ verbose_name=_("Data"),
39
+ help_text=_("Data describing an Observer."),
40
+ default=dict,
41
+ blank=True,
42
+ )
43
+
44
+ def __repr__(self) -> str:
45
+ return str(self.identifier)
46
+
47
+ def __str__(self) -> str:
48
+ return str(self.name)
@@ -0,0 +1,118 @@
1
+ import json
2
+ import logging
3
+
4
+ from json import JSONDecodeError
5
+
6
+ from django.db import models
7
+ from django.utils.translation import get_language
8
+ from django.utils.translation import gettext_lazy as _
9
+
10
+ log = logging.getLogger(__name__)
11
+
12
+
13
+ class Species(models.Model):
14
+ class Category(models.TextChoices):
15
+ ALL = "", _("All categories")
16
+ SPECIES = "species", _("Species")
17
+ SUBSPECIES = "issf", _("Subspecies")
18
+ DOMESTIC = "domestic", _("Domestic")
19
+ HYBRID = "hybrid", _("Hybrid")
20
+
21
+ class Meta:
22
+ verbose_name = _("species")
23
+ verbose_name_plural = _("species")
24
+
25
+ taxon_order = models.IntegerField(
26
+ blank=True,
27
+ null=True,
28
+ verbose_name=_("taxonomy order"),
29
+ help_text=_("The position in the eBird/Clements taxonomic order."),
30
+ )
31
+
32
+ order = models.TextField(
33
+ blank=True,
34
+ verbose_name=_("order"),
35
+ help_text=_(
36
+ "The order, e.g. Struthioniformes, from the eBird/Clements taxonomy."
37
+ ),
38
+ )
39
+
40
+ category = models.TextField(
41
+ blank=True,
42
+ choices=Category,
43
+ verbose_name=_("category"),
44
+ help_text=_("The category from the eBird/Clements taxonomy."),
45
+ )
46
+
47
+ species_code = models.TextField(
48
+ blank=True,
49
+ verbose_name=_("species code"),
50
+ help_text=_("The species code, e.g. ostric2, used in the eBird API."),
51
+ )
52
+
53
+ family_code = models.TextField(
54
+ blank=True,
55
+ verbose_name=_("family code"),
56
+ help_text=_("The family code, e.g. struth1, used in the eBird API."),
57
+ )
58
+
59
+ common_name = models.TextField(
60
+ verbose_name=_("common name"),
61
+ help_text=_("The species common name in the eBird/Clements taxonomy."),
62
+ )
63
+
64
+ scientific_name = models.TextField(
65
+ verbose_name=_("scientific name"),
66
+ help_text=_("The species scientific name in the eBird/Clements taxonomy."),
67
+ )
68
+
69
+ family_common_name = models.TextField(
70
+ blank=True,
71
+ verbose_name=_("family common name"),
72
+ help_text=_(
73
+ "The common name for the species family in the eBird/Clements taxonomy."
74
+ ),
75
+ )
76
+
77
+ family_scientific_name = models.TextField(
78
+ blank=True,
79
+ verbose_name=_("family scientific name"),
80
+ help_text=_(
81
+ "The scientific name for the species family in the eBird/Clements taxonomy."
82
+ ),
83
+ )
84
+
85
+ data = models.JSONField(
86
+ verbose_name=_("Data"),
87
+ help_text=_("Data describing a Species."),
88
+ default=dict,
89
+ blank=True,
90
+ )
91
+
92
+ def __repr__(self) -> str:
93
+ return str(self.species_code)
94
+
95
+ def __str__(self) -> str:
96
+ return self.get_common_name()
97
+
98
+ def get_common_name(self) -> str:
99
+ try:
100
+ data = json.loads(self.common_name)
101
+ common_name = data.get(get_language(), "")
102
+ if not common_name:
103
+ common_name = data.get(next(iter(data)), "")
104
+ except JSONDecodeError:
105
+ log.error("Incorrect JSON for Species common_name: %s", self.id)
106
+ common_name = ""
107
+ return common_name
108
+
109
+ def get_family_common_name(self) -> str:
110
+ try:
111
+ data = json.loads(self.family_common_name)
112
+ family_name = data.get(get_language(), "")
113
+ if not family_name:
114
+ family_name = data.get(next(iter(data)), "")
115
+ except JSONDecodeError:
116
+ log.error("Incorrect JSON for Species family_name: %s", self.id)
117
+ family_name = ""
118
+ return family_name
@@ -0,0 +1,29 @@
1
+ from django.db import models
2
+ from django.utils.translation import gettext_lazy as _
3
+
4
+
5
+ class State(models.Model):
6
+ class Meta:
7
+ verbose_name = _("state")
8
+ verbose_name_plural = _("states")
9
+
10
+ code = models.CharField(
11
+ max_length=10,
12
+ db_index=True,
13
+ verbose_name=_("code"),
14
+ help_text=_("The code used to identify the state."),
15
+ )
16
+
17
+ name = models.TextField(
18
+ verbose_name=_("name"), help_text=_("The name of the state.")
19
+ )
20
+
21
+ place = models.TextField(
22
+ verbose_name=_("place"), help_text=_("The hierarchical name of the state.")
23
+ )
24
+
25
+ def __repr__(self) -> str:
26
+ return str(self.code)
27
+
28
+ def __str__(self) -> str:
29
+ return str(self.name)
@@ -0,0 +1,46 @@
1
+ import json
2
+
3
+ from django import forms
4
+ from django.conf import settings
5
+ from django.utils.translation import gettext_lazy as _
6
+
7
+
8
+ class TranslationTextInput(forms.MultiWidget):
9
+ template_name = "data/widgets/translation_field.html"
10
+
11
+ def __init__(self, *args, **kwargs):
12
+ widgets = [
13
+ forms.TextInput(attrs={"locale": _(language), "class": "vTextField"})
14
+ for code, language in settings.LANGUAGES
15
+ ]
16
+ super().__init__(widgets, **kwargs)
17
+
18
+ def decompress(self, value):
19
+ if value:
20
+ data = json.loads(value)
21
+ return [data.get(code, "") for code, language in settings.LANGUAGES]
22
+ return []
23
+
24
+
25
+ class TranslationTextarea(forms.MultiWidget):
26
+ template_name = "data/widgets/translation_field.html"
27
+
28
+ def __init__(self, *args, **kwargs):
29
+ if "widgets" not in kwargs:
30
+ kwargs["widgets"] = [
31
+ forms.Textarea(
32
+ attrs={
33
+ "locale": _(language),
34
+ "rows": 10,
35
+ "class": "vLargeTextField",
36
+ }
37
+ )
38
+ for code, language in settings.LANGUAGES
39
+ ]
40
+ super().__init__(**kwargs)
41
+
42
+ def decompress(self, value):
43
+ if value:
44
+ data = json.loads(value)
45
+ return [data.get(code, "") for code, language in settings.LANGUAGES]
46
+ return []
@@ -0,0 +1,206 @@
1
+ Metadata-Version: 2.4
2
+ Name: ebird-api-data
3
+ Version: 0.1.0
4
+ Summary: eBird API Data is a reusable Django app for loading data from eBird into a database.
5
+ Author-email: Stuart MacKay <smackay@flagstonesoftware.com>
6
+ License: The MIT License (MIT)
7
+
8
+ Copyright (c) 2025 Stuart MacKay
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Keywords: checklists,observations,species,Django,eBird,models
29
+ Classifier: Development Status :: 5 - Production/Stable
30
+ Classifier: Intended Audience :: Science/Research
31
+ Classifier: Framework :: Django
32
+ Classifier: Framework :: Django :: 4.2
33
+ Classifier: Framework :: Django :: 5.0
34
+ Classifier: Framework :: Django :: 5.1
35
+ Classifier: Framework :: Django :: 5.2
36
+ Classifier: License :: OSI Approved :: MIT License
37
+ Classifier: Natural Language :: English
38
+ Classifier: Programming Language :: Python :: 3.10
39
+ Classifier: Programming Language :: Python :: 3.11
40
+ Classifier: Programming Language :: Python :: 3.12
41
+ Classifier: Programming Language :: Python :: 3.13
42
+ Classifier: Topic :: Scientific/Engineering
43
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
44
+ Requires-Python: >=3.10
45
+ Description-Content-Type: text/x-rst
46
+ Requires-Dist: beautifulsoup4>=4.13.3
47
+ Requires-Dist: django>=4.2
48
+ Requires-Dist: ebird-api-requests>=4.0.1
49
+ Requires-Dist: ebird-codes>=0.0.2
50
+ Requires-Dist: lxml>=6.0.0
51
+
52
+ eBird API Data
53
+ ==============
54
+ eBird API Data is a reusable Django app for loading data from eBird into a database.
55
+
56
+ Overview
57
+ --------
58
+ .. overview-start
59
+
60
+ The Cornell Laboratory of Ornithology in Ithaca, New York runs the eBird database
61
+ which collects observations of birds from all over the world. All the observations
62
+ are published on `eBird.org`_, and they also make them available via an `API`_.
63
+ This project contains a loader and models to take data from the API and load it into
64
+ a database. From there you can analyse the data with python, jupyter notebooks, or
65
+ build a web site.
66
+
67
+ To get started, you will need to `sign up`_ for an eBird account, if you don't
68
+ already have one and `register`_ to get an API key. Make sure you read and
69
+ understand the `Terms of use`_, and remember bandwidth and servers cost money,
70
+ so don't abuse the service. If you need large numbers of observations, then
71
+ sign up to receive the `eBird Basic Dataset`_.
72
+
73
+ .. _eBird.org: https://ebird.org
74
+ .. _API: https://documenter.getpostman.com/view/664302/S1ENwy59
75
+ .. _sign up: https://secure.birds.cornell.edu/identity/account/create
76
+ .. _register: https://ebird.org/data/download
77
+ .. _Terms of use: https://www.birds.cornell.edu/home/ebird-api-terms-of-use/
78
+ .. _eBird Basic Dataset: https://science.ebird.org/en/use-ebird-data/download-ebird-data-products
79
+
80
+ .. overview-end
81
+
82
+ Install
83
+ -------
84
+ .. install-start
85
+
86
+ You can use either `pip`_ or `uv`_ to download the `package`_ from PyPI and
87
+ install it into a virtualenv:
88
+
89
+ .. code-block:: console
90
+
91
+ pip install ebird-api-data
92
+
93
+ or:
94
+
95
+ .. code-block:: console
96
+
97
+ uv add ebird-api-data
98
+
99
+ Update ``INSTALLED_APPS`` in your Django setting:
100
+
101
+ .. code-block:: python
102
+
103
+ INSTALLED_APPS = [
104
+ ...
105
+ ebird.api.data
106
+ ]
107
+
108
+ Finally, run the migrations to create the tables:
109
+
110
+ .. code-block:: python
111
+
112
+ python manage.py migrate
113
+
114
+ .. _pip: https://pip.pypa.io/en/stable/
115
+ .. _uv: https://docs.astral.sh/uv/
116
+ .. _package: https://pypi.org/project/ebird-api-data/
117
+
118
+ .. install-end
119
+
120
+ Demo
121
+ ----
122
+
123
+ .. demo-start
124
+
125
+ If you check out the code from the repository there is a fully functioning
126
+ Django site. It only contains the admin pages, but that is sufficient for
127
+ you to browse the data.
128
+
129
+ .. code-block:: console
130
+
131
+ git clone git@github.com:StuartMacKay/ebird-api-data.git
132
+ cd ebird-api-data
133
+
134
+ Create the virtual environment:
135
+
136
+ .. code-block:: console
137
+
138
+ uv venv
139
+
140
+ Activate it:
141
+
142
+ .. code-block:: console
143
+
144
+ source venv/bin/activate
145
+
146
+ Install the requirements:
147
+
148
+ .. code-block:: console
149
+
150
+ uv sync
151
+
152
+ Run the database migrations:
153
+
154
+ .. code-block:: console
155
+
156
+ python manage.py migrate
157
+
158
+ Create a user:
159
+
160
+ .. code-block:: console
161
+
162
+ python manage.py createsuperuser
163
+
164
+ Create a copy of the .env.example file and add your API key:
165
+
166
+ .. code-block:: console
167
+
168
+ cp .env.example .env
169
+
170
+ .. code-block:: console
171
+
172
+ EBIRD_API_KEY=<my api key>
173
+
174
+ Now, download data from the API:
175
+
176
+ .. code-block:: console
177
+
178
+ python manage.py add_checklists --days 2 US-NY-109
179
+
180
+ This loads all the checklists, submitted in the past two days by birders in
181
+ Tompkins County, New York, where the Cornell Lab is based. You can use any
182
+ location code used by eBird, whether it's for a country, state/region, or
183
+ county. Remember, read the terms of use.
184
+
185
+ Run the demo:
186
+
187
+ .. code-block:: console
188
+
189
+ python manage.py runserver
190
+
191
+ Now log into the `Django Admin <http:localhost:8000/admin>` to browse the tables.
192
+
193
+ .. demo-end
194
+
195
+ Project Information
196
+ -------------------
197
+
198
+ * Documentation: https://ebird-api-data.readthedocs.io/en/latest/
199
+ * Issues: https://github.com/StuartMacKay/ebird-api-data/issues
200
+ * Repository: https://github.com/StuartMacKay/ebird-api-data
201
+
202
+ The app is tested on Python 3.10+, and officially supports Django 4.2, 5.0 and 5.1.
203
+
204
+ eBird API Data is released under the terms of the `MIT`_ license.
205
+
206
+ .. _MIT: https://opensource.org/licenses/MIT
@@ -0,0 +1,25 @@
1
+ ebird/api/data/__init__.py,sha256=kUR5RAFc7HCeiqdlX36dZOHkUI5wI6V_43RpEcD8b-0,22
2
+ ebird/api/data/admin.py,sha256=SQWBoTzd2yrk9EdftwguJJ5ZdUkIjMVuW_ykEgyPIr8,12642
3
+ ebird/api/data/apps.py,sha256=o8wTQ_g9bgGXyEBXdmoj2y1SLUng8r0Mzsyg5uSXFCc,192
4
+ ebird/api/data/fields.py,sha256=TkWQL_bmct4t-RmIWKrBHk_OZQzikGS9H4LHV9dKVOY,1693
5
+ ebird/api/data/loaders.py,sha256=TgnvDmxqABouELyIbLcZ9vDio8FNkvTLrfezT6pzjT4,18041
6
+ ebird/api/data/widgets.py,sha256=R7UZAcd2Eh4pgRN8epfAbKJEjiriW7FYHWa2RV8F98w,1419
7
+ ebird/api/data/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ ebird/api/data/management/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ ebird/api/data/management/commands/add_checklists.py,sha256=_jw1jjfsPY9UyEUse-BdTBdrUGzYUlPx0uXz1LMjYhs,4853
10
+ ebird/api/data/migrations/0001_initial.py,sha256=lvTE6LDlDFEHdKatX26_lFSwNy8Ut7b0sWdnj4ovS2Q,33841
11
+ ebird/api/data/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ ebird/api/data/models/__init__.py,sha256=sk5oRhvJwa1AHlYKprgcC8DMnMxZZ77FXGkbR2DXKz8,423
13
+ ebird/api/data/models/checklist.py,sha256=sLc0a1UBDVgeAeei7zyNAEVybWEJxUNnVsMwkKnYdjo,4747
14
+ ebird/api/data/models/country.py,sha256=Z-k7mIxzZWuBNP2dtge8Q64WjM5tOyMROp9UDZLk9UA,742
15
+ ebird/api/data/models/county.py,sha256=kshpq35w_JWAYit9wqgP44QQ2NjJwy_njH-GrUn-1-Q,737
16
+ ebird/api/data/models/filter.py,sha256=hwwz2Vlmpj-4XRm_yz1j_M4UPdDms8AX4x-95WsdK14,1859
17
+ ebird/api/data/models/location.py,sha256=HSz848qQUNU3G2NGHRH5Gg7dEB4qbZOvXFYOJbh1jYk,5537
18
+ ebird/api/data/models/observation.py,sha256=18YSIpq3aq_9DjH7LF2HpGveLb9h3wRxGNoQpE5cBQI,5201
19
+ ebird/api/data/models/observer.py,sha256=M3OllGp391wDsgwJD8j639qeLRQ_MV5kiCW5HoQ6NB4,1284
20
+ ebird/api/data/models/species.py,sha256=ZmUrn7iLYw4FFIOVWSo0dX9U7KnRC8r2NlmAsH-ierw,3524
21
+ ebird/api/data/models/state.py,sha256=9xZOwjwuM4YLx5wva3wGXYH50oz_oHXOhbGqmyCAoaQ,730
22
+ ebird_api_data-0.1.0.dist-info/METADATA,sha256=hvaNtTpszEcWaLcdaDTmgRQk1cUabl6BEh8IIMH4rZA,6284
23
+ ebird_api_data-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
24
+ ebird_api_data-0.1.0.dist-info/top_level.txt,sha256=lBp3I23K75tsPJn7Jdz7d4Tk7JeRhbVkcuGthNk7LaM,6
25
+ ebird_api_data-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ ebird