Skip to content
alienbrett edited this page Mar 27, 2020 · 5 revisions

To import the library, just run

import ally

Then, we can create an an API object a couple different ways:

Environment Variables (Easy)

It's strongly recommended that the API keys be stored as environment variables. If the account variables are specified as recommended, instantiation is easy:

a = ally.Ally()

And you're done!


As Parameters (Insecure)

However, variables can be passed in on instantiation. This way, no account variables need to be set. Keep in mind that this is much less secure for distributable applications, since anyone with these keys will have access to the account with which they're associated.

params = {
    'resource_owner_secret':XXXX,
    'resource_owner_key':XXXX,
    'client_secret':XXXX,
    'client_key':XXXX
}
a = ally.Ally(params)

From File

Parameters can also be read from a JSON file: params.json

{
    'resource_owner_secret':XXXX,
    'resource_owner_key':XXXX,
    'client_secret':XXXX,
    'client_key':XXXX
}

Specifying Account Number

The object allows account numbers to be specified at each relevant function call, or to be specified as a permanent parameter like the API keys. If the account number isn't specified as an environment variable:

params = {
    ... # see above
    'account' : 12345678
}
a = ally.Ally(params)

Now you're ready to make API calls with your new object.