Rates Request
Rates uses the HTTP GET method, and a request to Rates only requires a zip code.
import requests
import json
ratesEndPoint = 'https://service.getpowerbill.com/api/v2/rates?postalcode='
userName = 'your_username@your_company.com'
password = 'yourPassword'
zipCode = '98105'
def get_default_residential_rate(zipCode,userName,password):
response = requests.get(ratesEndPoint+zipCode, auth=(userName, password))
if(response.status_code != requests.codes.ok):
print (response, response.text)
return
jsonResponse = response.json()['Rates']
for rate in jsonResponse:
if rate['Sector'] == 'Residential' and rate['IsDefault'] == True:
return rate['Id']
if __name__ == '__main__':
print ('Default residential rate ID: '+get_default_residential_rate(zipCode,userName,password))