Skip to main content

Client for EarthRanger API

Project description

EarthRanger Client

Introduction

EarthRanger is a software solution that helps protected area managers, ecologists, and wildlife biologists make informed operational decisions for wildlife conservation.

The earthranger-client (er-client) is a Python library for accessing the EarthRanger HTTP API. It simplifies interaction with the API by abstracting away the complexity of resource-based endpoints and provides multi-threaded and async capabilities for improved performance.

Uses of er-client

  • Extracting data for analysis
  • Importing ecological or other historical data
  • Integrating a new field sensor type. If you do and will be supporting multiple ER sites, contact us to talk about our Gundi integrations platform
  • Performing external analysis that results in publishing an Alert on the ER platform.

Quick Start

see simple-example.py

Installation

From pypi

pip install earthranger-client

Usage

In your code, import the library and create an instance of the client.

from erclient import ERClient

client = ERClient(service_root="https://sandbox.pamdas.org/api/v1.0", username="", password="")

Async Support

We also offer an async client (asyncio).

Disclaimer: The async client is experimental and the current capabilities are limited to:

  • Posting Sensor Observations (a.k.a Positions)
  • Posting Reports (a.k.a Events)
  • Posting Report Attachments
  • Posting Camera Trap Reports
  • Getting Events
  • Getting Observations
from erclient import AsyncERClient

# You can use it as an async context-managed client
async with AsyncERClient(service_root="https://sandbox.pamdas.org/api/v1.0", username="", password="") as client:
   await self.er_client.post_sensor_observation(position)
   await client.post_report(report)
   await self.er_client.post_camera_trap_report(camera_trap_payload, file)
   ...
   
async with AsyncERClient(service_root="https://sandbox.pamdas.org/api/v1.0", username="", password="") as client:
   async for observation in client.get_observations(start="2023-11-10T00:00:00-06:00"):
      print(observation)
      ...

# Or create an instance and close the client explicitly later
client = AsyncERClient(service_root="https://sandbox.pamdas.org/api/v1.0", username="", password="")
await self.er_client.post_sensor_observation(position)
await client.post_report(report)
await self.er_client.post_camera_trap_report(camera_trap_payload, file)
...
await client.close()  # Close the session used to send requests to ER API

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

earthranger_client-1.6.0.tar.gz (276.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

earthranger_client-1.6.0-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

Details for the file earthranger_client-1.6.0.tar.gz.

File metadata

  • Download URL: earthranger_client-1.6.0.tar.gz
  • Upload date:
  • Size: 276.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.14

File hashes

Hashes for earthranger_client-1.6.0.tar.gz
Algorithm Hash digest
SHA256 83ffc02515327c3f8e9e1319c832d53463d7d31e76325bbff843daedc4f2aae9
MD5 4fc5cd2267197ff4a8f5a2bd8e19d169
BLAKE2b-256 42df332ebc39da5d970a7e51db965b404cd6079ba24fd6489e5cb3518e706a31

See more details on using hashes here.

File details

Details for the file earthranger_client-1.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for earthranger_client-1.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e09008847013a3ed21be9c6f7267ff83aba220758d4a47522220dc8dba5f595d
MD5 ce139aa4df9b6b13e6366af1d420c140
BLAKE2b-256 ccc165a375d3947d539ecee5962738e2dec0ac14a817f6e5bfe17324c82ae6b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page