### Install eBird API Python Library Source: https://github.com/projectbabbler/ebird-api/blob/master/README.md Instructions to install the ebird-api Python package using pip, the standard package installer for Python. ```Shell pip install ebird-api ``` -------------------------------- ### Fetch eBird Observations for Multiple Locations or Regions Source: https://github.com/projectbabbler/ebird-api/blob/master/README.md Shows how to query `get_observations` for multiple locations or regions by passing a list or a comma-separated string. It includes examples for specific locations and counties, demonstrating the use of additional parameters like `provisional` and `category`. ```Python import os from ebird.api import get_observations api_key = os.environ["EBIRD_API_KEY"] # Get the observations for the most visited locations in Madison county, New York: # Woodman Pond, Ditch Bank Rd., Cornell Biological Field Station and # Anne V Pickard Memorial Wildlife Overlook. locations = ['L227544', 'L273783', 'L677871', 'L2313391'] get_observations(api_key, locations, provisional=True, detail='full') # Get the observations for Suffolk, Nassau and Queens counties in New York state. counties = 'US-NY-103,US-NY-059,US-NY-81' records = get_observations(api_key, locations, hotspot=False, category='species') ``` -------------------------------- ### Initialize eBird API Client and Fetch Observations (Python) Source: https://github.com/projectbabbler/ebird-api/blob/master/README.md This snippet demonstrates how to initialize the 'ebird.api.Client' class using an API key retrieved from environment variables and a specified locale. It then shows an example of calling the 'get_observations' method to retrieve bird observations for a given location code, simplifying interaction with the eBird API. ```python import os from ebird.api import Client api_key = os.environ["EBIRD_API_KEY"] locale = 'es' client = Client(api_key, locale) client.get_observations('MX-OAX') ``` -------------------------------- ### Discover eBird Hotspots and Their Details Source: https://github.com/projectbabbler/ebird-api/blob/master/README.md This example illustrates how to interact with eBird's hotspot data. It covers listing all hotspots in a region, finding recently visited hotspots, identifying hotspots within a specified radius of coordinates, and retrieving detailed information for a specific hotspot ID. An API key is used for authentication. ```Python import os from ebird.api import get_hotspots, get_nearby_hotspots, get_hotspot api_key = os.environ["EBIRD_API_KEY"] # List all the hotspots in New York state. hotspots = get_hotspots(api_key, 'US-NY') # List all the hotspots in New York state visited in the past week. recent = get_hotspots(api_key, 'US-NY', back=7) # List all the hotspots in within 50kn of Point Reyes nearby = get_nearby_hotspots(api_key, 38.05, -122.94, dist=50) # Get the details of Anne V Pickard Memorial Wildlife Overlook in New York state. details = get_hotspot(api_key, 'L2313391') ``` -------------------------------- ### Access eBird Taxonomy Data and Species Codes Source: https://github.com/projectbabbler/ebird-api/blob/master/README.md This example illustrates how to retrieve eBird's comprehensive taxonomic information. It covers fetching the full species taxonomy, localized common names, specific species details, subspecies and form codes, and information about taxonomy revisions. This is crucial for obtaining species codes used in other API calls. ```Python import os from ebird.api import get_taxonomy, get_taxonomy_forms, get_taxonomy_versions api_key = os.environ["EBIRD_API_KEY"] # Get all the species in the eBird taxonomy. taxonomy = get_taxonomy(api_key) # Get all the species in the eBird taxonomy with common names in Spanish names = get_taxonomy(api_key, locale='es') # Get all the taxonomy for Horned Lark species = get_taxonomy(api_key, species='horlar') # Get the codes for all the subspecies and froms recognised for Barn Swallow. forms = get_taxonomy_forms(api_key, 'barswa') # Get information on all the taxonomy revisions, i.e. versions. # Usually only the latest is important. versions = get_taxonomy_versions(api_key) ``` -------------------------------- ### Retrieve eBird Statistics and Top Observers Source: https://github.com/projectbabbler/ebird-api/blob/master/README.md This snippet demonstrates how to access statistical data from eBird. It shows how to retrieve the 'Top 100' observers for a specific region and date, typically used for events like 'Big Days', and how to get daily totals for contributors, checklists, and species seen in a region. An API key is required. ```Python import os from datetime import date from ebird.api import get_top_100, get_totals api_key = os.environ["EBIRD_API_KEY"] # Get the winner of the Global Big Day in New York, on 5th May 2018 winners = get_top_100(api_key, 'US-NY', '2018-05-05') # Get the number of contributors, checklist submitted and species seen today totals = get_totals(api_key, 'US-NY', date.today()) ``` -------------------------------- ### Find Nearest Location for a Species with eBird API Source: https://github.com/projectbabbler/ebird-api/blob/master/README.md This Python example uses the `get_nearest_species` function to locate the closest geographical point where a specific bird species has been observed. It requires an API key, species code, and coordinates (latitude, longitude) to perform the search. The API key is loaded from an environment variable. ```Python import os from ebird.api import get_nearest_species api_key = os.environ["EBIRD_API_KEY"] # Where is the closest place to Cornell Lab of Ornithology to see # Tennessee Warbler. locations = get_nearest_species(api_key, 'tenwar', 42.48, -76.45) ``` -------------------------------- ### Retrieve eBird Checklists and Visit Details Source: https://github.com/projectbabbler/ebird-api/blob/master/README.md This snippet demonstrates how to fetch eBird checklist data. It uses `get_visits` to retrieve lists of visits for a given region, optionally filtered by date, and `get_checklist` to obtain detailed observations from a specific checklist ID. An API key is required, typically loaded from an environment variable. ```Python import os from ebird.api import get_visits, get_checklist api_key = os.environ["EBIRD_API_KEY"] # Get visits made recently to locations in New York state: visits = get_visits(api_key, 'US-NY') # Get visits made recently to locations in New York state on Jan 1st 2010 recent_visits = get_visits(api_key, 'US-NY', '2010-01-01') # Get the details of a checklist checklist = get_checklist(api_key, 'S22536787') ``` -------------------------------- ### Fetch eBird Observations by Location Source: https://github.com/projectbabbler/ebird-api/blob/master/README.md Demonstrates how to use the `get_observations` function to retrieve bird observations for various geographical scopes (hotspot, county, state, country) using an API key. It highlights the importance of storing API keys securely, preferably as environment variables. ```Python import os from ebird.api import get_observations # Always store secrets outside the code, so you don't accidentally # commit them. Environment variables are ideal for this. api_key = os.environ["EBIRD_API_KEY"] # Get observations from Woodman Pond, Madison county, New York for the past week. this_week = get_observations(api_key, 'L227544', back=7) # Get observations from Madison county, New York country_records = get_observations(api_key, 'US-NY-053') # Get observations from New York state_records = get_observations(api_key, 'US-NY') # Get observations from the USA - don't overdo the data downloads national_records = get_observations(api_key, 'US') ``` -------------------------------- ### Fetch eBird Observations with Localized Species Names Source: https://github.com/projectbabbler/ebird-api/blob/master/README.md Illustrates how to retrieve observations with species common names translated into a specified locale (e.g., French) by using the `locale` parameter in the `get_observations` function. This allows for displaying bird names in different languages. ```Python import os from ebird.api import get_observations api_key = os.environ["EBIRD_API_KEY"] records = get_observations(api_key, 'CA-QC', locale='fr') ``` -------------------------------- ### Explore eBird Geographical Regions and Boundaries Source: https://github.com/projectbabbler/ebird-api/blob/master/README.md This snippet demonstrates how to query eBird's geographical region data. It shows how to list sub-regions (countries, states, counties), find regions adjacent to a given area, and retrieve approximate boundary information for a specific region. An API key is required for these operations. ```Python import os from ebird.api import get_regions, get_adjacent_regions, get_region api_key = os.environ["EBIRD_API_KEY"] # Get the list of countries in the world. countries = get_regions(api_key, 'country', 'world') # Get the list of states in the US. states = get_regions(api_key, 'subnational1', 'US') # Get the list of counties in New York state. counties = get_regions(api_key, 'subnational2', 'US-NY') # Get the list of states which border New York state. nearby = get_adjacent_regions(api_key, 'US-NY') # Get the approximate area covered by New York state. bounds = get_region(api_key, 'US-NY') ``` -------------------------------- ### Fetch Nearby eBird Observations by Coordinates Source: https://github.com/projectbabbler/ebird-api/blob/master/README.md Demonstrates using `get_nearby_observations` to find the most recent sightings of all species within a specified distance and time frame from given geographical coordinates. This is useful for finding the nearest place to see a particular species. ```Python import os from ebird.api import get_nearby_observations api_key = os.environ["EBIRD_API_KEY"] # Get the most recent sightings of all species seen in the last week within # 10km of Point Reyes National Seashore. records = get_nearby_observations(api_key, 38.05, -122.94, dist=10, back=7) ``` -------------------------------- ### Retrieve Nearby Species Sightings with eBird API Source: https://github.com/projectbabbler/ebird-api/blob/master/README.md This snippet demonstrates how to use the `get_nearby_species` function to find recent sightings of a specific bird species within a given geographical area. It requires an API key, species code, latitude, longitude, and a 'back' parameter to specify the number of days to look back for observations. ```Python # Find out if Barn Swallows have been seen in the area in the past 10 days nearby_species = get_nearby_species(api_key, 'barswa', 38.05, -122.94, back=10) ``` -------------------------------- ### Fetch Notable or Species-Specific eBird Observations Source: https://github.com/projectbabbler/ebird-api/blob/master/README.md Shows how to use specialized functions like `get_notable_observations`, `get_species_observations`, and `get_nearby_notable` to filter observations. These functions allow retrieving data for rare species, specific species, or notable sightings within a region or near coordinates. ```Python import os from ebird.api import ( get_notable_observations, get_nearby_notable, get_species_observations, get_nearby_species, ) api_key = os.environ["EBIRD_API_KEY"] # Get the interesting birds seen in New York state. notables = get_notable_observations(api_key, 'US-NY') # Get the observations of Horned Lark (Eremophila alpestris) in New York state. records = get_species_observations(api_key, 'horlar', 'US-NY') # Get the interesting birds within 50kn of Point Reyes nearby_notables = get_nearby_notable(api_key, 38.05, -122.94, dist=50) ``` -------------------------------- ### Set Default Socket Timeout for Network Connections (Python) Source: https://github.com/projectbabbler/ebird-api/blob/master/README.md This code snippet illustrates how to set a default timeout for all socket connections in Python. This is a crucial troubleshooting step for preventing programs from hanging indefinitely when external API connections, such as to the eBird API, occasionally freeze. A 30-second timeout is suggested as a reasonable default. ```python import socket socket.setdefaulttimeout(30) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.