3

In SmartyStreets, I can view my subscription balance while logged in on the portal. There's no way to check my subscription balance via the API. Our app requires address validation in order to sell. As part of operationalizing SmartyStreets, I want to monitor my subscription balance, so I can be alerted to renew before I run out of address validations.

Available monitoring tools are Nagios, Nimsoft and CA APM.

Has anyone built such a monitor?

ChasSchley
  • 49
  • 2

2 Answers2

3

SmartyStreets subscriptions renew on 2 occasions:

  1. It expires (e.g. a month or year has passed)
  2. Your lookups get depleted

The second trigger is there so that you don't have to worry about how used up your subscription is; if you run out, it just fills up with more without interrupting your service.

As for monitoring, it's kind of built-in. You should get emails when your subscription is running low, when it is about to renew, and when it actually does renew.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Matt
  • 22,721
  • 17
  • 71
  • 112
1

Screen-scraping using curl is one approach. Try:

  1. Get a cookie jar from the auth app.
  2. Grab your accounts from the subscription app.
  3. 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

ChasSchley
  • 49
  • 2
  • While this definitely works (for now), it's not a contractual URL as indicated in the documentation, which means that SmartyStreets reserves the right to change the signature, payload, etc. etc. at their sole and absolute discretion and without warning. This means the usual caveats and disclaimers apply. – Jonathan Oliver Feb 18 '15 at 22:10