Screen-scraping using curl is one approach. Try:
- Get a cookie jar from the auth app.
- Grab your accounts from the subscription app.
- Crunch the numbers.
This command will save your auth cookies in the SSCookies file:
$ curl -c SSCookies 'http://smartystreets.com/apps/accounting/auth' -d email=myEmail -d password=myPassword
Now use the cookie jar to auth with the subscription app. These commands will fetch your subscriptions:
$ subs=https://smartystreets.com/apps/accounting/subscription
$ curl -s -b @SSCookies $subs | python -mjson.tool
(The | python part makes the output pretty)
The resulting JSON will list your whole account history, including subscriptions that are no longer active and any that may be coming up for renewal. Look for the entry that has a status of "active":
[
{
"free": true,
"id": nnnnn,
"issued": 250.0,
"lapse_date": "2013-06-15T08:15:00Z",
"name": "LiveAddress API (Free)",
"sku": nnnnn,
"start_date": "2013-06-03T21:56:00Z",
"status": "expired",
"used": 250
},
{
"autorenew": true,
"id": nnnnn,
"issued": 1200000.0,
"lapse_date": "2015-06-20T20:11:00Z",
"name": "LiveAddress API (Yearly)",
"sku": nnnnn,
"start_date": "2014-06-20T20:11:00Z",
"status": "active",
"used": 934
},
{
"autorenew": true,
"cart_id": 0,
"issued": 1200000.0,
"lapse_date": "2016-07-20T20:11:00Z",
"name": "LiveAddress API (Yearly)",
"sku": nnnnn,
"start_date": "2015-07-20T20:11:00Z",
"status": "proposed"
}
]
My active subscription is #2 (index 1). Some Python to extract the vitals (I named this SSMonitor.py):
import json,sys;
obj=json.load(sys.stdin);
keys=obj[1].keys();
values=obj[1].values();
for i,key in enumerate(keys):
if (key=="used"): used=values[i];
if (key=="issued"): issued=values[i];
print "SmartyStreets subscription usage: {0}/{1}".format(used, issued);
$ curl -s -b @SSCookies $subs | python SSMonitor.py
SmartyStreets subscription usage: 934/1200000.0