Litecoin API

Accept and send Litecoin payments seamlessly

Litecoin API Key

You have to obtain API keys for each coin seperately. It is INSTANT and FREE. You can provide your email address during API key creation, though it is optional. If we have your email address, we can contact you before disabling your API key for any reason.

Get Receiving Address

You provide an extended public key (xpub) and we generate a unique, unused address for your customers to send payment to. If you receive any payment to that address, we will notify you instantly using the callback URL you provided.

Where can I get extended public key (xpub)?

Now a days, most of the wallets provide BIP32 extended public keys. For blockchain.com users, go to Settings -> Addresses -> Manage -> More Options -> Show xPub. Please use a new account xpub with our API and do not use it outside to receive payment.

What is gap limit and how to handle it?

You can generate millions of addresses from an xpub. But it is not feasible to monitor or scan that many addresses to know the balance of the xpub. BIP44 wallets scan 20 unused addresses from last used address. It is called gap limit. Our API will return an error and refuse to generate new address if it reaches this gap limit. You can follow 2 strategies to handle gap limit:

  1. Switch to a new xpub if you encounter this error. You can create a pool of pre-generated xpubs and use them one after another. In the meantime, if you receive payment to an unused address of a 'gap limit exceeded' xpub, it can be reused.
  2. Use a higher gap limit. Use our Get Xpub Info API endpoint to see the gap addresses. When you want to spend received coins, send minimum amount to these gap addresses (fill gap). This will make the whole balance visible in your own wallet. If you are an expert cryptocurrency developer, you can spend these coins without filling gaps.
Request: GET
https://ltc.zerodifficulty.com/api/receive?xpub=YOUR_XPUB&callbackurl=URL_ENCODED_CALLBACK_URL&apikey=YOUR_APIKEY&gaplimit=20&orderid=ORDER_ID
  • xpub: (Required) Your extended public key, from which we will generate receiving address.
  • callbackurl: (Required) URL-encoded callback URL. Your original unencoded URL should be of maximum 255 characters. You can use a secret parameter (&secret=YOUR_SECRET) with the callback URL, so that you can verify the authenticity of the callback while processing it.
  • apikey: (Required) Your Litecoin API key.
  • gaplimit: (Optional) (Default: 20) How many unused addresses are allowed (from last used address index) before erroring out.
  • orderid: (Optional) A unique ID to generate the address for. If we find an unused address with same orderid, we return it updating its callback URL only. Otherwise, we return a new address. If you do not provide orderid, a new address is returned always. You can use username as orderid if you wish to generate unique address for each user. Or use your actual product order ID to generate unique address for each order.
Response: 200 OK, application/json
{
    "address": "LKiXQFfYWDS6o9E9qXgSDZBnnNXfndJ5pN",
    "index": 4,
    "error": null
}
  • address: Address to receive payment.
  • index: Index of the address on receiving chain of xpub (0/{index}).
  • error: Error text if any error occurs. Otherwise, null.

Process Callback

The following key-value pairs are sent to your callback URL using POST method (application/x-www-form-urlencoded).

  • txid: Transaction hash of the payment.
  • amount: Amount in LTC.
  • address: Receiving address.
  • confirmations: Number of confirmations of this transaction.
  • orderid: The orderid you provided while creating this address.

We send callbacks for up to 20 confirmations. If you are done with processing this transaction and do not want to receive this callback any more, reply with "*ok*" text (without quote) as a response to the callback.

Create Hot Wallet

To send payment or pay bill, you have to create a hot wallet first. Hot wallet is just an extended key. From the public part (xpub) of this key, we can generate as many funding addresses and change addresses as needed. Use our Get Xpub Info API endpoint to get the funding address, balance and other details of your hot wallet.

Request: GET
https://ltc.zerodifficulty.com/api/createwallet?apikey=YOUR_APIKEY
  • apikey: (Required) Your Litecoin API key.
Response: 200 OK, application/json
{
    "xpub": "xpub661MyMwAqRbcGiDFM1kpGqbmmgYjP5i5RicTQRzpQQDfFC6TPmJpgKjrbspeCxguYrZfPB2surtGK2EKZ37XkSGJv5nfTB7o4vTMhJKDnHU",
    "xprv": "xprv9s21ZrQH143K4E8nEzDouhf3DeiEyczE4Vgrc3bCr4ggNPmJrDza8XRNkbVjs9eu95XFtz1He2ghG84yWRQZ7u9uZn7Cift1UMGCzDWGmPE",
    "password": "4ccbe482-27c9-4c7f-94c4-6ae43a91853b",
    "error": null
}
  • xpub: Extended public key of your hot wallet. It is your wallet identifier.
  • xprv: Extended private key of your hot wallet in plain text. Keep it in a safe place. If our service is unavailable for any reason, you can use it to retrieve your fund.
  • password: A randomly generated password. Your private key is encrypted with this password and stored in our database. We do not store your password. Thus enhancing the security of your fund even if our system gets compromised.
  • error: Error text if any error occurs. Otherwise, null.

Send

To send payment, you have to create a hot wallet before and have it funded. You can pay to multiple recipients. We will create change address (1/{index}) from your xpub automatically if necessary.

Request: GET
https://ltc.zerodifficulty.com/api/send?xpub=HOT_WALLET_XPUB&password=HOT_WALLET_PASSWORD&to=ADDR1-AMOUNT1|ADDR2-AMOUNT2&apikey=YOUR_APIKEY&feetarget=6
  • xpub: (Required) Extended public key of your hot wallet.
  • password: (Required) Password of your hot wallet.
  • to: (Required) Recipients. Format: address1-amount1|address2-amount2|... Example: LKiXQFfYWDS6o9E9qXgSDZBnnNXfndJ5pN-0.005|Lh6p1J4eewTzs6wnQj5E6CZ8TvhTW16VDm-0.0001
  • apikey: (Required) Your Litecoin API key.
  • feetarget: (Optional) (Default: 6) How many blocks you want to include this transaction within. You can set it from 1 to 10.
Response: 200 OK, application/json
{
    "txId": "80801bbe5a8268d9393e89cff2c57a7d9d26bb6ea89eaf8e33196c25f503255a",
    "error": null
}
  • txId: Transaction hash of this payment.
  • error: Error text if any error occurs. Otherwise, null.

Fee

Our fee is 0.2% on both receive and send. It is not only the cheapest on market, but also many times lower than others.

Pay Bill

You have to pay bill using a hot wallet, at least once in a week. You can pay it manually or set up a cron/scheduled job of maximum 7 days interval. If your due bill is less than 0.0001 LTC we do not deduct any amount. If you do not pay bill regularly, your API key might be disabled. We will send email before disabling your API key if you provided your email address during API key creation.

Request: GET
https://ltc.zerodifficulty.com/api/paybill?xpub=HOT_WALLET_XPUB&password=HOT_WALLET_PASSWORD&apikey=YOUR_APIKEY
  • xpub: (Required) Extended public key of your hot wallet.
  • password: (Required) Password of your hot wallet.
  • apikey: (Required) Your Litecoin API key.

Fee target for bill transactions is 6.

Response: 200 OK, application/json
{
    "txId": "80801bbe5a8268d9393e89cff2c57a7d9d26bb6ea89eaf8e33196c25f503255a",
    "error": null
}
  • txId: Transaction hash of this payment.
  • error: Error text if any error occurs. Otherwise, null.

Get API Key Info

Request: GET
https://ltc.zerodifficulty.com/api/apikeyinfo?apikey=YOUR_APIKEY
  • apikey: (Required) Your Litecoin API key.
Response: 200 OK, application/json
{
    "dueBill": 0.00033032,
    "error": null
}
  • dueBill: Total due bill.
  • error: Error text if any error occurs. Otherwise, null.

Get Xpub Info

Request: GET
https://ltc.zerodifficulty.com/api/xpubinfo?xpub=YOUR_XPUB&apikey=YOUR_APIKEY&details=false&html=false&gaplimit=20
  • xpub: (Required) Any extended public key present in our system.
  • apikey: (Required) Your Litecoin API key.
  • details: (Optional) (Default: false) If true, shows the information of child addresses also.
  • html: (Optional) (Default: false) If details = true and html = true, You will get a visual representation of your xpub showing gap addresses. You can fill gaps by sending minimum amount to these addresses, so that your wallet app shows the actual balance.
  • gaplimit: (Optional) (Default: 20) Your desired gap limit to mark gap addresses.
Response: 200 OK, application/json
{
    "balance": 0.0,
    "fundingAddress": "Lh6p1J4eewTzs6wnQj5E6CZ8TvhTW16VDm",
    "addresses": [
        {
        "change": false,
        "index": 0,
        "address": "Lh6p1J4eewTzs6wnQj5E6CZ8TvhTW16VDm",
        "balance": 0.0,
        "used": false,
        "gap": false
        }
    ],
    "error": null
}
  • balance: Total balance of this xpub.
  • fundingAddress: (Only for hot wallets) Address to load fund. You will get a new funding address if previous one is used.
  • addresses: (When details = true) Child addresses.
    • change: Whether it is in receiving chain (0/{index}) or change chain (1/{index}).
    • index: Index on chain.
    • address: Child address.
    • balance: Balance of child address.
    • used: Whether it has received any coin so far.
    • gap: Whether it can be considered as a gap address (to fill) based on your gaplimit.
  • error: Error text if any error occurs. Otherwise, null.

WebSocket API

You can use our websocket API to monitor any address for new payment. You can use it to notify your user on browser while checking out.

wss://ltc.zerodifficulty.com/ws?address=YOUR_ADDRESS
  • address: (Required) The address you want to monitor.

You will receive following JSON text if any new payment is made to that address.

{ 
    "obType": "tx", 
    "ob": { 
        "txId": "bf6bdec4ef4c0ae94af1edb8b277462b6fb0c2b23c742f6861a753a5c53bebcc", 
        "address": "LKiXQFfYWDS6o9E9qXgSDZBnnNXfndJ5pN", 
        "amount": 0.0068 
    } 
}

You can send "ping" text (without quote) to test whether the websocket connection established successfully. You will receive the following JSON text.

{ 
    "obType": "pong", 
    "ob": null 
}

You can use this tool to test our websocket API. Send "ping" every 30 seconds to keep the connection alive.