API Documentation

API Endpoint

All API calls are implemented as HTTP Post. Requests must be made to our API endpoint located at https://numivcoin.com/api/[METHOD]

API Setup

To utilize our API, all you have to do is obtain API Key and API Secret from your account. API Key and API Secret are used to authenticate your requests to our database.

PHP Library

We have created a small, useful library to communicate with our API. You can download our PHP library at https://numivcoin.com/page/api-documentation/code

API Functions

Our API consists of 4 methods which will enable you to accept cryptocurrency payments. We are going to list some basic information and code related to each method below.

  • Get Coin Balance
    <?php
      
    include_once("BasiliskClient.php");
    
    define("API_KEY", "YOUR_API_KEY");
    define("API_SECRET", "YOUR_API_SECRET");
    
    $api_client = new BasiliskClient(API_KEY, API_SECRET);
    $api_client->setCoin("BTC");
    $api_client->setMethod("get-balance");
    $response = $api_client->process();
    
    if($response["response_code"] != 200) {
    
    exit($response["response_message"]);
    
    } else {
    
    $balance = $response["balance"];
    
    }
    
    ?>
  • Generate Coin Address
    <?php
      
    include_once("BasiliskClient.php");
    
    define("API_KEY", "YOUR_API_KEY");
    define("API_SECRET", "YOUR_API_SECRET");
    $callback_url = "https://site.com/IPN.php?user=2450";
    
    $api_client = new BasiliskClient(API_KEY, API_SECRET);
    $api_client->setCoin("BTC");
    $api_client->setField("callback_url", $callback_url);
    $api_client->setMethod("generate-address");
    $response = $api_client->process();
    
    if($response["response_code"] != 200) {
    
    exit($response["response_message"]);
    
    } else {
    
    $address = $response["address"];
    $qr_code_url = $response["qr_code"];
    
    }
    
    ?>
  • Generate Hosted Page
    <?php
      
    include_once("BasiliskClient.php");
    
    define("API_KEY", "YOUR_API_KEY");
    define("API_SECRET", "YOUR_API_SECRET");
    $callback_url = "https://site.com/IPN.php?user=2450";
    $amount = 10.68;
    
    $api_client = new BasiliskClient(API_KEY, API_SECRET);
    $api_client->setCoin("USD");
    $api_client->setField("amount", $amount);
    $api_client->setField("callback_url", $callback_url);
    $api_client->setMethod("generate-hosted-page");
    $response = $api_client->process();
    
    if($response["response_code"] != 200) {
    
    exit($response["response_message"]);
    
    } else {
    
    $hosted_page_id = $response["hosted_page_id"];
    $hosted_page_url = $response["hosted_page_url"];
    
    header("Location: " . $hosted_page_url);
    
    }
    
    ?>
    *Currency conversions are done at our system. So, you can set anything as coin and the buyer will have to pay the equivalent of that amount in their preferred currency.
    **Coin, in this case, can also be set to USD.
  • Send Payment
    <?php
      
    include_once("BasiliskClient.php");
    
    define("API_KEY", "YOUR_API_KEY");
    define("API_SECRET", "YOUR_API_SECRET");
    $address = "1tkh8ENwHr8Uoo6PWFM31T5ub2cQiFGbm";
    $amount = 0.54;
    
    $api_client = new BasiliskClient(API_KEY, API_SECRET);
    $api_client->setCoin("BTC");
    $api_client->setField("recipient", $address);
    $api_client->setField("amount", $amount);
    $api_client->setMethod("send-payment");
    $response = $api_client->process();
    
    if($response["response_code"] != 200) {
    
    exit($response["response_message"]);
    
    } else {
    
    $transaction_id = $response["transaction_id"];
    
    }
    
    ?>

Handling Callback Response

Once someone sends you a payment, we will send you a callback notification to inform you about that. Callback notifications are sent many times until the transaction is fully confirmed. Handling callback notifications (also called IPN) is pretty easy and can be understood by analyzing the code below.

<?php
  
include_once("BasiliskClient.php");

define("API_KEY", "YOUR_API_KEY");
define("API_SECRET", "YOUR_API_SECRET");

$transaction_id = $_POST["transaction_id"];
$address = $_POST["address"];
$amount = $_POST["amount"];
$confirmations = $_POST["confirmations"];
$hash = $_POST["hash"];
$auth_hmac = $_POST["auth_hmac"]; 

$api_client = new BasiliskClient(API_KEY, API_SECRET);
$valid = $api_client->validatePayment($hash, $auth_hmac);

if($valid == true) {

// Process the payment.

} else {

exit("Could not verify the payment.");
// Log for manual verification

}

?>

Response Codes

Response codes allow you to have a better understanding of the working of our system. Response codes carry a unique message which can help you debug your application.

  • 200 - Success, check other parameters
  • 401 - Invalid API details
  • 403 - Your account has been suspended or you do not have permissions to access API
  • 404 - Wrong coin abbreviation used
  • 19 - Invalid callback or success URL used
  • 17 - You have been rate-limited, try again later
  • 21 - Amount too small
  • 500 - Unknown internal error
  • PRIVACY POLICY