Django: Ripple API app.

42 Coffee Cups have published an application that helps to work with API of Ripple in Django. We use it on production but it's still beta or even alpha so feel free to create issues on github.

Main developers are jetmind and Kostya Shish. And I just ripped it from our project to make standalone reusable app.

Install it as usual Django app:
  1. Install it into your environment (e.g. with pip):

    pip install django-ripple_api==0.0.2
  2. Add app to

        # ...
        # ...
  3. Add API auth info to settings:

    RIPPLE_API_URL = '' 
    RIPPLE_API_USER = 'api_user'  # some api servers require additional auth. Set username if server needs it
    RIPPLE_API_PASSWORD = 'api_password'  # some api servers require additional auth. Set password if server needs it
    RIPPLE_ACCOUNT = 'rnAoa45cMnBQb85mUnPep2yeJAvUtToCiL'
    RIPPLE_SECRET = 'some_secret_of_RIPPLE_ACCOUNT'
Now you can use it:
  1. Now you can send transactions and get info about existing transactions:

    from ripple_api.ripple_api import sign, submit, account_tx, tx
    import pprint 
    pp = pprint.PrettyPrinter(indent=1)
    # get info on account transactions:
    # {u'status': u'success', u'ledger_index_max': 5841226, u'account': rNMW2mJHowD6d4KUvm2XXXXXXXXXXXXX', u'transactions': [], u'ledger_index_min': 5841221}
    # get info about specific transaction:
    tx_info = tx('41C03F1A6CD2B7B11118C85A964AEA0364EDC10E1990FBD8A17946XXXXXXXX')
    # {u'Account': rNMW2mJHowD6d4KUvm2XXXXXXXXXXXXX',
    #  u'Amount': {u'currency': u'XXX',
    #              u'issuer': u'rBeToNo4AwHaNbXXXXXXXXXXXXXXXX',
    #              u'value': u'0.2'},
    #  u'Destination': u'rBeToNo4AXXXXXXXXXXXXXXXXXX',
    #  u'DestinationTag': 4060,
    #  ...
    #  u'meta': {u'AffectedNodes': [{u'ModifiedNode': {u'FinalFields': {u'Balance': {u'currency': u'XXX',
    # ...
    #            u'TransactionIndex': 0,
    #            u'TransactionResult': u'tesSUCCESS'},
    #  u'status': u'success',
    #  u'validated': True}
    # to send transaction you need to sign it first:
    sign_response = sign(
        'rNMW2mJHowD6d4KUvm23v3XkkDnatt5F1q', 'my_top_secret', 
            "currency" : currency,
            "value" : string,
            "issuer" : account_id,
    # Now you can submit it:
    submit_response = submit(sign_response['tx_blob'])
    if submit_response['engine_result'] in ["tesSUCCESS",  "tefPAST_SEQ"]:
        print('Congrats! Transaction is being processed by rippled! Check it later')
    # later you need to check this transaction:
    tx_info = tx(submit_response['tx_json']['hash'])
    if response.get('meta', {}).get('TransactionResult') == 'tesSUCCESS':
        print('You transaction was processed!')
  2. There is a model to save transaction information in DB:
    from ripple_api.models import Transaction
    amount = tx_info.get('Amount', {})
    destination_tag = tx_info.get('DestinationTag')
    source_tag = tx_info.get('SourceTag')
    transaction_object = Transaction.objects.create(
        account=tx_info['Account'], hash=tx_info['hash'],
        source_tag=source_tag, status=Transaction.RECEIVED,
        issuer=amount['issuer'], value=amount['value']
    If you have some transactions with status Transaction.SUBMITTED or Transaction.FAILED, than you can run manage command `process_transactions` that will try to resend failed transaction and check status of submited ones.
  3. There are also celery tasks to work with ripple_api.models.Transaction:
    1. ripple_api.tasks.sign_task(transaction, secret)
    2. ripple_api.tasks.submit_task(transaction)

    Example usage:
    sign_task.apply((transaction, settings.RIPPLE_SECRET), link=submit_task.s())

What's planned:
  • Support to work multiple API servers in case of connection errors.
  • Support to work without Django.
  • Class method for
    model to create instances from results of
  • ???