Skip to main content

A package to access the WattTime API v2

Reason this release was yanked:

Package has been replaced by an officially maintained python client (version 1.0)

Project description

WattTime API v2 - Easy to Use Model

Creating an easier way to interact with WattTime API v2 (api2.watttime.org) The API documentation is at: https://watttimeapiv2.docs.apiary.io and the Watttime organization is really cool, so check them out at https://www.watttime.org/.

Written in Python 3.7, should work with 3.6+

On PyPI pip install watttime

To use:

If you already have a username and password registered with the API v2, then no need to register again. If you do not, follow these steps:

from watttime.api import WattTime

w = WattTime(username=<DesiredUsername>, password=<YourDesiredPassword>)
w.register(email=<your@email.com>, organization=<your organization>)

console output:

Registering...
{'user': '<DesiredUsername>', 'ok': 'User created'}

If you need to reset your password:

w.reset_password()

console output:

{'ok': 'Please check your email for the password reset link'}

Before you do any work, you must request a token:

w.get_token()

console output:

{'token': 'crazy_hash'}
Token received, setting headers: crazy_hash

Now you're ready to get your realtime emissions!!!

If you want to use latitude and longitude, pass them into your function explicitly

data = w.get_realtime_emissions(latitude=37.871667, longitude=-122.272778)

console output:

No balancing authority passed, getting data for
    latitude=37.871667
    longitude=-122.272778
{'id': 137, 'abbrev': 'CAISO_NP15', 'name': 'CAISO NP15 Trading Hub'}
Setting balancing_authority: CAISO_NP15
Getting data for balancing authority: CAISO_NP15
URL requested = https://api2.watttime.org/v2/index/?ba=CAISO_NP15&style=all
{'validUntil': '2019-10-02T21:45:00Z', 'pointTime': '2019-10-02T21:40:00Z', 'freq': '300', 'market': 'RTM', 'ba': 'CAISO_NP15', 'rating': '4', 'switch': '0', 'percent': '64', 'point_time': '2019-10-02T21:40:00Z', 'validFor': 175}

your data variable output in console:

{'validUntil': '2019-10-02T21:45:00Z',
 'pointTime': '2019-10-02T21:40:00Z',
 'freq': '300',
 'market': 'RTM',
 'ba': 'CAISO_NP15',
 'rating': '4',
 'switch': '0',
 'percent': '64',
 'point_time': '2019-10-02T21:40:00Z',
 'validFor': 175}

If you prefer to pass in a balancing authority, you may do so explicitly as well. Note: anything you pass as ba will overwrite and set your instance balancing_authority to whatever you pass and that will be used by default until you change it.

w.get_realtime_emissions(ba='<your_balancing_authority_abbreviation>')

If you need to find a balancing authority (because you can't overwrite by using latitude and longitude alone, use the get_balancing_authority function in order to override it.

w.get_balancing_authority(latitude=37.871667, longitude=-122.272778)

Then you may proceed as normal!

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

watttime-0.0.2.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

watttime-0.0.2-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file watttime-0.0.2.tar.gz.

File metadata

  • Download URL: watttime-0.0.2.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for watttime-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c81ea666c009aad9866d7985a8bea0ef7afcb03d6c8ea9c5b067a97e219488c1
MD5 f26af9efe7bb1143081d75ee72445242
BLAKE2b-256 c7b6c323bda0bef35d25712ce314a7e913ba0a34577b955651605571ba76a9e3

See more details on using hashes here.

File details

Details for the file watttime-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: watttime-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for watttime-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a9da02f0d5df3c8e2adf190e12b7f50a8ebdbae3cd5f3634eeb5aebeab42ac97
MD5 9b2361a247ace5e2c3f57d429aaad8e4
BLAKE2b-256 f2cc8ce501888a94e796fda63ef174dca41ebffd9f6ca2765e495fdb4e25a5e8

See more details on using hashes here.

Supported by

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