NAV Navbar
php

Introduction

Kepler Lab provides a simple and powerful REST API to integrate ethereum and ERC20 payments into your business and application. This API reference provides information on available endpoints and how to interact with it. With our API, you can transfer crypto currency, create wallet for users and even mint your own ERC20 token.

API endpoint 
https://api.keplerlab.io/v1/

Authentication

To authorize, use the following code with your API_KEY:

$headers = array(
    'Content-Type:application/json',
    'Authorization: Basic '. base64_encode("YOUR_API_KEY")
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
# With shell, you can just pass the correct header with each request
curl "api_endpoint_here"
  -H "Authorization: Basic [encoded YOUR_API_KEY]"

Make sure to replace YOUR_API_KEY with your API key.

Kepler Lab expects for the API key to be included in all API requests to the server via HTTP Basic Auth. SImply include the Base64 encoded API key to the Authorization header as follow:

Address and inbound

Generate new addresses for your users


The above command returns JSON structured like this:

  {
    "status": 200,
    "ticker": "ETH",
    "address": "0x0c5cf69c09a9c3c39a8bf3c733f9f64666c29dae"
  }

This endpoint generates a new address.

HTTP Request

GET blockchain/:ticker/newaddress

URL Parameters

Parameter Optional Description
:ticker false BTC, ETH, or any supported token ticker

Get the accumulated deposit of an address


The above command returns JSON structured like this:

  {
    "status": 200,
    "amount": 7.500000000000000000,
    "address": "0x0c5cf69c09a9c3c39a8bf3c733f9f64666c29dae",
    "ticker": "ETH"
  }

This endpoint retrieves the accumulated deposit of an address.

HTTP Request

GET /blockchain/inbound/:ticker/:address

URL Parameters

Parameter Optional Description
:ticker false BTC, ETH, or any supported token ticker
:address false address generated by us

Get the total deposit of a token


The above command returns JSON structured like this:

  {
    "status": 200,
    "amount": 7.500000000000000000,
    "ticker": "ETH"
  }

This endpoint returns the accumulated deposit of a token of your application

HTTP Request

GET blockchain/inbound/:ticker

URL Parameters

Parameter Optional Description
:ticker false BTC, ETH, or any supported token ticker

Get the total withdrawal of a token


The above command returns JSON structured like this:

  {
    "status": 200,
    "amount": 7.500000000000000000,
    "ticker": "ETH"
  }

This endpoint returns the accumulated withdrawal of a token of your application

HTTP Request

GET blockchain/outbound/:ticker

URL Parameters

Parameter Optional Description
:ticker false BTC, ETH, or any supported token ticker

Tokens

Minting coins (only available to enterprise account)

{

}

The above command returns JSON structured like this:

{

}

This endpoint creates customised token.

HTTP Request

POST blockchain/newtoken

Query Parameters

Parameter Optional Type Description
ticker false string BTC, ETH, or any supported token ticker

Sending coins (only available to enterprise account)

{
  "timestamp" : 1632895471284,
  "ticker" : "ETH", 
  "address" : "0x0c5cf69c09a9c3c39a8bf3c733f9f64666c29dae", 
  "amount" : 7.500000000000000000, 
  "secret" : "04b0cea231195d0532d4c5173f1b32f2"
}

The above command returns JSON structured like this:

{
  "tx_hash" : "0xdc5907496ef5896e2f1f1ab635172eb3fd4b6be623ecf4a6d300df560ab69378",
  "timestamp" : 1632895471284, 
  "ticker" : "ETH", 
  "address" : "0x0c5cf69c09a9c3c39a8bf3c733f9f64666c29dae", 
  "amount" : 7.500000000000000000, 
  "status" :  200
}

This endpoint sends token to the designated address.

HTTP Request

POST blockchain/:ticker/newwithdrawal

URL Parameters

Parameter Optional Description
:ticker false BTC, ETH, or any supported token ticker

Query Parameters

Parameter Optional Type Description
timestamp false long unix timestamp in millisecond
ticker false string BTC, ETH, or any supported token ticker
address false string designated address
amount false float a number with 18 decimal places
secret false string by calling getSecret("YOUR_API_KEY") in Kepler Lab library

Depositing coins (only available to enterprise account)


Kepler Lab server will call your callback URL with the following payload:

{
  "tx_hash" : "0xdc5907496ef5896e2f1f1ab635172eb3fd4b6be623ecf4a6d300df560ab69378",
  "timestamp" : 1632895471284, 
  "ticker" : "ETH", 
  "address" : "0x0c5cf69c09a9c3c39a8bf3c733f9f64666c29dae", 
  "amount" : 7.500000000000000000, 
  "secret" : "04b0cea231195d0532d4c5173f1b32f2"
}

The above command returns:

{
  "status" : 200
}

Coin deposit works with a callback URL provided application, after an address generated by us received token, we will call your callback URL with the following payload. You can also use the topup.php provided by us directly.

HTTP Request

POST YOUR_CALLBACK_URL

Payload Parameters

Parameter Optional Type Description
tx_hash false string transaction hash from blockchain
timestamp false long unix timestamp in millisecond
ticker false string BTC, ETH, or any supported token ticker
address false string address that receive deposit
amount false float a number with 18 decimal places
secret false string check by calling checkSecret("YOUR_API_KEY") in Kepler Lab library

Log

Getting error logs (only available to enterprise account)

{

}

The above command returns JSON structured like this:

{
   "status": 200,
   "logs":[
      {
         "id": 1,
         "error": "Server Response ERR",
         "description": "Cannot call to server; https://.",
         "message":{
            "tx_hash": "0xdc5907496ef5896e2f1f1ab635172eb3fd4b6be623ecf4a6d300df560ab69378",
            "address": "0x4cd222cea6b16050a62ee4bc0445bfc2ef590891",
            "ticker": "SPN",
            "timestamp": 1551669844742,
            "amount": 5.000000000000000000,
            "secret": "04b0cea231195d0532d4c5173f1b32f2"
         },
         "timestamp": 1632895471284
      },
      {
         "id": 2,
         "error": "Server Response ERR",
         "description": "Cannot call to server; https://.",
         "message":{
            "tx_hash": "0x39bb5dace6872db7b8e1cd8f8f3078408ce6919b787f9c0e3c5c65524e3b0499",
            "address": "0xce7cb0d00cae34d6db96e60d4f0f3a5c12f39bb0",
            "ticker": "SPN",
            "timestamp": 1551679651187,
            "amount": 3.000000000000000000,
            "secret": "5450a005bd7d7ebe7936252e7430a806"
         },
         "timestamp": 1632895471284
      }
   ]
}

This endpoint creates customised token.

HTTP Request

GET blockchain/:ticker/log/err/:starting_timestamp/:ending_timestamp

URL Parameters

Parameter Optional Description
:ticker false BTC, ETH, or any supported token ticker
:starting_timestamp false unix timestamp in millisecond e.g. 1532895471284
:ending_timestamp false unix timestamp in millisecond e.g. 1632895471284

Address management

Errors

The Kepler Lab API uses the following error codes:

Error Code Meaning
400 Bad Request -- Your request is invalid.
401 Unauthorized -- Your API key is wrong.
404 Not Found -- The specified kitten could not be found.
405 Method Not Allowed -- You tried to access the api with an invalid method.
418 Insufficient Fund -- You don't have sufficient fund to make the token transfer transfer.
429 Too Many Requests -- You're are making too many requests.
500 Internal Server Error -- We had a problem with our server. Try again later.
503 Service Unavailable -- We're temporarily offline for maintenance. Please try again later.
php