It's 2021 2022 2023 2024.

Magi needs an easy to use library and API, similar to what Duino-Coin offers.

Below you can find two ready to use ways of interacting with the XMG network with examples and comments.

If you need them, all the source codes are available on GitHub: Python lib and REST API.

Thank me later 😎

MAGI PYTHON LIBRARY (RPC)
Easy to use Python 3 library for interacting with the Magi network. Requires a locally hosted wallet!

Installation & basic usage

Because Magi lacks any new APIs or libraries, I've decided to finally create one myself for Python 3.
Firstly install python-bitcoinrpc and requests:
pip install python-bitcoinrpc requests
Then you can download the magilib.py library and place it in the same folder in which you want to create your Python script.

If you intend on using the library with your local Magi wallet, open your magi.conf file (.magi/magi.conf when using Linux) and enable the RPC server:
listen = 1
server = 1
rpcallowip = 127.0.0.1
rpcport = 8232
rpcuser = username
rpcpassword = password
To use the Python library, simply import it first:
import magilib
And create a magi instance (note: your Magi wallet must be running):
magi = magilib.rvxMagi("username", "password", ip="127.0.0.1:8232") # default IP
Summing up, a simple program that shows wallet stats will look like this:
import magilib
magi = magilib.rvxMagi("username", "password")
print(magi.statistics())

Getting a wallet (using the library)

You can easily create a wallet with the create_wallet function:
import magilib
magi = magilib.rvxMagi("username", "password")
print(magi.create_wallet()) # returns a tuple with wallet address and the autogenerated label
To name your wallet (give it a label), simply put your desired label as an argument:
print(magi.create_wallet("myCoolWallet")) # returns a tuple with wallet address and the label

Sending Magi (using the library)

Sending funds is also very easy - use the magi.send(from_address, to_address, amount) function to do so:
import magilib
magi = magilib.rvxMagi("username", "password")
print(magi.send("myCoolWallet", "95JLhkyWVDce5D17LyApULc5YC4vrVzaio", 0.5)) # returns the TXID
To add a memo (visible only locally!), pass it as an argument too:
print(magi.send("myCoolWallet", "95JLhkyWVDce5D17LyApULc5YC4vrVzaio", 0.5, "Kolka payment!!!"))
Don't want to subtract the transaction fee from the amount? No problem:
print(magi.send("myCoolWallet", "95JLhkyWVDce5D17LyApULc5YC4vrVzaio", 0.5, subtract_fee=False))
Want a custom transaction fee? There you go:
print(magi.send("myCoolWallet", "95JLhkyWVDce5D17LyApULc5YC4vrVzaio", amount=0.5, txfee=0.01))
For the from_address you can either use the wallet address or the wallet label - the library will automatically convert it.

Other functions

  • List all wallet accounts:
    magi.get_wallets()
    Example output:
    >>> print(magi.get_wallets())
    [
        {
            'flags': 'coins received',
            'address': '95JLhkyWVDce5D17LyApULc5YC4vrVzaio',
            'account': 'revox',
            'amount': Decimal('2893.28250294'),
            'confirmations': 1260
        }
    ]
  • Get label (name) of wallet address:
    magi.get_account_name(address)
    Example output:
    >>> print(magi.get_account_name("95JLhkyWVDce5D17LyApULc5YC4vrVzaio"))
    revox
  • Get address of wallet name (label):
    magi.get_account_address(address)
    Example output:
    >>> print(magi.get_account_address("revox"))
    95JLhkyWVDce5D17LyApULc5YC4vrVzaio
  • Get last transactions of wallet (label or address):
    magi.get_transactions(wallet, limit=10)
    Example output:
    >>> print(magi.get_transactions("revox", 2))
    [
        {
            'account': 'revox',
            'address': '95JLhkyWVDce5D17LyApULc5YC4vrVzaio',
            'category': 'receive',
            'amount': Decimal('50.75197137'),
            'confirmations': 99,
            'blockhash': '17160e51e06ef45098d826524b4e6157db3657531dd9870aa098db998d3508c3',
            'blockindex': 3,
            'blocktime': 1634581200,
            'txid': 'fa58f34b7ae81df04c1e43c6720509e3c1a915dab896037990a57f31671230bf',
            'time': 1634581143, 'timereceived': 1634581143
        },
        {
            'account': 'revox', 
            'address': '95JLhkyWVDce5D17LyApULc5YC4vrVzaio',
            'category': 'receive',
            'amount': Decimal('58.37396298'),
            'confirmations': 7,
            'blockhash': 'caf8e656d84d85dce07ef2c060cd44f63797bc863f215615372d8df09e284781',
            'blockindex': 2,
            'blocktime': 1634587424, 
            'txid': '55b23d724f36c427fc73b17aea15e166073265daf1b87272788c52b91796fb31', 
            'time': 1634587424,
            'timereceived': 1634587435
        }
    ]
  • Create a wallet account
    magi.create_wallet(label)
    Example output:
    >>> print(magi.create_wallet("myCoolUsername"))
    ('9R7TrBNPksW8AxJK5fxHYZzrk7bKEhFEPe', 'myCoolUsername')
  • Send Magi
    magi.send(sender_account, recipient_address, amount, memo="none", txfee=0.005, subtract_fee=True)
  • Get current Magi price
    magi.get_price()
    Example output:
    >>> print(magi.get_price())
    {
        'btcpop': 0.00245908, 
        'ducoexchange': 0.00059835,
        'moondex': 0,
        'max': 0.00245908
    }
  • Get network statistics
    magi.statistics()
    Example output:
    >>> print(magi.statistics())
    {
        'difficulty': {
            'pow': 1.45384564, 
            'pos': 0.00233533
        }, 
        'blocktx': 0, # transactions in mempool
        'blocks': 3239881,
        'reward': 20.84243837, # block reward
        'hashrate': 24918734.0, # network hashrate
        'price': {
            'btcpop': 0.00245908,
            'ducoexchange': 0.00059835, 
            'moondex': 0,
            'max': 0.00245908
        },
        'stake_interest': 0.03806139,
        'hours_to_stake': 4.0 # mPoS II
    }
  • Get balance of an account
    magi.get_balance(wallet)
    Example output:
    >>> print(magi.get_balance("revox"))
    2951.65646592
  • Get wallet sync status (WIP)
    magi.sync_status()
    Example output:
    >>> print(magi.sync_status())
    Wallet in sync (100% of 3239864 synced)
    (0, 3239864)
  • Get transaction by TXID (hash)
    magi.transaction_by_txid(txid)
    Example output:
    >>> print(magi.transaction_by_txid("fa58f34b7ae81df04c1e43c6720509e3c1a915dab896037990a57f31671230bf"))
    {
        'datetime': '2021-10-18 18:19:03',
        'recipient': 'revox (95JLhkyWVDce5D17LyApULc5YC4vrVzaio)',
        'amount': 50.75197137,
        'hash': 'fa58f34b7ae81df04c1e43c6720509e3c1a915dab896037990a57f31671230bf',
        'memo': 'none', 
        'fee': 'unknown',
        'sender': 'unknown',
        'confirmations': 110,
        'block': '17160e51e06ef45098d826524b4e6157db3657531dd9870aa098db998d3508c3',
        'currency': 'XMG'
    }
  • Check if wallet (label) already exists
    magi.wallet_exists(label)
    Example output:
    >>> print(magi.wallet_exists("revox"))
    True
  • Get basic account (label/wallet) data
    magi.account_data(label)
    Example output:
    >>> print(magi.account_data("revox"))
    {
        'username': 'revox',
        'address': '95JLhkyWVDce5D17LyApULc5YC4vrVzaio',
        'balance': 2951.65646592,
        'currency': 'XMG'
    }
MAGI ONLINE REST API
API calls you can use to integrate Magi into your app without the need of any hosting.

Usage

Usage of our API is really simple - just create a GET request to the desired endpoint. For example, to get the Magi network stats, just open the magi.duinocoin.com/statistics route:
{
  "result": {
    "blocks": 3252534,
    "blocktx": 0,
    "difficulty": {
      "pos": 0.00389869,
      "pow": 0.51841158
    },
    "hashrate": 8657484,
    "hours_to_stake": "unknown",
    "price": {
      "btcpop": 0.00243984,
      "ducoexchange": 0.00032753,
      "max": 0.00243984,
      "moondex": 0
    },
    "reward": 19.93486563,
    "stake_interest": 0.03930132,
    "total_balance": 50257.69530399,
    "users": 810
  },
  "success": true
}
Python example:
import requests
print(requests.get("https://magi.duinocoin.com/statistics").json())

Available endpoints

GET /statistics - info/stats related to the Magi network Example output:
{
  "result": {
    "blocks": 3252534,
    "blocktx": 0,
    "difficulty": {
      "pos": 0.00389869,
      "pow": 0.51841158
    },
    "hashrate": 8657484,
    "hours_to_stake": "unknown",
    "price": {
      "btcpop": 0.00243984,
      "ducoexchange": 0.00032753,
      "max": 0.00243984,
      "moondex": 0
    },
    "reward": 19.93486563,
    "stake_interest": 0.03930132,
    "total_balance": 50257.69530399,
    "users": 810
  },
  "success": true
}
GET /all_balances - return all users and their balances (above 0.0) registered on magi.duinocoin.com Example output:
{
  "result": {
    "revox": {
      "address": "95JLhkyWVDce5D17LyApULc5YC4vrVzaio",
      "balance": 34631.39634922,
      "currency": "XMG",
      "username": "revox"
    },
    "revox2": {
      "address": "9Nnp5tCuDQ6gFCPx1t8vzg3L31yDnhBNzQ",
      "balance": 0.0049,
      "currency": "XMG",
      "username": "revox2"
    }
  },
  "success": true
}
GET /transactions/TXID - info about a transaction by its TXID Example output:
{
  "result": {
    "amount": 2.995,
    "block": "01dc6a675f999cc3b55fdae4f874ecc251d929f644535445b742c14cfcf09f37",
    "confirmations": 43,
    "currency": "XMG",
    "datetime": "2021-10-29 10:14:02",
    "fee": 0.0002,
    "hash": "38712cabb97235257cfbf42b0e20b8533722d86d3f95809ac164c6a11de6a9f2",
    "memo": "none",
    "recipient": "revox (9GuFv2TgZn7gHWD3fR3YUN9J9fRVhHKpxx)",
    "sender": "unknown"
  },
  "success": true
}
GET /user_transactions/USERNAME - return last transactions of USERNAME Example output:
{
  "result": [
    {
      "amount": 2.995,
      "confirmations": 16216,
      "currency": "XMG",
      "datetime": "2021-10-15 21:12:04",
      "fee": 0.0001,
      "hash": "df48b95a8c03f747e691efa35103a681dcd94382fddd8fceb232861ca1a647cd",
      "memo": "None",
      "recipient": "9RTb3ikRrWExsF6fis85g7vKqU1tQYVFuR",
      "sender": "revox2"
    },
    {
      "amount": 0.995,
      "confirmations": 16138,
      "currency": "XMG",
      "datetime": "2021-10-15 22:44:56",
      "fee": 0.0001,
      "hash": "502d912e6b3720dd13a92906ed59bf9d0c57482a42119c3333f7c1c157e8ad23",
      "memo": "hmmm",
      "recipient": "revox3",
      "sender": "revox2"
    },
  ],
  "success": true
}
GET /users/USERNAME - return balance, magi price and last transactions of USERNAME Example output:
{
  "result": {
    "balance": {
      "address": "95JLhkyWVDce5D17LyApULc5YC4vrVzaio",
      "balance": 34631.39634922,
      "currency": "XMG",
      "username": "revox"
    },
    "price": {
      "btcpop": 0.00244636,
      "ducoexchange": 0.00032753,
      "max": 0.00244636,
      "moondex": 0
    },
    "transactions": [
      {
        "amount": 251.78871502,
        "confirmations": 1044,
        "currency": "XMG",
        "datetime": "2021-10-28 14:05:38",
        "fee": 0,
        "hash": "5558f12bc6b6d9743e994e42f5107db32491219d5e907b586fc7a4e3b713ba7a",
        "memo": "none",
        "recipient": "revox",
        "sender": null
      },
      {
        "amount": 81.995,
        "confirmations": 1025,
        "currency": "XMG",
        "datetime": "2021-10-28 14:41:08",
        "fee": 0.0001,
        "hash": "405c68a5c1c68c3b262a06a277f8da1ab5a3698fcceb8dfe133f48d74ece65eb",
        "memo": "DUCO Exchange payment",
        "recipient": "Raidz",
        "sender": "revox"
      }
    ]
  },
  "success": true
}
GET /balances/USERNAME - return balance of USERNAME Example output:
{
  "result": {
    "address": "9Nnp5tCuDQ6gFCPx1t8vzg3L31yDnhBNzQ",
    "balance": 0.0049,
    "currency": "XMG",
    "username": "revox2"
  },
  "success": true
}
GET /transaction/TX_DATA - create a transaction with TX_DATA TX_DATA is a set of URL arguments containing:
  • username - senders username
  • password - senders password
  • recipient - recipients username/address
  • amount - amount to be transferred
  • memo - (optional) transaction comment
Example output:
{
  "result": "OK,Successfully transferred funds,df48b95a8c03f747e691efa35103a681dcd94382fddd8fceb232861ca1a647cd",
  "success": true
}