API Documentation

dwolla-python

dwolla-python is a simple python module to use Dwolla’s REST API.

For the general API documentation and other dwolla documentation go to http://developers.dwolla.com/

exception dwolla.DwollaAPIError[source]

Raised if the dwolla api returns an error.

class dwolla.DwollaClientApp(client_id, client_secret)[source]

Encapsulates OAuth dance, and making requests to the dwolla api.

api_request(resource, **params)[source]

Helper function that makes an API request, by automatically setting the client_id, and client_secret url parameters.

get(resource, **params)[source]
Get an API resource via the REST api. E.g. to get a certain user::
resource = “user/” + account_id user = dwolla_client.get(resource)
Parameters:
  • resource – the resource to fetch.
  • **params

    optional arguments to use as url arguments, depending on the kind of resource being fetched (.e.g range=10, limit=10, etc.)

get_account_info(account_id)[source]

Convinience function to get a certain user accounts data. Equivalent to doing `dwolla_client.get("users/%"%account_id)`

Parameters:account_id – Dwolla account identifier or email address of the Dwolla account
get_nearby_spots(lat='41.59', lon='-93.62', range=10, limit=10)[source]

Convinience function to get a list of nearby dwolla spots for a given lat,long.

Parameters:
  • lat – lattitude of location. defaults to ‘41.59’
  • long – longitude of location. defaults to ‘-92,62’
  • range – number of miles within which to look for spots. defaults to 10
  • limit – limit the number of results. defaults to 10.
get_oauth_token(code, **kwargs)[source]

Returns a valid OAuth token given the code you got from dwolla when they redirected the user back to your site after you sent them to the url generated by :method:`init_oauth_url`.

Parameters:
  • code – Verification code obtained from dwolla in response to user authorizing your application
  • grant_type – (optional) set’s the grant_type url parameter. defaults to authorization_code
  • redirect_uri – (optional) URI user was redirected back to by dwolla. This must match the URI you specified when you generated the initial OAuth redirect via init_oauth_url
init_oauth_url(redirect_uri=None, scope='accountinfofull')[source]

geneates url to initialize the Oauth dance. redirext the user to the returned URL, and the Dwolla API will authenticat/authorize the request and redirect back to the default OAuth Callback URL you registered with dwolla, or to the url you pass via the redirect_uri parameter.

Parameters:
  • redirect_uri – URL to return the user to after they approve or deny the authentication request. If not provided, will default to registered OAuth Callback URL.
  • scope – “|” seperated string of any auth scope you are requesting access to. For example “balance|contacts|transactions” to request access to balance, contacts, and transaction resources. Availeble resources inlude: balance, contacts, transactions, request, send, accountinfofull, funding.
parse_response(resp)[source]

Helper function to parse json API response. Raises DwollaAPIError if the response indicates an error.

register_user(email, password, pin, firstName, lastName, address, address2, city, state, zip, phone, dateOfBirth, organization=None, ein=None, type='Personal', acceptTerms='true')[source]

Register a new Dwolla user account

Parameters:
  • email – (required) Email address of the new user
  • password – (required) Desired user’s password
  • pin – (required) Desired 4 digit PIN
  • firstName – (required) User’s first name
  • lastName – (required) User’s last name
  • address – (required) Line 1 of the address
  • address2 – (optional) Line 2 of the address
  • city – (required) City.
  • state – (required) USA state or territory two character code.
  • zip – (required) Postal code or zip code.
  • phone – (required) Primary phone number of the user.
  • dateOfBirth – (required) Date of birth of the user.
  • organization – (optional) Company name for a commercial or non-profit account.
  • type – (optional) Account type of the new user. Defaults to Personal. Options are Personal, Commercial, and NonProfit.
  • acceptTerms – (optional) Did user agree to Dwolla’s TOS?
class dwolla.DwollaUser(access_token)[source]

Once you have an access token for a specfic user, you can use it to instatiate this class, ehich wraps usefull api resources/functions.

get_account_info()[source]

returs the account info for this user account

get_balance()[source]

returns the balance for this user account

get_contacts(search=None, types=None, limit=None)[source]

returns a list of contacts for this user account.

Parameters:
  • search – (optional) Search term used to search the contacts.
  • types – (optional) not sure?
  • search – (optional) Number of contacts to retrieve. Defaults to 10. Can be between 1 and 200 contacts .
get_funding_source(source_id)[source]

Returns the data for a specific funding source given its ID.

Parameters:source_id – Funding source identifier of the funding source being requested.
get_funding_sources()[source]

Returns a list of verified funding sources for the user

get_transaction(transaction_id)[source]

returns a specific transaction resource

Parameters:transaction_id – id of the transaction to fetch.
get_transaction_list(since='', types='', limit=None, skip=None)[source]

returns a list of contacts for this user account.

Parameters:
  • since – (optional) Earliest date and time for which to retrieve transactions. Defaults to 7 days prior to current date and time in UTC. Can be string with format ‘mm-dd-YYYY’ or a python datetime.datetime object.
  • types – (optional) Transaction types to retrieve. Must be delimited by a ‘|’. Options are money_sent, money_received, deposit, withdrawal, and fee. Defaults to include all transaction types.
  • skip – (optional) Numer of transactions to skip. Defaults to 0.
Param:

limit: (optional) Number of transactions to retrieve. Defaults to 10. Can be between 1 and 200 transactions.

get_transaction_stats(types=None, start_date='', end_date='')[source]

returns transaction stats for the user account.

Parameters:
  • start_date – (optional) Starting date and time to for which to process transactions stats. Defaults to 0300 of the current day in UTC. Can be string with format ‘mm-dd-YYYY’ or a python datetime.datetime object.
  • end_date – (optional) Starting date and time to for which to process transactions stats. Defaults to 0300 of the current day in UTC. Can be string with format ‘mm-dd-YYYY’ or a python datetime.datetime object.
request_funds(amount, source, pin, notes=None, facil_amount=None, source_type=None)[source]

Request funds from another dwolla user on behalf of the user.

Parameters:
  • amount – Amount of funds to transfer to the user.
  • source – Identification of the user to request funds from. Must be the Dwolla identifier, Facebook identifier, Twitter identifier, phone number, or email address.
  • pin – User’s pin number to verify transaction.
  • notes – (optional )Note to attach to the transaction. Limited to 250 characters.
  • facil_amount – (optional) Amount of the facilitator fee to override. Only applicable if the facilitator fee feature is enabled. If set to 0, facilitator fee is disabled for transaction. Cannot exceed 25% of the ‘amount’.
  • source_type – (optional) Type of destination user. Defaults to “Dwolla”. Can be “Dwolla”, “Facebook”, “Twitter”, “Email”, or “Phone”.
send_funds(amount, dest, pin, notes=None, assume_cost=None, facil_amount=None, dest_type=None)[source]

Send funds from this user account to another one.

Parameters:
  • amount – Amount of funds to transfer to the destination user.
  • dest – Identification of the user to send funds to. Must be the Dwolla identifier, Facebook identifier, Twitter identifier, phone number, or email address.
  • pin – User’s pin number to verify transaction.
  • notes – (optional )Note to attach to the transaction. Limited to 250 characters.
  • assume_cost – (optional) Set to True if the user will assume the Dwolla fee. Set to false if the destination user will assume the Dwolla fee. Does not affect facilitator fees. Defaults to false.
  • facil_amount – (optional) Amount of the facilitator fee to override. Only applicable if the facilitator fee feature is enabled. If set to 0, facilitator fee is disabled for transaction. Cannot exceed 25% of the ‘amount’.
  • dest_type – (optional) Type of destination user. Defaults to “Dwolla”. Can be “Dwolla”, “Facebook”, “Twitter”, “Email”, or “Phone”.