/ALFAcoins-js-api

A JavaScript implementation of the ALFAcoins API

Primary LanguageHTML

ALFAcoins-js-api

A JavaScript implementation of the ALFAcoins API

This library provides a JavaScript implementation of the https://www.alfacoins.com/ API - A Bitcoin & cryptocurrency payment processing system.

Use this API to accept and send Bitcoin, Litecoin, Ethereum, Bitcoin Cash, Dash and XRP cryptocurrency payments/refunds.

Core ALFAcoins API: https://www.alfacoins.com/developers

Security Note

Although the GET based API calls can be made from anywhere, when making POST based API calls using your secret_key/password you will want to avoid serving these 2 values up to a public website as a malicious user could scrape the credentials and make calls without your consent. Only make these calls from a private/protected environment.

Setup

Include the single script file into your page:

<script src="ALFAcoins.js"></script>

Available Properties/Methods

Properties

ALFAcoins.version
//returns the version of this library as a string e.g. "1.0"
    
ALFAcoins.COIN_TYPES
//A convienience mapping of the major coin type abreviations
/*
  BITCOIN:"BTC",
  LITECOIN:"LTC",
  ETHEREUM:"ETH",
  BITCOINCASH:"BHC",
  DASH:"DASH",
  XRP:"XRP",
  LITECOINTESTNET:"LTCT"
*/

GET Methods

ALFAcoins.getFees()
//returns a JSON map of coin types, each with a map of deposit, withdrawal, and bitsend comissions/fees:

Example (truncated) JSON return

{
  "bitcoin": {
    "deposit": {
      "commission": "0.99%",
      "network_fee": "0 BTC"
    },
    "withdrawal": {
      "commission": "0%",
      "network_fee": "0.00005 BTC"
    },
    "bitsend": {
      "commission": "0.99%",
      "network_fee": "0.00005 BTC"
    }
  },
  "litecoin": {...},
  "ethereum": {...},
  "bitcoincash": {...},
  "dash": {...},
  "xrp": {...},
  "litecointestnet": {...}
}
ALFAcoins.getRate(currencyA, currencyB)
//e.g. ALFAcoins.getRate("BTC", "USD")
//returns a JSON array with a single value for the requested rate

Example JSON return

[
  "3927.60000000"
]
ALFAcoins.getRates()
//returns a JSON array of all coin types and all currency rates for each type

Example (truncated) JSON return (selective currencies listed, actual list of currencies is extensive)

{
  "BTC": [
    {
      "code": "AUD",
      "rate": 5526.335314
    },
    {
      "code": "CAD",
      "rate": 5316.65607
    },
    {
      "code": "EUR",
      "rate": 3411.712203
    },
    {
      "code": "GBP",
      "rate": 3075.586959
    },
    {
      "code": "USD",
      "rate": 3902.53389
    }
  ],
  "LTC": [...],
  "ETH": [...],
  "BCH": [...],
  ...
  ]
}

POST Methods

For convienience all of the post methods accept a standard customizable configuration object matching the core ALFAcoins API docs: https://www.alfacoins.com/developers

ALFAcoins.postBitSend(config)
//send cryptocurrency to a specific address: https://www.alfacoins.com/developers#post_requests-bitsend

ALFAcoins.postBitSendStatus(config)
//check the status of a bitSend request: https://www.alfacoins.com/developers#post_requests-bitsend_status

ALFAcoins.postCreateOrder(config)
//create an order for payment: https://www.alfacoins.com/developers#post_requests-create

ALFAcoins.postOrderStatus(config)
//get status of created order: https://www.alfacoins.com/developers#post_requests-status

ALFAcoins.postStatistics(config)
//get merchants balance and send statistics: https://www.alfacoins.com/developers#post_requests-stats

ALFACoins.postRefund(config)
//refund a completed order: https://www.alfacoins.com/developers#post_requests-refund