Skip to main content

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_url
  • Station — id, alias, lat, lon, streaming, version
  • StationStats — unique_species, call_count, top_bird
  • Weather — temp_f, temp_c, condition, humidity, wind_mph
  • YardListEntry — common_name, species_code, sighting_count, first_seen
  • SpeciesInfo — common_name, species_code, threshold
  • Stream — title, live_stream_url, streaming
  • BioDiversityRank — rank, competitors, percentile
  • GraphStatsEntry — ts, total_calls, unique_species

Running Tests

pip install -e ".[dev]"
pytest tests/ -v

License

MIT

Metadata

Release files for terra-listens-sdk 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for terra-listens-sdk 0.2.1
File Size Uploaded Provenance
terra_listens_sdk-0.2.1.tar.gz 13.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for terra-listens-sdk 0.2.1
File Interpreter ABI Platform
terra_listens_sdk-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 22.7 kB

Release files / terra_listens_sdk-0.2.1.tar.gz

Download URL terra_listens_sdk-0.2.1.tar.gz
Size 13.0 kB
Tags Source
SHA-256 checksum
How to use checksums
30cba7423385bbbcb85a1f333b0dd324904d39739fdfe11d8e6b459275d92e6c
BLAKE2b-256 checksum
How to use checksums
07e805701623cbf6e2cc6a2cd3411f8ae1f34f429b0cd4ea8311d4dd07e87c8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / terra_listens_sdk-0.2.1-py3-none-any.whl

Download URL terra_listens_sdk-0.2.1-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20b5bb65be3d16d54e6a9ec494418e45c9cef5a87644466c74654c257aa4c894
BLAKE2b-256 checksum
How to use checksums
c795933be4821e2bc4195e254bf7dd64b9a64fec747ab7f48d84a20507dab768
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Security for terra-listens-sdk 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page