Skip to main content

A Python client library for the Dropcountr API

Project description

Dropcountr Python Client

A Python client library for the Dropcountr API, providing easy access to water usage, cost, and goal data.

Installation

Quick Install (with existing Python environment)

pip install -r requirements.txt

Dependencies

  • httpx: Modern HTTP client with cookie and redirect support
  • uritemplate: RFC 6570 URI Template expansion per the Python Hyper project
  • python-dotenv: Environment variable management

Quick Start

Setup Environment Variables

  1. Copy the example environment file:
cp env.example .env
  1. Edit .env and add your credentials:
DROPCOUNTR_EMAIL=your_email@example.com
DROPCOUNTR_PASS=your_password

Run the Example

python example.py

This will:

  • Login and display user info
  • Fetch all premises and their meters
  • Display usage data (gallons, leak detection) for the last 3 days
  • Display cost data with detailed breakdowns

Usage

Basic Authentication and User Info

from dropcountr_client import DropcountrClient

# Create client instance
client = DropcountrClient(
    email="your_email@example.com",
    password="your_password"
)

# Login
client.login()

# Get user information
user_info = client.me()
print(user_info)

# Logout when done
client.logout()

Context Manager (Recommended)

from dropcountr_client import DropcountrClient

with DropcountrClient(email="your_email@example.com", password="your_password") as client:
    client.login()
    user_info = client.me()
    print(user_info)
    # Client automatically closes when exiting context

Fetching Data

# Get premise information
premise_data = client.premise("https://dropcountr.com/api/premises/123")

# Get service connection
connection_data = client.service_connection("https://dropcountr.com/api/service_connections/456")

Time Series Data

# Usage data
usage_data = client.usage(
    templated_url="https://dropcountr.com/api/usage{/period}{/during}",
    period="day",
    during="2023-01-01/2023-01-31"
)

# Cost data
cost_data = client.cost(
    templated_url="https://dropcountr.com/api/cost{/period}{/during}",
    period="month",
    during="2023-01-01/2023-12-31"
)

# Goal data
goal_data = client.goal(
    templated_url="https://dropcountr.com/api/goals{/period}{/during}",
    period="week",
    during="2023-01-01/2023-01-07"
)

API Methods

Authentication

  • login(): Authenticate with the Dropcountr API
  • logout(): End the current session
  • me(): Get current user information

Data Access

  • premise(url): Fetch premise data
  • service_connection(url): Fetch service connection data
  • usage(templated_url, period, during): Fetch usage time series
  • cost(templated_url, period, during): Fetch cost time series
  • goal(templated_url, period, during): Fetch goal time series

Parameters

Period

Common period values:

  • "hour": Hour Data
  • "day": Daily data
  • "month": Monthly data

During

Time range in ISO8601 interval format:

  • Format: "start_time/end_time"
  • Example: "2023-01-01/2023-01-31"

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

dropcountr_py-0.1.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

dropcountr_py-0.1.0-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file dropcountr_py-0.1.0.tar.gz.

File metadata

  • Download URL: dropcountr_py-0.1.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for dropcountr_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b0bb086c02482bdbcd4c4c4ecdd581a09680e551dd55d9a2c7b808a264a13c82
MD5 debd1bf70135aac16493e2cadd9f8092
BLAKE2b-256 ee598683ca597523fc1ac1af9ae1a75ab889ec30d4dae954b2d01d69c3c826b1

See more details on using hashes here.

File details

Details for the file dropcountr_py-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dropcountr_py-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for dropcountr_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 54aeb1203a1caa9c383d6610d4acbd13cc4dc126eca6711a2373770fe4cc2fb8
MD5 a1472c8a2d3d98a4303cdee2c4348dc3
BLAKE2b-256 39cfde04d9ac2a0f82526c117e47f0ba8691f49daf432b4e94ab14cd5f4a68f1

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