Python SDK for the Terra Listens bioacoustic monitoring platform
Project description
Terra SDK
Python SDK for the Terra Listens bioacoustic monitoring platform.
Wraps the Terra Listens backend API to provide programmatic access to bird detections, station data, weather, yard lists, and more.
Installation
python -m venv .venv && source .venv/bin/activate
pip install -e .
Quick Start
from terra_sdk import TerraClient
# From .env file (USERNAME, PASSWORD)
client = TerraClient.from_env()
# Or explicit credentials
client = TerraClient("you@example.com", "your-password")
# Or reuse an existing token
client = TerraClient(token="your-token")
Usage
from terra_sdk import TerraClient
client = TerraClient.from_env()
# List your stations
devices = client.get_devices()
station = devices[0]
print(f"{station.alias} - {station.id}")
# Get latest bird detections
birds = client.get_latest_birds(count=10, min_confidence=0.5)
for bird in birds:
print(f"{bird.common_name} ({bird.confidence:.0%}) - {bird.timestamp}")
print(f" Audio: {bird.audio_url}")
print(f" Image: {bird.image_url}")
# Station stats
stats = client.get_stats()
print(f"{stats.unique_species} species, {stats.call_count} calls")
print(f"Top bird: {stats.top_bird}")
# Weather
weather = client.get_weather()
print(f"{weather.condition}, {weather.temp_f}°F")
# Yard life-list
yard = client.get_yard_list(timeframe="all")
for entry in yard:
print(f"{entry.common_name}: {entry.sighting_count} sightings")
# Species list with confidence thresholds
species = client.get_species_list()
for s in species:
print(f"{s.common_name} ({s.species_code}) threshold={s.threshold:.2f}")
# Biodiversity ranking
rank = client.get_biodiversity_rank()
print(f"Rank {rank.rank} of {rank.competitors} ({rank.percentile}th percentile)")
# Streams (global public feeds)
streams = client.get_streams()
for s in streams:
print(f"{s.title}: {s.live_stream_url}")
If you have only one Terra station, device_id is auto-selected. Otherwise pass it explicitly:
birds = client.get_latest_birds("0123FB1FA9136F95EE", count=5)
CLI
Quick test from the command line:
python -m terra_sdk
Environment Variables
Create a .env file:
USERNAME=you@example.com
PASSWORD=your-password
Or set TERRA_TOKEN directly if you already have one.
API Methods
| Method | Description |
|---|---|
login() |
Authenticate and get token |
get_devices() |
List your Terra stations |
get_user_info() |
Account profile |
get_latest_birds(device_id, count, min_confidence) |
Latest detections |
get_species_list(device_id) |
All species detected at station |
get_stats(device_id) |
Station statistics |
get_weather(device_id) |
Weather at station |
get_yard_list(device_id, timeframe) |
Yard life-list |
get_biodiversity_rank(device_id) |
Biodiversity ranking |
get_graph_stats(device_id) |
Call activity over time |
get_streams() |
Public audio streams |
get_notifications_list(device_id) |
Notification preferences |
get_station_tags(device_id) |
Radio tags (Motus) |
vote(detection_id, direction, device_id) |
Vote on bird ID |
Models
All responses are typed Pydantic models:
BirdDetection— common_name, scientific_name, alpha_code, confidence, timestamp, audio_url, image_urlStation— id, alias, lat, lon, streaming, versionStationStats— unique_species, call_count, top_birdWeather— temp_f, temp_c, condition, humidity, wind_mphYardListEntry— common_name, species_code, sighting_count, first_seenSpeciesInfo— common_name, species_code, thresholdStream— title, live_stream_url, streamingBioDiversityRank— rank, competitors, percentileGraphStatsEntry— ts, total_calls, unique_species
Running Tests
pip install -e ".[dev]"
pytest tests/ -v
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file terra_listens_sdk-0.2.0.tar.gz.
File metadata
- Download URL: terra_listens_sdk-0.2.0.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12124edc76e0f0f911d93a3194db7c74d5b783fcde92187ff4fda8726224f858
|
|
| MD5 |
8624f5266f4d95dea98f11dc5dd80f05
|
|
| BLAKE2b-256 |
2b2a1c59d580eb3927d47f06761799b7a14f74b23352869e594b0eec778ce1bc
|
File details
Details for the file terra_listens_sdk-0.2.0-py3-none-any.whl.
File metadata
- Download URL: terra_listens_sdk-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd2a708ddc625ee9443a345ead4df46be644859f42379c806ad32f2e6cbed3f5
|
|
| MD5 |
81390fa6ccbe579dc084620fd526e9a2
|
|
| BLAKE2b-256 |
cc5a40009604f8d6ced7646541eae7619731c500ba84d8c34c7f9319a87ce2f6
|