NAV Navbar
cURL PHP Scala Java

Introduction

There are two endpoints, one for testing and one for production.

TEST https://sandbox.litego.io:9000/api/v1

LIVE https://api.litego.io:9000/api/v1
TEST https://sandbox.litego.io:9000/api/v1

LIVE https://api.litego.io:9000/api/v1
TEST https://sandbox.litego.io:9000/api/v1

LIVE https://api.litego.io:9000/api/v1
TEST https://sandbox.litego.io:9000/api/v1

LIVE https://api.litego.io:9000/api/v1

Welcome to LiteGo API! We have implemented our API with REST. Our API supports HTTP verbs, BASIC Auth and cross-origin resources sharing.

All response objects are delivered as JSON objects

Errors

Response examples:

{
    "name": "Forbidden",
    "detail": "Authentication failed."
}

When invalid referrer id

{
    "name": "NotFound",
    "detail": "Referrer not found."
}

When incorrect request parameter or field in BTC wallet

{
    "name": "BTCWalletError",
    "detail": "Unacceptable request, due to missing or incorrect parameters."
}

When insufficient balance in EOS wallet

{
    "name": "EOSWalletError",
    "detail": "Insufficient balance."
}

LiteGo API uses standard HTTP response codes. The status code is provided in the response header. Response contains an object with additional information about the error.

HTTP codes description

Code Description
200 Request has succeeded.
400 Invalid request. Check your json syntax.
403 Authentication failed, maybe invalid or expired token.
404 The resource does not exist.
406 Request is valid, but contains unacceptable parameters.
500 An internal API error.

Error response

An object that contains error information

Field Description
name Type of error
detail Detail description of error

Authentication

To authorize, use this code:

# With shell, you can just pass the correct header with each request
curl -X POST 'https://api.litego.io:9000/api/v1/merchant/authenticate' \
 -H "Content-Type: application/json" \
 --data "{\"merchant_id\":\"some_merchant_key\",\"secret_key\":\"333555666oqc8ocm8fom59amcg\"}"
<?php
try {
    $ch = curl_init();

    $httpHeaders = array(
     'Content-Type: application/json',
    );

    $data = array(
    'merchant_id' => 'some_merchant_key',
    'secret_key' => '333555666oqc8ocm8fom59amcg'
    );

    curl_setopt($ch, CURLOPT_URL, 'https://api.litego.io:9000/api/v1/merchant/authenticate');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

    $response = curl_exec($ch);

    $responseCode           = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $responseHeaderSize     = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $responseContent        = substr($response, $responseHeaderSize);

    $result = json_decode($responseContent);

    curl_close($ch);

} catch(Exception $e) {
    echo $e->getCode() . ": " . $e->getMessage();
}

?>
import java.util.UUID

import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import akka.http.scaladsl.marshalling.Marshal
import akka.http.scaladsl.model._
import akka.stream.ActorMaterializer
import spray.json.{DefaultJsonProtocol, DeserializationException, JsString, JsValue, JsonFormat, RootJsonFormat}

import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.util.{Failure, Success}

final case class AuthenticateRequest(merchant_id: Option[UUID] = None, secret_key: String = "")

trait AuthenticateProtocol extends DefaultJsonProtocol {
  implicit object UUIDFormat extends JsonFormat[UUID] {
    def write(uuid: UUID) = JsString(uuid.toString)
    def read(value: JsValue): UUID = {
      value match {
        case JsString(uuid) => UUID.fromString(uuid)
        case _              => throw DeserializationException("Expected hexadecimal UUID string")
      }
    }
  }
  implicit val authenticateFormat: RootJsonFormat[AuthenticateRequest] = jsonFormat2(AuthenticateRequest)
}

object Main extends App with AuthenticateProtocol with SprayJsonSupport {
  implicit val system: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  val http = Http(system)

  def post(request: AuthenticateRequest): Future[HttpResponse] =
    Marshal(request).to[RequestEntity] flatMap { entity =>
      val request = HttpRequest(method = HttpMethods.POST, uri = "https://api.litego.io:9000/api/v1/merchant/authenticate", entity = entity)
      http.singleRequest(request)
    }

  val request = AuthenticateRequest(Some(UUID.fromString("YOUR_MERCHANT_ID")), "YOUR_SECRET_KEY")

  post(request) onComplete {
    case Failure(ex) => System.out.println(s"Failed to post $request, reason: $ex")
    case Success(response) => System.out.println(s"Server responded with $response")
  }
}
import okhttp3.*;
import java.io.IOException;

public class Example {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "{\n\t\"merchant_id\":\"YOUR_MERCHANT_ID\",\n\t\"secret_key\":\"YOUR_SECRETKEY\"\n}");
        Request request = new Request.Builder()
                .url("https://api.litego.io:9000/api/v1/merchant/authenticate")
                .post(body)
                .build();
        Response response = client.newCall(request).execute();
    }
}

Example of the response for authorization:

[
  {
    "id": "8b6703c4-0ffb-4093-a785-ef438f08c1c7", 
    "auth_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
    eyJleHAiOjE1MzI2MTU2MDcsImlhdCI6MTUzMjYxNTMwNywibWVy
    Y2hhbnRJZCI6IjhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4Z
    jA4YzFjNyIsImlzUmVmcmVzaFRva2VuIjpmYWxzZX0.5-yhpiyntqD
    CP2IG6acf6cab5E-pA2CBajS5ZKrxGt3b4h1f7o9GSW60aaQaQxNTH
    MXp0gWqqj-6fN4X9t7Cww", 
    "refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
    eyJleHAiOjE1MzI3MDE3MDcsImlhdCI6MTUzMjYxNTMwNywibWVyY2
    hhbnRJZCI6IjhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4
    YzFjNyIsImlzUmVmcmVzaFRva2VuIjp0cnVlfQ.JBXiKCcV4_biWQu
    9OoaOPnQhdnMDinbz0p-cuVbaUuqPgvKkl470LxTv9mDntjMHyoR9B
    JI9VFc0JsrzT3cY5A"
  }
]

Make sure to replace 333555666oqc8ocm8fom59amcg with your secret API key and some_merchant_key with Merchant API ID.

Calls to the API are authenticated with secret API Key and merchant API ID, which you can find in your account settings in tab API KEY.

Keep the API key private.

All authenticated calls to this API must be done from a secured and trusted environment (e.g. your backend server) and not from the public front end.

In success we expect 2 JWT keys auth_token and refresh_token:

POST /merchant/authenticate
Attributes
merchant_id String Merchant ID
secret_key String Merchant secret key
Response
id Merchant ID
auth_token Authorization token
refresh_token Refresh token

Refresh Auth token

You can refresh auth_token with refresh_token.

To refresh auth_token use this code:

curl -X PUT 'https://api.litego.io:9000/api/v1/merchant/me/refresh-auth' \
 -H "Content-Type: application/json" \
 -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
 eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
 jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
 va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
 maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA"
<?php
try {
    $ch = curl_init();

    $httpHeaders = array(
     'Content-Type: application/json',
     'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
       eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
       jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
       va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
       maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA'
    );

    curl_setopt($ch, CURLOPT_URL, 'https://api.litego.io:9000/api/v1/merchant/me/refresh-auth');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');

    $response = curl_exec($ch);

    $responseCode           = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $responseHeaderSize     = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $responseContent        = substr($response, $responseHeaderSize);

    $result = json_decode($responseContent);

    curl_close($ch);

} catch(Exception $e) {
    echo $e->getCode() . ": " . $e->getMessage();
}
?>
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.stream.ActorMaterializer

import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.util.{Failure, Success}

object Main extends App {
  implicit val system: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  val http = Http(system)

  val request = HttpRequest(method = HttpMethods.PUT, uri = "https://api.litego.io:9000/api/v1/merchant/me/refresh-auth")
    .withHeaders(Authorization(OAuth2BearerToken("YOUR_REFRESH_TOKEN")))

  http.singleRequest(request).onComplete {
    case Failure(ex) => System.out.println(s"Failed to put. Reason: $ex")
    case Success(response) => System.out.println(s"Server responded with $response")
  }
}
import okhttp3.*;
import java.io.IOException;
public class Example {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "");
        Request request = new Request.Builder()
                .url("https://api.litego.io:9000/api/v1/merchant/me/refresh-auth")
                .put(body)
                .header("Authorization", "YOUR_REFRESH_TOKEN")
                .build();
        Response response = client.newCall(request).execute();
    }
}

You must insert your refresh_token into Authorization request header.

Example of the response for refreshed auth_token:

{
    "auth_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE1MzI2MTU
    5NjYsImlhdCI6MTUzMjYxNTY2NiwibWVyY2hhbnRJZCI6IjhiNjcwM2M0LTBmZmItNDA5M
    y1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFRva2VuIjpmYWxzZX0.3vEt5AZgMrC9
    gua7m3FngL09jKiKlq6sPRToaI__EuVrP7UVqOeJkcsBylaSegGe4KvaZObzkY-IO1mfxiOUuQ"
}

When auth_token lifetime is over, all other API requests return authorization error

PUT /merchant/me/refresh-auth
Response
auth_token New authorization token

Get information about authenticated merchant

curl 'https://api.litego.io:9000/api/v1/merchant/me' \
   -H "Content-Type: application/json" \
   -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
   eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
   jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
   va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
   maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA"
<?php
try {
    $ch = curl_init();

    $httpHeaders = array(
     'Content-Type: application/json',
     'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
       eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
       jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
       va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
       maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA'
    );

    curl_setopt($ch, CURLOPT_URL, 'https://api.litego.io:9000/api/v1/merchant/me');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);

    $response = curl_exec($ch);

    $responseCode           = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $responseHeaderSize     = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $responseContent        = substr($response, $responseHeaderSize);

    $result = json_decode($responseContent);

    curl_close($ch);

} catch(Exception $e) {
    echo $e->getCode() . ": " . $e->getMessage();
}
?>
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.stream.ActorMaterializer

import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.util.{Failure, Success}

object Main extends App {
  implicit val system: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  val http = Http(system)

  val request = HttpRequest(method = HttpMethods.GET, uri = "https://api.litego.io:9000/api/v1/merchant/me")
    .withHeaders(Authorization(OAuth2BearerToken("YOUR_AUTH_TOKEN")))

  http.singleRequest(request).onComplete {
    case Failure(ex) => System.out.println(s"Failed to get. Reason: $ex")
    case Success(response) => System.out.println(s"Server responded with $response")
  }
}
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;
public class Example {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder()
                .url("https://api.litego.io:9000/api/v1/merchant/me")
                .get()
                .header("Authorization", "YOUR_AUTH_TOKEN")
                .build();
        Response response = client.newCall(request).execute();
    }
}

Example of the response for merchant:

{
    "id": "77aea0aa-1eb0-4a23-8597-066a90c05082",
    "name": "John Galt",
    "available_balance_satoshi": 0,
    "pending_withdrawal_satoshi": 0,
    "withdrawn_total_satoshi": 0,
    "withdrawal_address": {
        "type": "regular",
        "address": "mnBVX4hDpceePZzdS4hPnrxPJ2DzV2h1My",
        "object": "withdrawal_address"
    },
    "notification_url": "https://some_address",
    "referral_commission": 0.05,
    "object": "merchant"
}

You can get information about authenticated merchant

GET /merchant/me
Response
Merchant information `withdrawal_address` and `notification_url` are optional fields

Create a charge

> Example of a charge creation request:
curl -X POST 'https://api.litego.io:9000/api/v1/charges' \
 -H "Content-Type: application/json" \
 -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
 eyJleHAiOjE1MzI2NjYwMDQsImlhdCI6MTUzMjY2NTcwNCwibWVyY2hhbnRJZCI
 6IjhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmV
 zaFRva2VuIjpmYWxzZX0._QsZG3r4UMtU8f8qr1nl3tkewhXKl0wmyF5ef1Fihcv
 b-55UCQhAGeNWhYE9qqqxIm9_y2rkEPL-DzH5krIBhg" \
 --data "{\"description\":\"DEMO\",\"amount_satoshi\":100000}"
<?php
try {
    $ch = curl_init();

    $httpHeaders = array(
     'Content-Type: application/json',
     'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
       eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
       jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
       va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
       maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA'
    );

    $data = array(
        'description' => 'DEMO',
        'amount_satoshi' => 100000
    );

    curl_setopt($ch, CURLOPT_URL, 'https://api.litego.io:9000/api/v1/charges');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

    $response = curl_exec($ch);

    $responseCode           = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $responseHeaderSize     = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $responseContent        = substr($response, $responseHeaderSize);

    $result = json_decode($responseContent);

    curl_close($ch);

} catch(Exception $e) {
    echo $e->getCode() . ": " . $e->getMessage();
}
?>
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import akka.http.scaladsl.marshalling.Marshal
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.stream.ActorMaterializer
import spray.json.{DefaultJsonProtocol, RootJsonFormat}

import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.util.{Failure, Success}

final case class CreateCahrgeRequest(description: String = "", amount_satoshi: Option[Long] = None)

trait CreateCahrgeProtocol extends DefaultJsonProtocol {
  implicit val createChargeFormat: RootJsonFormat[CreateCahrgeRequest] = jsonFormat2(CreateCahrgeRequest)
}

object Main extends App with CreateCahrgeProtocol with SprayJsonSupport {
  implicit val system: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  val http = Http(system)

  def post(request: CreateCahrgeRequest): Future[HttpResponse] =
    Marshal(request).to[RequestEntity] flatMap { entity =>
      val request = HttpRequest(method = HttpMethods.POST, uri = "https://api.litego.io:9000/api/v1/charges", entity = entity)
        .withHeaders(Authorization(OAuth2BearerToken("YOUR_AUTH_TOKEN")))
      http.singleRequest(request)
    }

  val request = CreateCahrgeRequest("Description", Some(100L))

  post(request) onComplete {
    case Failure(ex) => System.out.println(s"Failed to post $request, reason: $ex")
    case Success(response) => System.out.println(s"Server responded with $response")
  }
}
import okhttp3.*;
import java.io.IOException;

public class Example {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "{\n\t\"description\":\"DEMO\",\n\t\"amount_satoshi\":100000\n}");
        Request request = new Request.Builder()
                .url("https://api.litego.io:9000/api/v1/charges")
                .post(body)
                .header("Authorization", "YOUR_AUTH_TOKEN")
                .build();
        Response response = client.newCall(request).execute();
    }
}

Example of the response for a created charge:

{
  "id":"aee91a40-9155-11e8-aac3-f758db4d43e0",
  "merchant_id": "77aea0aa-1eb0-4a23-8597-066a90c05082",
  "description": "DEMO",
  "amount": 100000,
  "amount_satoshi": 100000,
  "payment_request":"lntb1m1pd448akpp5yzk76sqrr2cp6f7t4fqkc9u28zzaa
  h0wa7cdwhk06v65hrmjardqdq8g3z56nccqzysd6dv5kcsmarwlcl87e4t6xzvm3p
  mg4gxc83e6a45ddnavceewjp4d5s325qff7lkscyh8rvpg0jeky5rfy29700jufe002wys63tahqp5rch06"
  "paid": false,
  "created": "2018-08-03T06:37:26Z",
  "expiry_seconds": 3600,
  "object": "charge"
}

Everytime a payment is required, you will create a new charge.

All attributes are required.

POST /charges
Attributes
description String Discretionary description of the charge.
amount_satoshi Integer Amount in satoshi.
Response
The created charge

List charges

curl 'https://api.litego.io:9000/api/v1/charges' \
 -H "Content-Type: application/json" \
 -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
 eyJleHAiOjE1MzI2NzA3NzgsImlhdCI6MTUzMjY3MDQ3OCwibWVyY2hhbnRJZCI
 6IjhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcm
 VzaFRva2VuIjpmYWxzZX0.--JwxKPtQrrv4_EY2fN8iHqJd0on-PiIQQigN30Ys
 CEcy96JXwY8fFPtQazLjSePBaLR5lUpP0DQyRsHl7jKEw"
<?php
try {
    $ch = curl_init();

    $httpHeaders = array(
     'Content-Type: application/json',
     'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
       eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
       jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
       va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
       maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA'
    );

    curl_setopt($ch, CURLOPT_URL, 'https://api.litego.io:9000/api/v1/charges');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);

    $response = curl_exec($ch);

    $responseCode           = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $responseHeaderSize     = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $responseContent        = substr($response, $responseHeaderSize);

    $result = json_decode($responseContent);

    curl_close($ch);

} catch(Exception $e) {
    echo $e->getCode() . ": " . $e->getMessage();
}
?>
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.stream.ActorMaterializer

import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.util.{Failure, Success}

object Main extends App {
  implicit val system: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  val http = Http(system)

  val request = HttpRequest(method = HttpMethods.GET, uri = "https://api.litego.io:9000/api/v1/charges")
    .withHeaders(Authorization(OAuth2BearerToken("YOUR_AUTH_TOKEN")))

  http.singleRequest(request).onComplete {
    case Failure(ex) => System.out.println(s"Failed to get. Reason: $ex")
    case Success(response) => System.out.println(s"Server responded with $response")
  }
}
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;

public class Example {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder()
                .url("https://api.litego.io:9000/api/v1/charges")
                .get()
                .header("Authorization", "YOUR_AUTH_TOKEN")
                .build();
        Response response = client.newCall(request).execute();
    }
}

Example of a response listing charges with a filter:

  {
    "data":[],
    "page":0,
    "page_size":10,
    "count":0,
    "object": "list"
  }

or

  {
    "data":
    [
      {
        "id": "31873440-09ac-11e9-87eb-5d39ee904d94",
        "merchant_id": "77aea0aa-1eb0-4a23-8597-066a90c05082",
        "description": "DEMO",
        "amount": 100,
        "amount_satoshi": 100,
        "amount_paid_satoshi": 100,
        "payment_request": "lntb1u1pwzfprkpp58q5fzngkjlstgngw09nlea25lt7scs5typhv9jlwf6nfx4hxt63sdq5g3z56n6lxqu47df3tucscqzys0jjjjm67d48ktdak0c7srkteycyfsk2zvu6zf2tyfjtp945f6wd4zeq3t4rdxqpf7yzte209hr4kxhn2xnrk8up8242lx0ru2knksqgpcerghr",
        "paid": true,
        "paid_at": "2018-12-27T07:52:12Z",
        "created": "2018-12-27T07:51:18Z",
        "expiry_seconds": 3600,
        "object": "charge"
      },
      {
        "id":"aee91a40-9155-11e8-aac3-f758db4d43e0",
        "merchant_id": "77aea0aa-1eb0-4a23-8597-066a90c05082",
        "description": "DEMO",
        "amount": 100000,
        "amount_satoshi": 100000,
        "payment_request":"lntb1m1pd448akpp5yzk76sqrr2cp6f7t4fqkc9u28zzaah0wa7cdwhk06v65hrmjardqdq8g3z56nccqzysd6dv5kcsmarwlcl87e4t6xzvm3pmg4gxc83e6a45ddnavceewjp4d5s325qff7lkscyh8rvpg0jeky5rfy29700jufe002wys63tahqp5rch06"
        "paid": false,
        "created": "2018-08-03T06:37:26Z",
        "expiry_seconds": 3600,
        "object": "charge"
      }
    ],
    "page":0,
    "page_size":10,
    "count":2,
    "object": "list"
  }

You can list charges with a paid and pagination filters.

GET /charges
Filters
paidOnly Boolean Filter charges by paid status:
true - only paid charges
false - only unpaid charges
not specified - both paid and unpaid charges
page Integer Page count. Default value is 0.
pageSize Integer Number of charges in the page. Default value is 10.
startDate Long Filter charges by date of creation:
Return invoices created not earlier than the specified date.
not specified - parameter is ignored.
Using seconds from the epoch of 1970-01-01T00:00:00Z
endDate Long Filter charges by date of creation:
Return invoices created no later than the specified date.
not specified - parameter is ignored.
Using seconds from the epoch of 1970-01-01T00:00:00Z
minAmount Long Filter charges by amount:
Return charges not less than the specified amount.
not specified - parameter is ignored.
maxAmount Long Filter charges by amount:
Return charges not more than the specified amount.
not specified - parameter is ignored.
minAmountPaid Long Filter charges by date of creation:
Return charges not less than the specified amount paid.
not specified - parameter is ignored.
maxAmountPaid Long Filter charges by date of creation:
Return charges not more than the specified amount paid.
not specified - parameter is ignored.
Sorting
sortBy String Sorting charges by:
amount - sorts by amount
amount_paid_satoshi - sorts by the amount of received payment(Does not include paid)
paid_at - sorts by date of paid
created - sorts by date of created
not specified - sorts by date of created
ascending Boolean Select sort order:
true - sorts by ascending
false - sorts by descending
not specified - sorts by descending
Response
An object that contains an array of charges

Get a single charge

curl 'https://api.litego.io:9000/api/v1/charges/31873440-09ac-11e9-87eb-5d39ee904d94' \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE1Mz
    I2NzExNzksImlhdCI6MTUzMjY3MDg3OSwibWVyY2hhbnRJZCI6IjhiNjcwM2M0LTBmZmItNDA5My1
    hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFRva2VuIjpmYWxzZX0.zuS5wVNukUY30fqnTNFj
    boifJ1mgNKbkXXX3MvOrif1ZygB3RZimE-ZcJncFoAEUXHtsu_wu4l0xgNZ4bDQaDg"
<?php
try {
    $ch = curl_init();

    $httpHeaders = array(
     'Content-Type: application/json',
     'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
       eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
       jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
       va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
       maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA'
    );

    curl_setopt($ch, CURLOPT_URL, 'https://api.litego.io:9000/api/v1/charges/31873440-09ac-11e9-87eb-5d39ee904d94');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);

    $response = curl_exec($ch);

    $responseCode           = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $responseHeaderSize     = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $responseContent        = substr($response, $responseHeaderSize);

    $result = json_decode($responseContent);

    curl_close($ch);

} catch(Exception $e) {
    echo $e->getCode() . ": " . $e->getMessage();
}
?>
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.stream.ActorMaterializer

import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.util.{Failure, Success}

object Main extends App {
  implicit val system: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  val http = Http(system)

  val request = HttpRequest(method = HttpMethods.GET, uri = "https://api.litego.io:9000/api/v1/charges/31873440-09ac-11e9-87eb-5d39ee904d94")
    .withHeaders(Authorization(OAuth2BearerToken("YOUR_AUTH_TOKEN")))

  http.singleRequest(request).onComplete {
    case Failure(ex) => System.out.println(s"Failed to get. Reason: $ex")
    case Success(response) => System.out.println(s"Server responded with $response")
  }
}
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;

public class Example {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder()
                .url("https://api.litego.io:9000/api/v1/charges/31873440-09ac-11e9-87eb-5d39ee904d94")
                .get()
                .header("Authorization", "YOUR_AUTH_TOKEN")
                .build();
        Response response = client.newCall(request).execute();
    }
}

Example of a single charge response:

  {
    "id": "31873440-09ac-11e9-87eb-5d39ee904d94",
    "merchant_id": "77aea0aa-1eb0-4a23-8597-066a90c05082",
    "description": "DEMO",
    "amount": 100,
    "amount_satoshi": 100,
    "amount_paid_satoshi": 100,
    "payment_request": "lntb1u1pwzfprkpp58q5fzngkjlstgngw09nlea25lt7scs5typhv9jlwf6nfx4hxt63sdq5g3z56n6lxqu47df3tucscqzys0jjjjm67d48ktdak0c7srkteycyfsk2zvu6zf2tyfjtp945f6wd4zeq3t4rdxqpf7yzte209hr4kxhn2xnrk8up8242lx0ru2knksqgpcerghr",
    "paid": true,
    "paid_at": "2018-12-27T07:52:12Z",
    "created": "2018-12-27T07:51:18Z",
    "expiry_seconds": 3600,
    "object": "charge"
  }

You can get a single charge by its id.

GET /charges/:charge_id
Response
A charge object

Set notification URL

To set notification URL use:

curl -X POST 'https://api.litego.io:9000/api/v1/merchant/me/notification-url' \
 -H "Content-Type: application/json" \
 -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
  eyJleHAiOjE1MzI2NjYwMDQsImlhdCI6MTUzMjY2NTcwNCwibWVyY2hhbnRJZCI
  6IjhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmV
  zaFRva2VuIjpmYWxzZX0._QsZG3r4UMtU8f8qr1nl3tkewhXKl0wmyF5ef1Fihcv
  b-55UCQhAGeNWhYE9qqqxIm9_y2rkEPL-DzH5krIBhg" \
 --data "{
    "url":"https://litego.io"
   }"
<?php
try {
    $ch = curl_init();

    $httpHeaders = array(
     'Content-Type: application/json',
     'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
       eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
       jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
       va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
       maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA'
    );

    $data = array(
        'url' => 'https://litego.io'
    );

    curl_setopt($ch, CURLOPT_URL, 'https://api.litego.io:9000/api/v1/merchant/me/notification-url');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

    $response = curl_exec($ch);

    $responseCode           = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $responseHeaderSize     = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $responseContent        = substr($response, $responseHeaderSize);

    $result = json_decode($responseContent);

    curl_close($ch);

} catch(Exception $e) {
    echo $e->getCode() . ": " . $e->getMessage();
}
?>
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import akka.http.scaladsl.marshalling.Marshal
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.stream.ActorMaterializer
import spray.json.{DefaultJsonProtocol, RootJsonFormat}

import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.util.{Failure, Success}

final case class SetNotificationUrlRequest(url: String = "")

trait SetNotificationUrlProtocol extends DefaultJsonProtocol {
  implicit val format: RootJsonFormat[SetNotificationUrlRequest] = jsonFormat1(SetNotificationUrlRequest)
}

object Main extends App with SetNotificationUrlProtocol with SprayJsonSupport {
  implicit val system: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  val http = Http(system)

  def post(request: SetNotificationUrlRequest): Future[HttpResponse] =
    Marshal(request).to[RequestEntity] flatMap { entity =>
      val request = HttpRequest(method = HttpMethods.POST, uri = "https://api.litego.io:9000/api/v1/merchant/me/notification-url", entity = entity)
        .withHeaders(Authorization(OAuth2BearerToken("YOUR_AUTH_TOKEN")))
      http.singleRequest(request)
    }

  val request = SetNotificationUrlRequest("https://litego.io")

  post(request) onComplete {
    case Failure(ex) => System.out.println(s"Failed to post $request, reason: $ex")
    case Success(response) => System.out.println(s"Server responded with $response")
  }
}
import okhttp3.*;
import java.io.IOException;

public class Example {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "{\n\t\"url\":\"https://litego.io\"\n}");
        Request request = new Request.Builder()
                .url("https://api.litego.io:9000/api/v1/merchant/me/notification-url")
                .post(body)
                .header("Authorization", "YOUR_AUTH_TOKEN")
                .build();
        Response response = client.newCall(request).execute();
    }
}

Example of a notification URL response:

{
  "url": "https://litego.io",
  "object": "notification_url"
}

Merchant can set notification URL to send notifications when a payment has been made.

POST /merchant/me/notification-url
Attributes
url String Notification URL. HTTP and HTTPS supported
Response
Notification URL object

Webhooks

Example of a payment notification sent by LiteGo:

curl https://notification.url/api/notification \
-H 'content-type: application/json' \
-X POST \
-d '{
    "invoiceId":"7afbfe70-a611-11e8-a174-7974cd817590",
    "amountMsat":60000,
    "timestamp":"2018-08-22T13:48:35Z"
  }'

A webhook is a URL where we send an HTTP POST request, giving you the possibility to react to certain events.

LiteGo will send you a notification when a payment has been made. Server makes a simple POST HTTP request to url, defined previously, and expects a HTTP 200 OK response. If successful response is not received or connection timeout occures, LiteGo will attempt to retry sending with an increasing delay up to 24 hours.

List responses from webhook

curl -X GET https://api.litego.io:9000/api/v1/merchant/me/notification-responses \
 -H "Content-Type: application/json" \
 -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
   eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
   jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
   va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
   maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA"
<?php
try {
    $ch = curl_init();

    $httpHeaders = array(
     'Content-Type: application/json',
     'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
       eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
       jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
       va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
       maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA'
    );

    curl_setopt($ch, CURLOPT_URL, 'https://api.litego.io:9000/api/v1/merchant/me/notification-responses');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);

    $response = curl_exec($ch);

    $responseCode           = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $responseHeaderSize     = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $responseContent        = substr($response, $responseHeaderSize);

    $result = json_decode($responseContent);

    curl_close($ch);

} catch(Exception $e) {
    echo $e->getCode() . ": " . $e->getMessage();
}
?>
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.stream.ActorMaterializer

import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.util.{Failure, Success}

object Main extends App {
  implicit val system: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  val http = Http(system)

  val request = HttpRequest(method = HttpMethods.GET, uri = "https://api.litego.io:9000/api/v1/merchant/me/notification-responses")
    .withHeaders(Authorization(OAuth2BearerToken("YOUR_AUTH_TOKEN")))

  http.singleRequest(request).onComplete {
    case Failure(ex) => System.out.println(s"Failed to get. Reason: $ex")
    case Success(response) => System.out.println(s"Server responded with $response")
  }
}
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;

public class Example {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder()
                .url("https://api.litego.io:9000/api/v1/merchant/me/notification-responses")
                .get()
                .header("Authorization", "YOUR_AUTH_TOKEN")
                .build();
        Response response = client.newCall(request).execute();
    }
}

Example of a response listing webhook responses:

  {
    "data":[],
    "page":0,
    "page_size":10,
    "count":0,
    "object": "list"
  }

or

  {
    "data":
    [
      {
        "charge_id": "6a432360-de8d-11e8-9ede-2d69f348ade2",
        "address": "https://some.url",
        "request": "{\"invoiceId\":\"6a432360-de8d-11e8-9ede-2d69f348ade2\",\"amountMsat\":500,\"timestamp\":\"2018-11-02T10:52:51Z\"}",
        "status": 0,
        "status_text": "Connection timeout",
        "timestamp": "2018-11-02T13:23:14.011Z"
      },
      {
        "charge_id": "6a432360-de8d-11e8-9ede-2d69f348ade2",
        "address": "https://some.url",
        "request": "{\"invoiceId\":\"6a432360-de8d-11e8-9ede-2d69f348ade2\",\"amountMsat\":500,\"timestamp\":\"2018-11-02T10:52:51Z\"}",
        "status": 200,
        "status_text": "Ok",
        "timestamp": "2018-11-02T10:53:13.705Z"
      }
    ],
    "page":0,
    "page_size":10,
    "count":2,
    "object": "list"
  }

You can list last 30 responses from webhook with detailed information.

GET /merchant/me/notification-responses
Response
An object that contains an array of responses from webhook

Set withdrawal address

To set withdrawal address use this code:

curl -X POST 'https://api.litego.io:9000/api/v1/merchant/me/withdrawal/address' \
 -H "Content-Type: application/json" \
 -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
  eyJleHAiOjE1MzI2NjYwMDQsImlhdCI6MTUzMjY2NTcwNCwibWVyY2hhbnRJZCI
  6IjhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmV
  zaFRva2VuIjpmYWxzZX0._QsZG3r4UMtU8f8qr1nl3tkewhXKl0wmyF5ef1Fihcv
  b-55UCQhAGeNWhYE9qqqxIm9_y2rkEPL-DzH5krIBhg" \
 --data "{
    "type":"regular",
    "value":"mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRfn"
   }"
<?php
try {
    $ch = curl_init();

    $httpHeaders = array(
         'Content-Type: application/json',
         'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
           eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
           jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
           va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
           maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA'
        );

    $data = array(
        'type' => 'regular',
        'value' => 'mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRfn'
    );

    curl_setopt($ch, CURLOPT_URL, 'https://api.litego.io:9000/api/v1/merchant/me/withdrawal/address');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

    $response = curl_exec($ch);

    $responseCode           = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $responseHeaderSize     = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $responseContent        = substr($response, $responseHeaderSize);

    $result = json_decode($responseContent);

    curl_close($ch);

} catch(Exception $e) {
    echo $e->getCode() . ": " . $e->getMessage();
}
?>
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import akka.http.scaladsl.marshalling.Marshal
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.stream.ActorMaterializer
import spray.json.{DefaultJsonProtocol, RootJsonFormat}

import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.util.{Failure, Success}

final case class SetWithdrawalAddressRequest(`type`: String = "", value: String = "")

trait SetWithdrawalAddressProtocol extends DefaultJsonProtocol {
  implicit val format: RootJsonFormat[SetWithdrawalAddressRequest] = jsonFormat2(SetWithdrawalAddressRequest)
}

object Main extends App with SetWithdrawalAddressProtocol with SprayJsonSupport {
  implicit val system: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  val http = Http(system)

  def post(request: SetWithdrawalAddressRequest): Future[HttpResponse] =
    Marshal(request).to[RequestEntity] flatMap { entity =>
      val request = HttpRequest(method = HttpMethods.POST, uri = "https://api.litego.io:9000/api/v1/merchant/me/withdrawal/address", entity = entity)
        .withHeaders(Authorization(OAuth2BearerToken("YOUR_AUTH_TOKEN")))
      http.singleRequest(request)
    }

  val request = SetWithdrawalAddressRequest("regular", "some_address")

  post(request) onComplete {
    case Failure(ex) => System.out.println(s"Failed to post $request, reason: $ex")
    case Success(response) => System.out.println(s"Server responded with $response")
  }
}
import okhttp3.*;
import java.io.IOException;

public class Example {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "{\n\t\"type\":\"regular\",\n\t\"value\":\"YOUR_ADDRESS\"\n}");
        Request request = new Request.Builder()
                .url("https://api.litego.io:9000/api/v1/merchant/me/withdrawal/address")
                .post(body)
                .header("Authorization", "YOUR_AUTH_TOKEN")
                .build();
        Response response = client.newCall(request).execute();
    }
}

Example of a withdrawal address response:

  {
    "type": "regular",
    "value": "mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRfn",
    "object": "withdrawal_address"
  }

or

  {
    "type": "extended",
    "value": "tpubDCZ3fGiiTX5Kv9Q96t4NcS1XMPFd85jpTcAUKFU2Vc8Rtz2vNf7Z1bUSE6euXsgjCwDWrotd4iH1ej7SJpvFL6HeYXwaPGUZyYKYWFbABvY",
    "object": "withdrawal_address"
  }

Merchant can set withdrawal address (or extended public key).

When Xpub used, a new address will be derived from this Xpub after each withdrawal. This prevents address reuse and improves privacy.

POST /merchant/me/withdrawal/address
Attributes
type String Type of the withdrawal address. Only `regular` and `extended` are supported.
value String P2PKH or P2SH address for `regular` type. xPub/yPub/zPub (tPub/uPub/vPub for testnet) for `extended` type.
Response
Withdrawal address

Auto withdrawal

To set threshold for auto withdrawal use this code:

curl -X POST \
  http://localhost:9000/api/v1/merchant/me/withdrawal/auto-withdrawal-threshold \
  -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
      eyJleHAiOjE1MzI2NjYwMDQsImlhdCI6MTUzMjY2NTcwNCwibWVyY2hhbnRJZCI
      6IjhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmV
      zaFRva2VuIjpmYWxzZX0._QsZG3r4UMtU8f8qr1nl3tkewhXKl0wmyF5ef1Fihcv
      b-55UCQhAGeNWhYE9qqqxIm9_y2rkEPL-DzH5krIBhg' \
  -H 'Content-Type: application/json' \
  -d '{"threshold": 60000}'
<?php
try {
    $ch = curl_init();

    $httpHeaders = array(
         'Content-Type: application/json',
         'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
           eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
           jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
           va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
           maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA'
        );

    $data = array(
        'threshold' => 60000
    );

    curl_setopt($ch, CURLOPT_URL, 'http://localhost:9000/api/v1/merchant/me/withdrawal/auto-withdrawal-threshold');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

    $response = curl_exec($ch);

    $responseCode           = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $responseHeaderSize     = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $responseContent        = substr($response, $responseHeaderSize);

    $result = json_decode($responseContent);

    curl_close($ch);

} catch(Exception $e) {
    echo $e->getCode() . ": " . $e->getMessage();
}
?>

import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import akka.http.scaladsl.marshalling.Marshal
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.stream.ActorMaterializer
import spray.json.{DefaultJsonProtocol, RootJsonFormat}

import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.util.{Failure, Success}

final case class SetThresholdAutoWithdrawal(thrashold: Long)

trait SetAutoWithdrawalThresholdProtocol extends DefaultJsonProtocol {
  implicit val format: RootJsonFormat[SetThresholdAutoWithdrawal] = jsonFormat1(SetThresholdAutoWithdrawal)
}

object Main extends App with SetAutoWithdrawalThresholdProtocol with SprayJsonSupport {
  implicit val system: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  val http = Http(system)

  def post(request: SetThresholdAutoWithdrawal): Future[HttpResponse] =
    Marshal(request).to[RequestEntity] flatMap { entity =>
      val request = HttpRequest(method = HttpMethods.POST, uri = "https://api.litego.io:9000/api/v1/merchant/me/withdrawal/auto-withdrawal-threshold", entity = entity)
        .withHeaders(Authorization(OAuth2BearerToken("YOUR_AUTH_TOKEN")))
      http.singleRequest(request)
    }

  val request = SetThresholdAutoWithdrawal(60000L)

  post(request) onComplete {
    case Failure(ex) => System.out.println(s"Failed to post $request, reason: $ex")
    case Success(response) => System.out.println(s"Server responded with $response")
  }
}

import okhttp3.*;
import java.io.IOException;

public class Example {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "{\"threshold\":60000}");
        Request request = new Request.Builder()
                .url("https://api.litego.io:9000/api/v1/merchant/me/withdrawal/auto-withdrawal-threshold")
                .post(body)
                .header("Authorization", "YOUR_AUTH_TOKEN")
                .build();
        Response response = client.newCall(request).execute();
    }
}

Example of a withdrawal auto threshold response:

  {
    "threshold": 60000,
    "object": "auto_withdrawal_threshold"
  }

Merchant can set threshold for auto withdrawal.

If threshold value equals '0' then it means disable auto withdrawal.

Auto withdrawal can be enable only if merchant has set withdrawal address.

When using this type of withdrawal, a commission is charged:

POST /merchant/me/withdrawal/auto-withdrawal-threshold
Attributes
threshold Long The threshold upon reaching which an automatic withdrawal will be made
Response
Auto withdrawal threshold object

Manually trigger a withdrawal

To trigger a withdrawal manually:

curl -X PUT 'https://api.litego.io:9000/api/v1/merchant/me/withdrawal/manual' \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
  eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
  jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
  va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
  maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA"
<?php
try {
    $ch = curl_init();

    $httpHeaders = array(
         'Content-Type: application/json',
         'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
           eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
           jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
           va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
           maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA'
        );

    curl_setopt($ch, CURLOPT_URL, 'https://api.litego.io:9000/api/v1/merchant/me/withdrawal/manual');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');

    $response = curl_exec($ch);

    $responseCode           = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $responseHeaderSize     = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $responseContent        = substr($response, $responseHeaderSize);

    $result = json_decode($responseContent);

    curl_close($ch);

} catch(Exception $e) {
    echo $e->getCode() . ": " . $e->getMessage();
}
?>
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.stream.ActorMaterializer

import scala.concurrent.ExecutionContextExecutor
import scala.util.{Failure, Success}

object Main extends App {
  implicit val system: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  val http = Http(system)

  val request = HttpRequest(method = HttpMethods.PUT, uri = "https://api.litego.io:9000/api/v1/merchant/me/withdrawal/manual")
    .withHeaders(Authorization(OAuth2BearerToken("YOUR_AUTH_TOKEN")))

  http.singleRequest(request).onComplete {
    case Failure(ex) => System.out.println(s"Failed to put. Reason: $ex")
    case Success(response) => System.out.println(s"Server responded with $response")
  }
}
import okhttp3.*;
import java.io.IOException;

public class Example {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "");
        Request request = new Request.Builder()
                .url("https://api.litego.io:9000/api/v1/merchant/me/withdrawal/manual")
                .put(body)
                .header("Authorization", "YOUR_AUTH_TOKEN")
                .build();
        Response response = client.newCall(request).execute();
    }
}

Example of response:

{
  "transaction_id": "5b5c3b4a519b7b785fb7bfc3e39c820934e62544909c5d648a0fba09b52d62cb",
  "merchantId": "77aea0aa-1eb0-4a23-8597-066a90c05082",
  "status": "created",
  "address": "2MtCpRhk7XAYCzpCPPenAkf9QrCRdybVMmP",
  "transaction_id_str": "bf93d4e9be90224c555b78ee076a7889ae342c01c982086206fdbacfecb167eb",
  "total_amount": 60000,
  "relative_fee": 600,
  "manual_fee": 50000,
  "created_at": "2018-08-03T06:37:26Z",
  "status_changed_at": "2018-08-03T06:37:26Z",
  "type": "manual",
  "object": "withdrawal_transaction"
}

You may trigger a withdrawal manually. At now LiteGo supports only withdrawals to regular addresses and minimum allowable amount is 60000 satoshi.

At development stage two type of withdrawal fees used:

PUT /merchant/me/withdrawal/manual
Response
Withdrawal transaction The transaction object

Withdrawal to lightning invoice

To trigger a withdrawal to lightning invoice:

curl -X POST 'https://api.litego.io:9000/api/v1/merchant/me/withdrawal/lightning-invoice' \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
  eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
  jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
  va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
  maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA" \
  -d '{
        "payment_request": "lntb1pw949wdpp5jymh5xsulwslahpp8lwgg7mr08tjjpaahvmj3jkcrvuve04a2tcsdpv23jhxapqd9h8vmmfvdjjqvevypsk6apq85srqgrnv96qcqzyspty2h703gecjgtlsvhke5h3gsqeqnecx5rxv4zvll6aeldgsxkcz267glz46vjjyk6scr0mfn6k4d9qlure6pu74na4sj3w9acpycdcqcfzud3",
        "amount_satoshi": 60000
      }'
<?php
try {
    $ch = curl_init();

    $httpHeaders = array(
         'Content-Type: application/json',
         'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
           eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
           jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
           va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
           maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA'
        );

    $data = array(
        'payment_request' => 'lntb1pw949wdpp5jymh5xsulwslahpp8lwgg7mr08tjjpaahvmj3jkcrvuve04a2tcsdpv23jhxapqd9h8vmmfvdjjqvevypsk6apq85srqgrnv96qcqzyspty2h703gecjgtlsvhke5h3gsqeqnecx5rxv4zvll6aeldgsxkcz267glz46vjjyk6scr0mfn6k4d9qlure6pu74na4sj3w9acpycdcqcfzud3',
        'amount_satoshi' => 60000
        );

    curl_setopt($ch, CURLOPT_URL, 'https://api.litego.io:9000/api/v1/merchant/me/withdrawal/lightning-invoice');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');

    $response = curl_exec($ch);

    $responseCode           = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $responseHeaderSize     = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $responseContent        = substr($response, $responseHeaderSize);

    $result = json_decode($responseContent);

    curl_close($ch);

} catch(Exception $e) {
    echo $e->getCode() . ": " . $e->getMessage();
}
?>
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import akka.http.scaladsl.marshalling.Marshal
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.stream.ActorMaterializer
import spray.json.{DefaultJsonProtocol, RootJsonFormat}

import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.util.{Failure, Success}

final case class WithdrawLightningRequest(payment_request: String = "", amount_satoshi: Option[Long] = None)

trait WithdrawLightningProtocol extends DefaultJsonProtocol {
  implicit val format: RootJsonFormat[WithdrawLightningRequest] = jsonFormat2(WithdrawLightningRequest)
}

object Main extends App with WithdrawLightningProtocol with SprayJsonSupport {
   implicit val system: ActorSystem = ActorSystem()
   implicit val ec: ExecutionContextExecutor = system.dispatcher
   implicit val materializer: ActorMaterializer = ActorMaterializer()

   val http = Http(system)

   def post(request: WithdrawLightningRequest): Future[HttpResponse] =
     Marshal(request).to[RequestEntity] flatMap { entity =>
      val request = HttpRequest(method = HttpMethods.POST, uri = "https://api.litego.io:9000/api/v1/merchant/me/withdrawal/lightning-invoice", entity = entity)
        .withHeaders(Authorization(OAuth2BearerToken("YOUR_AUTH_TOKEN")))
      http.singleRequest(request)
   }

   val request = WithdrawLightningRequest(
     "lntb1pw949wdpp5jymh5xsulwslahpp8lwgg7mr08tjjpaahvmj3jkcrvuve04a2tcsdpv23jhxapqd9h8vmmfvdjjqvevypsk6apq85srqgrnv96qcqzyspty2h703gecjgtlsvhke5h3gsqeqnecx5rxv4zvll6aeldgsxkcz267glz46vjjyk6scr0mfn6k4d9qlure6pu74na4sj3w9acpycdcqcfzud3",
     Some(60000L)
   )

   post(request) onComplete {
     case Failure(ex) => System.out.println(s"Failed to post $request, reason: $ex")
     case Success(response) => System.out.println(s"Server responded with $response")
   }
}
import okhttp3.*;
import java.io.IOException;

public class Example {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "{\n\t\"payment_request\":\"lntb1pw949wdpp5jymh5xsulwslahpp8lwgg7mr08tjjpaahvmj3jkcrvuve04a2tcsdpv23jhxapqd9h8vmmfvdjjqvevypsk6apq85srqgrnv96qcqzyspty2h703gecjgtlsvhke5h3gsqeqnecx5rxv4zvll6aeldgsxkcz267glz46vjjyk6scr0mfn6k4d9qlure6pu74na4sj3w9acpycdcqcfzud3\",\n\t\"amount_satoshi\":60000\n}");
        Request request = new Request.Builder()
                .url("https://api.litego.io:9000/api/v1/merchant/me/withdrawal/lightning-invoice")
                .post(body)
                .header("Authorization", "YOUR_AUTH_TOKEN")
                .build();
        Response response = client.newCall(request).execute();
    }
}

Example of response:

{
    "transaction_id": "5a3af160-29e6-11e9-9026-af3efaac3e61",
    "merchant_id": "6ae0b704-fe99-45a6-8312-386a644f2165",
    "status": "confirmed",
    "address": "lntb10u1pwf30fypp5hl0wt2cgf0lg443qvg0eh83lntzvjxz4jrfaurhsh8zdr46w047sdpzwfjkvun9vajhyct5daezq6twwehkjcm9xycqzysxqrrssscpawa996feenjskylas5afh9a8fs0czly4p0l9ngzhqu73qdze3ar3kvggr34qew5cu7p90n98d7exx470u6awg7ul3cnu4xu4xaxqqxyx5m2",
    "total_amount": 60000,
    "relative_fee": 600,
    "manual_fee": 0,
    "created_at": "2019-02-06T08:08:14.454Z",
    "status_changed_at": "2019-02-06T08:08:16.285Z",
    "type": "lightning_invoice",
    "object": "withdrawal_transaction"
}

You can withdraw funds to a lightning invoice.

Specify the lightning payment request and amount. Amount is optional field. If it is not specified, the entire amount of the balance will be withdrawn. Minimum allowable amount is 60000 satoshi.

LiteGo fee with this type of withdrawal is 0.1% of withdrawal amount.

POST /merchant/me/withdrawal/lightning-invoice
Attributes
payment_request String Payment request of lightning invoice
amount_satoshi Long (Optional) Withdrawal amount. If it is not specified, the entire amount of the balance will be withdrawn.
Response
Withdrawal transaction The transaction object

Withdrawal to lightning channel

To trigger a withdrawal to lightning channel:

curl -X POST 'https://api.litego.io:9000/api/v1/merchant/me/withdrawal/lightning-channel' \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
  eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
  jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
  va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
  maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA" \
  -d '{
        "public_key":"03b882dcd309adaf4d66d1aadfbc6e85764bd65c6bdaf03689c55f1abd13f53fc5",
        "host":"nodetestnet.litego.io:9735",
        "amount_sat":1000
      }'
<?php
try {
    $ch = curl_init();

    $httpHeaders = array(
         'Content-Type: application/json',
         'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
           eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
           jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
           va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
           maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA'
        );

    $data = array(
        'public_key' => '03b882dcd309adaf4d66d1aadfbc6e85764bd65c6bdaf03689c55f1abd13f53fc5',
        'host' => 'nodetestnet.litego.io:9735',
        'amount_sat' => 1000
        );

    curl_setopt($ch, CURLOPT_URL, 'https://api.litego.io:9000/api/v1/merchant/me/withdrawal/lightning-channel');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');

    $response = curl_exec($ch);

    $responseCode           = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $responseHeaderSize     = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $responseContent        = substr($response, $responseHeaderSize);

    $result = json_decode($responseContent);

    curl_close($ch);

} catch(Exception $e) {
    echo $e->getCode() . ": " . $e->getMessage();
}
?>
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import akka.http.scaladsl.marshalling.Marshal
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.stream.ActorMaterializer
import spray.json.{DefaultJsonProtocol, RootJsonFormat}

import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.util.{Failure, Success}

final case class LightningChannelWithdrawalRequest(public_key: String = "", host: String = "", amount_sat: Option[Long] = None)

trait LightningChannelWithdrawalProtocol extends DefaultJsonProtocol {
  implicit val format: RootJsonFormat[LightningChannelWithdrawalRequest] = jsonFormat3(LightningChannelWithdrawalRequest)
}

object Main extends App with LightningChannelWithdrawalProtocol with SprayJsonSupport {
   implicit val system: ActorSystem = ActorSystem()
   implicit val ec: ExecutionContextExecutor = system.dispatcher
   implicit val materializer: ActorMaterializer = ActorMaterializer()

   val http = Http(system)

   def post(request: LightningChannelWithdrawalRequest): Future[HttpResponse] =
     Marshal(request).to[RequestEntity] flatMap { entity =>
      val request = HttpRequest(method = HttpMethods.POST, uri = "https://api.litego.io:9000/api/v1/merchant/me/withdrawal/lightning-channel", entity = entity)
        .withHeaders(Authorization(OAuth2BearerToken("YOUR_AUTH_TOKEN")))
      http.singleRequest(request)
   }

   val request = LightningChannelWithdrawalRequest(
     "03b882dcd309adaf4d66d1aadfbc6e85764bd65c6bdaf03689c55f1abd13f53fc5",
     "nodetestnet.litego.io:9735",
     Some(260000L)
   )

   post(request) onComplete {
     case Failure(ex) => System.out.println(s"Failed to post $request, reason: $ex")
     case Success(response) => System.out.println(s"Server responded with $response")
   }
}
import okhttp3.*;
import java.io.IOException;

public class Example {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "{\n\t\"public_key\":\"03b882dcd309adaf4d66d1aadfbc6e85764bd65c6bdaf03689c55f1abd13f53fc5\",\n\t\"host\":\"nodetestnet.litego.io:9735\",\n\t\"amount_sat\":260000\n}");
        Request request = new Request.Builder()
                .url("https://api.litego.io:9000/api/v1/merchant/me/withdrawal/lightning-channel")
                .post(body)
                .header("Authorization", "YOUR_AUTH_TOKEN")
                .build();
        Response response = client.newCall(request).execute();
    }
}

Example of response:

{
    "transaction_id": "6f266240-4ee3-11e9-a436-0175b5691469",
    "merchant_id": "5eba9919-3ab0-453d-8e81-3f96a863d1ae",
    "status": "created",
    "address": "03b882dcd309adaf4d66d1aadfbc6e85764bd65c6bdaf03689c55f1abd13f53fc5@nodetestnet.litego.io:9735",
    "transaction_id_str": "275b500c19b650935575df95eb8ec4c1359227611ca80b4cf6d24e77dcf69a51",
    "total_amount": 200000,
    "relative_fee": 2000,
    "manual_fee": 10,
    "created_at": "2019-03-25T09:50:34.084Z",
    "status_changed_at": "2019-03-25T09:50:34.084Z",
    "type": "lightning_channel",
    "object": "withdrawal_transaction"
}

You can withdraw funds by opening lightning channel.

Specify the lightning payment request and amount. Amount is optional field. If it is not specified, the entire amount of the balance will be withdrawn.

POST /api/v1/merchant/me/withdrawal/lightning-channel
Attributes
public_key String Public key of your node
host String Address and port of your node, example: "nodetestnet.litego.io:9735"
amount_sat Long (Optional) Withdrawal amount. If it is not specified, the entire amount of the balance will be withdrawn.
Response
Withdrawal transaction The transaction object

List withdrawals

curl 'https://api.litego.io:9000/api/v1/merchant/me/withdrawals' \
 -H "Content-Type: application/json" \
 -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
 eyJleHAiOjE1MzI2NzA3NzgsImlhdCI6MTUzMjY3MDQ3OCwibWVyY2hhbnRJZCI
 6IjhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcm
 VzaFRva2VuIjpmYWxzZX0.--JwxKPtQrrv4_EY2fN8iHqJd0on-PiIQQigN30Ys
 CEcy96JXwY8fFPtQazLjSePBaLR5lUpP0DQyRsHl7jKEw"
<?php
try {
    $ch = curl_init();

    $httpHeaders = array(
     'Content-Type: application/json',
     'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
       eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
       jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
       va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
       maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA'
    );

    curl_setopt($ch, CURLOPT_URL, 'https://api.litego.io:9000/api/v1/merchant/me/withdrawals');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);

    $response = curl_exec($ch);

    $responseCode           = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $responseHeaderSize     = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $responseContent        = substr($response, $responseHeaderSize);

    $result = json_decode($responseContent);

    curl_close($ch);

} catch(Exception $e) {
    echo $e->getCode() . ": " . $e->getMessage();
}
?>
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.stream.ActorMaterializer

import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.util.{Failure, Success}

object Main extends App {
  implicit val system: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  val http = Http(system)

  val request = HttpRequest(method = HttpMethods.GET, uri = "https://api.litego.io:9000/api/v1/merchant/me/withdrawals")
    .withHeaders(Authorization(OAuth2BearerToken("YOUR_AUTH_TOKEN")))

  http.singleRequest(request).onComplete {
    case Failure(ex) => System.out.println(s"Failed to get. Reason: $ex")
    case Success(response) => System.out.println(s"Server responded with $response")
  }
}
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;

public class Example {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder()
                .url("https://api.litego.io:9000/api/v1/merchant/me/withdrawals")
                .get()
                .header("Authorization", "YOUR_AUTH_TOKEN")
                .build();
        Response response = client.newCall(request).execute();
    }
}

Example of a response listing withdrawals with a filter:

{
    "data":[],
    "page":0,
    "page_size":10,
    "count":0,
    "object": "list"
}

or

{
  "data":
    [
      {
        "transaction_id": "5b5c3b4a519b7b785fb7bfc3e39c820934e62544909c5d648a0fba09b52d62cb",
        "merchant_id": "77aea0aa-1eb0-4a23-8597-066a90c05082",
        "status": "performed",
        "address": "mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRfn",
        "transaction_id_str": "c54fd8a9130e0cc920dfcd14c8f73cc8d3f03f94ad4b56fa81ab30de9141aa19",
        "total_amount": 60000,
        "relative_fee": 600,
        "manual_fee": 50000,
        "created_at": "2018-08-03T06:37:26Z",
        "status_changed_at": "2018-08-03T06:39:21Z",
        "type": "manual",
        "object": "withdrawal_transaction"
      }
    ],
  "page":0,
  "page_size":10,
  "count":1,
  "object": "list"
}

You can list withdrawals with a status and pagination filters.

GET /merchant/me/withdrawals
Filters
status String Withdrawals status. Can be "created", "performed", "confirmed"
page Integer Page count. Default value is 0.
page_size Integer Number of charges in the page. Default value is 10.
address String Filter at the address where the withdrawals was made:
Return withdrawals have the output address specified in the value.
not specified - parameter is ignored.
type String Filter withdrawals by type:
Return withdrawals have the output type specified in the value.
manual - only manual withdrawals
auto - only auto withdrawals
lightning_invoice - only lightning withdrawals
lightning_channel - only to lightning channel withdrawals

start_created_at Long Filter withdrawals by date of creation:
Return withdrawals created not earlier than the specified date.
not specified - parameter is ignored.
Using seconds from the epoch of 1970-01-01T00:00:00Z
end_created_at Long Filter withdrawals by date of creation:
Return withdrawals created no later than the specified date.
not specified - parameter is ignored.
Using seconds from the epoch of 1970-01-01T00:00:00Z
min_amount Long Filter withdrawals by amount:
Return withdrawals not less than the specified amount
not specified - parameter is ignored.
max_amount Long Filter withdrawals by amount:
Refund withdrawals not more than the specified amount
not specified - parameter is ignored.
start_changed_at Long Filter withdrawals by date of change status:
Return withdrawals whose status has changed not earlier than the specified date.
not specified - parameter is ignored.
end_changed_at Long Filter withdrawals by date of change status:
Return withdrawals whose status has changed not later than the specified date.
not specified - parameter is ignored.
Sorting
sort_by String Sorting withdrawals by:
total_amount - sorts by amount
status_changed_at - sorts by date of changed status
created_at - sorts by date of created
not specified - sorts by date of created
ascending Boolean Select sort order:
true - sorts by ascending
false - sorts by descending
not specified - sorts by descending
Response
An object that contains an array of withdrawals

Get withdrawal settings

curl 'https://api.litego.io:9000/api/v1/merchant/withdrawal/settings' \
 -H "Content-Type: application/json" \
 -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
 eyJleHAiOjE1MzI2NzA3NzgsImlhdCI6MTUzMjY3MDQ3OCwibWVyY2hhbnRJZCI
 6IjhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcm
 VzaFRva2VuIjpmYWxzZX0.--JwxKPtQrrv4_EY2fN8iHqJd0on-PiIQQigN30Ys
 CEcy96JXwY8fFPtQazLjSePBaLR5lUpP0DQyRsHl7jKEw"
<?php
try {
    $ch = curl_init();

    $httpHeaders = array(
     'Content-Type: application/json',
     'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
       eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
       jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
       va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
       maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA'
    );

    curl_setopt($ch, CURLOPT_URL, 'https://api.litego.io:9000/api/v1/merchant/withdrawal/settings');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);

    $response = curl_exec($ch);

    $responseCode           = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $responseHeaderSize     = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $responseContent        = substr($response, $responseHeaderSize);

    $result = json_decode($responseContent);

    curl_close($ch);

} catch(Exception $e) {
    echo $e->getCode() . ": " . $e->getMessage();
}
?>
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.stream.ActorMaterializer

import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.util.{Failure, Success}

object Main extends App {
  implicit val system: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  val http = Http(system)

  val request = HttpRequest(method = HttpMethods.GET, uri = "https://api.litego.io:9000/api/v1/merchant/withdrawal/settings")
    .withHeaders(Authorization(OAuth2BearerToken("YOUR_AUTH_TOKEN")))

  http.singleRequest(request).onComplete {
    case Failure(ex) => System.out.println(s"Failed to get. Reason: $ex")
    case Success(response) => System.out.println(s"Server responded with $response")
  }
}
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;

public class Example {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder()
                .url("https://api.litego.io:9000/api/v1/merchant/withdrawal/settings")
                .get()
                .header("Authorization", "YOUR_AUTH_TOKEN")
                .build();
        Response response = client.newCall(request).execute();
    }
}

Example of a withdrawal settings response:

{
    "withdrawal_fee": 0.001,
    "withdrawal_manual_fee": 50000,
    "withdrawal_min_amount": 60000,
    "withdrawal_lightning_min_amount": 2
}

You can get withdrawal settings.

GET /merchant/withdrawal/settings
Response
An object that contains settings
withdrawal_fee Double Value of withdrawal fee.
withdrawal_manual_fee Long Value of fixed fee that will be used in manual withdrawals.
withdrawal_min_amount Long minimum allowed withdrawal amount.
withdrawal_lightning_min_amount Long minimum allowed withdrawal amount for lightning.
withdrawal_min_threshold_auto Long minimal amount of auto withdraw

Validate lightning payment request

To validate lightning payment request use:

curl -X POST 'https://api.litego.io:9000/api/v1/utils/payment_request_status' \
 -H "Content-Type: application/json" \
 -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
  eyJleHAiOjE1MzI2NjYwMDQsImlhdCI6MTUzMjY2NTcwNCwibWVyY2hhbnRJZCI
  6IjhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmV
  zaFRva2VuIjpmYWxzZX0._QsZG3r4UMtU8f8qr1nl3tkewhXKl0wmyF5ef1Fihcv
  b-55UCQhAGeNWhYE9qqqxIm9_y2rkEPL-DzH5krIBhg" \
 --data '{
        "payment_request_string":"lntb1pw949wdpp5jymh5xsulwslahpp8lwgg7mr08tjjpaahvmj3jkcrvuve04a2tcsdpv23jhxapqd9h8vmmfvdjjqvevypsk6apq85srqgrnv96qcqzyspty2h703gecjgtlsvhke5h3gsqeqnecx5rxv4zvll6aeldgsxkcz267glz46vjjyk6scr0mfn6k4d9qlure6pu74na4sj3w9acpycdcqcfzud3",
        "amount_satoshi":60000
    }'
<?php
try {
    $ch = curl_init();

    $httpHeaders = array(
     'Content-Type: application/json',
     'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
       eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
       jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
       va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
       maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA'
    );

    $data = array(
        'payment_request_string' => 'lntb1pw949wdpp5jymh5xsulwslahpp8lwgg7mr08tjjpaahvmj3jkcrvuve04a2tcsdpv23jhxapqd9h8vmmfvdjjqvevypsk6apq85srqgrnv96qcqzyspty2h703gecjgtlsvhke5h3gsqeqnecx5rxv4zvll6aeldgsxkcz267glz46vjjyk6scr0mfn6k4d9qlure6pu74na4sj3w9acpycdcqcfzud3',
        'amount_satoshi' => 60000
    );

    curl_setopt($ch, CURLOPT_URL, 'https://api.litego.io:9000/api/v1/utils/payment_request_status');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

    $response = curl_exec($ch);

    $responseCode           = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $responseHeaderSize     = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $responseContent        = substr($response, $responseHeaderSize);

    $result = json_decode($responseContent);

    curl_close($ch);

} catch(Exception $e) {
    echo $e->getCode() . ": " . $e->getMessage();
}
?>
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import akka.http.scaladsl.marshalling.Marshal
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.stream.ActorMaterializer
import spray.json.{DefaultJsonProtocol, RootJsonFormat}

import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.util.{Failure, Success}

final case class ValidateLightningRequest(payment_request_string: String = "", amount_satoshi: Long = 0L)

trait ValidateLightningProtocol extends DefaultJsonProtocol {
  implicit val format: RootJsonFormat[ValidateLightningRequest] = jsonFormat2(ValidateLightningRequest)
}

object Main extends App with ValidateLightningProtocol with SprayJsonSupport {
  implicit val system: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  val http = Http(system)

  def post(request: ValidateLightningRequest): Future[HttpResponse] =
    Marshal(request).to[RequestEntity] flatMap { entity =>
      val request = HttpRequest(method = HttpMethods.POST, uri = "https://api.litego.io:9000/api/v1/utils/payment_request_status", entity = entity)
        .withHeaders(Authorization(OAuth2BearerToken("YOUR_AUTH_TOKEN")))
      http.singleRequest(request)
    }

  val request = ValidateLightningRequest(
    "lntb1pw949wdpp5jymh5xsulwslahpp8lwgg7mr08tjjpaahvmj3jkcrvuve04a2tcsdpv23jhxapqd9h8vmmfvdjjqvevypsk6apq85srqgrnv96qcqzyspty2h703gecjgtlsvhke5h3gsqeqnecx5rxv4zvll6aeldgsxkcz267glz46vjjyk6scr0mfn6k4d9qlure6pu74na4sj3w9acpycdcqcfzud3",
    60000L
  )

  post(request) onComplete {
    case Failure(ex) => System.out.println(s"Failed to post $request, reason: $ex")
    case Success(response) => System.out.println(s"Server responded with $response")
  }
}
import okhttp3.*;
import java.io.IOException;

public class Example {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "{\n\t\"payment_request_string\":\"lntb1pw949wdpp5jymh5xsulwslahpp8lwgg7mr08tjjpaahvmj3jkcrvuve04a2tcsdpv23jhxapqd9h8vmmfvdjjqvevypsk6apq85srqgrnv96qcqzyspty2h703gecjgtlsvhke5h3gsqeqnecx5rxv4zvll6aeldgsxkcz267glz46vjjyk6scr0mfn6k4d9qlure6pu74na4sj3w9acpycdcqcfzud3\",\n\t\"amount_satoshi\":60000\n}");
        Request request = new Request.Builder()
                .url("https://api.litego.io:9000/api/v1/utils/payment_request_status")
                .post(body)
                .header("Authorization", "YOUR_AUTH_TOKEN")
                .build();
        Response response = client.newCall(request).execute();
    }
}

Example of a validate lightning payment request response:

{
    "payment_request_string": "lntb1pw949wdpp5jymh5xsulwslahpp8lwgg7mr08tjjpaahvmj3jkcrvuve04a2tcsdpv23jhxapqd9h8vmmfvdjjqvevypsk6apq85srqgrnv96qcqzyspty2h703gecjgtlsvhke5h3gsqeqnecx5rxv4zvll6aeldgsxkcz267glz46vjjyk6scr0mfn6k4d9qlure6pu74na4sj3w9acpycdcqcfzud3",
    "amount_satoshi": 0,
    "memo": "Test invoice",
    "path_found": true,
    "expired": false,
    "paid": false
}

You can validate payment request of lightning invoice, specifying payment request and desired amount, that will be payed to this amount.

POST /utils/payment_request_status
Attributes
payment_request_string String Payment request of lightning invoice.
amount_satoshi Long Payment amount, that will be sent to this amount.
Response
payment_request_string String Payment request of lightning invoice.
amount_satoshi Long Payment amount, decoced from payment request.
memo String Payment memo, decoced from payment request.
path_found Boolean Shows if find routes to payment destination.
expired Boolean Shows if payment expired.
paid Boolean Shows if payment was paid.

List referral payments

curl 'https://api.litego.io:9000/api/v1/merchant/me/referral-payments' \
 -H "Content-Type: application/json" \
 -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
 eyJleHAiOjE1MzI2NzA3NzgsImlhdCI6MTUzMjY3MDQ3OCwibWVyY2hhbnRJZCI
 6IjhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcm
 VzaFRva2VuIjpmYWxzZX0.--JwxKPtQrrv4_EY2fN8iHqJd0on-PiIQQigN30Ys
 CEcy96JXwY8fFPtQazLjSePBaLR5lUpP0DQyRsHl7jKEw"
<?php
try {
    $ch = curl_init();

    $httpHeaders = array(
     'Content-Type: application/json',
     'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
       eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
       jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
       va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
       maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA'
    );

    curl_setopt($ch, CURLOPT_URL, 'https://api.litego.io:9000/api/v1/merchant/me/referral-payments');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);

    $response = curl_exec($ch);

    $responseCode           = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $responseHeaderSize     = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $responseContent        = substr($response, $responseHeaderSize);

    $result = json_decode($responseContent);

    curl_close($ch);

} catch(Exception $e) {
    echo $e->getCode() . ": " . $e->getMessage();
}
?>
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.stream.ActorMaterializer

import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.util.{Failure, Success}

object Main extends App {
  implicit val system: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  val http = Http(system)

  val request = HttpRequest(method = HttpMethods.GET, uri = "https://api.litego.io:9000/api/v1/merchant/me/referral-payments")
    .withHeaders(Authorization(OAuth2BearerToken("YOUR_AUTH_TOKEN")))

  http.singleRequest(request).onComplete {
    case Failure(ex) => System.out.println(s"Failed to get. Reason: $ex")
    case Success(response) => System.out.println(s"Server responded with $response")
  }
}
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;

public class Example {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder()
                .url("https://api.litego.io:9000/api/v1/merchant/me/referral-payments")
                .get()
                .header("Authorization", "YOUR_AUTH_TOKEN")
                .build();
        Response response = client.newCall(request).execute();
    }
}

Example of a response listing referral payments with a filter:

{
    "data":[],
    "page":0,
    "page_size":10,
    "count":0,
    "object": "list"
}

or

{
  "data":
    [
      {
         "amount_msat": 100,
         "paid_at": "2018-08-03T06:37:26Z",
         "object": "referral_payment"
      }
    ],
  "page":0,
  "page_size":10,
  "count":1,
  "object": "list"
}

You can list referral payments with a pagination filters.

GET /merchant/me/referral-payments
Filters
page Integer Page count. Default value is 0.
size Integer Number of charges in the page. Default value is 10.
Response
An object that contains an array of referral payments

Websocket API

Subscribe payments

<?php
/*
Install Websocket Client for PHP library with Composer
Just add

"require": {
  "textalk/websocket": "1.0.*"
}

in your projects composer.json.
*/

require('vendor/autoload.php');

use WebSocket\Client;

$client = new Client("wss://api.litego.io:9000/api/v1/payments/subscribe",
    array("headers" => array("authorization" => "Bearer YOUR_TOKEN")));

$client->send("");
$result_string = ""; 
while ($result_string == "") {
    try {
        $result_string = trim($client->receive());
        echo $result_string ."<br/>";
    } catch (Exception $e) {}
}
exit;
?>
import akka.Done
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.http.scaladsl.model.ws._
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.{Keep, Sink, Source}

import scala.concurrent.{ExecutionContextExecutor, Future}

object Main extends App {
  implicit val system: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  val http = Http(system)

  val outgoing = Source.repeat(TextMessage(""))

  val incoming: Sink[Message, Future[Done]] =
    Sink.foreach {
      case message: TextMessage.Strict =>
        println(message.text)
    }

  val webSocketFlow =
    http.webSocketClientFlow(
      WebSocketRequest(
        uri = "wss://api.litego.io:9000/api/v1/payments/subscribe",
        extraHeaders = List(Authorization(OAuth2BearerToken("YOUR_TOKEN")))
      )
    )

  val (upgradeResponse, closed) =
    outgoing
      .viaMat(webSocketFlow)(Keep.right)
      .toMat(incoming)(Keep.both)
      .run()

  val connected = upgradeResponse.map { upgrade =>
    if (upgrade.response.status == StatusCodes.SwitchingProtocols) {
      Done
    } else {
      throw new RuntimeException(s"Connection failed: ${upgrade.response.status}")
    }
  }

  connected.onComplete(println)
  closed.foreach(_ => println("closed"))
}
import okhttp3.WebSocket;
import okhttp3.WebSocketListener;

public class Application {
    public static void main(String[] args) {
        OkHttpClient httpClient = new OkHttpClient();
        Request request = new Request.Builder()
                .url("https://api.litego.io:9000/api/v1/payments/subscribe")
                .addHeader("Authorization", "Bearer " + "YOUR_TOKEN")
                .build();
        httpClient.newWebSocket(request, new WebSocketListener() {
                 @Override
                 public void onMessage(WebSocket webSocket, String text) {
                     System.out.println("Receive: " + text);
                 }
        });
    }
}

Example of event in payments topic:

{  
   "invoice_id":"e0fe5260-01db-11e9-9754-adb009bbf170",
   "merchant_id":"ca938c7a-ce45-4217-aa84-96b38c0a5b90",
   "amount_paid_satoshi":100,
   "settled_at":"2018-12-17T09:12:39Z"
}

You may subscribe to topic with payments of all your charges.

Subscription requires authentication. You need to pass your auth token in header to authorize.

Topic is available at wss://api.litego.io:9000/api/v1/payments/subscribe

Subscribe payment of single charge

<?php 
/*
Install Websocket Client for PHP library with Composer
Just add

"require": {
  "textalk/websocket": "1.0.*"
}

in your projects composer.json.
*/

require('vendor/autoload.php');

use WebSocket\Client;

$client = new Client("wss://api.litego.io:9000/api/v1/payments/subscribe/21f4ddb0-fa30-11e8-85c9-01aa46d43ea0",
    array("headers" => array("authorization" => "Bearer YOUR_TOKEN")));

$client->send("");
$result_string = ""; 
while ($result_string == "") {
    try {
        $result_string = trim($client->receive());
        echo $result_string ."<br/>";
    } catch (Exception $e) {}
}
exit;
?>
import akka.Done
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.http.scaladsl.model.ws._
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.{Keep, Sink, Source}

import scala.concurrent.{ExecutionContextExecutor, Future}

object Main extends App {
  implicit val system: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  val http = Http(system)

  val outgoing = Source.repeat(TextMessage(""))

  val incoming: Sink[Message, Future[Done]] =
    Sink.foreach {
      case message: TextMessage.Strict =>
        println(message.text)
    }

  val webSocketFlow =
    http.webSocketClientFlow(
      WebSocketRequest(
        uri = "wss://api.litego.io:9000/api/v1/payments/subscribe/21f4ddb0-fa30-11e8-85c9-01aa46d43ea0",
        extraHeaders = List(Authorization(OAuth2BearerToken("YOUR_TOKEN")))
      )
    )

  val (upgradeResponse, closed) =
    outgoing
      .viaMat(webSocketFlow)(Keep.right)
      .toMat(incoming)(Keep.both)
      .run()

  val connected = upgradeResponse.map { upgrade =>
    if (upgrade.response.status == StatusCodes.SwitchingProtocols) {
      Done
    } else {
      throw new RuntimeException(s"Connection failed: ${upgrade.response.status}")
    }
  }

  connected.onComplete(println)
  closed.foreach(_ => println("closed"))
}
import okhttp3.WebSocket;
import okhttp3.WebSocketListener;

public class Application {
    public static void main(String[] args) {
        OkHttpClient httpClient = new OkHttpClient();
        Request request = new Request.Builder()
                .url("https://api.litego.io:9000/api/v1/payments/subscribe/21f4ddb0-fa30-11e8-85c9-01aa46d43ea0")
                .addHeader("Authorization", "Bearer " + "YOUR_TOKEN")
                .build();
        httpClient.newWebSocket(request, new WebSocketListener() {
                 @Override
                 public void onMessage(WebSocket webSocket, String text) {
                     System.out.println("Receive: " + text);
                 }
        });
    }
}

Example of event in charge payment topic:

{  
   "invoice_id":"21f4ddb0-fa30-11e8-85c9-01aa46d43ea0",
   "merchant_id":"ca938c7a-ce45-4217-aa84-96b38c0a5b90",
   "amount_paid_satoshi":100,
   "settled_at":"2018-12-17T09:12:39Z"
}

You may subscribe to topic with payment of a single charge by ID.

Subscription requires authentication. You need to pass your auth token in header to authorize.

Topic is available at wss://api.litego.io:9000/api/v1/payments/subscribe/:charge_id

Wallets

We have implemented a simple custodian currency wallet using API with REST. It appears after merchant registration.

All response objects are delivered as JSON objects

Digital Currency Support

LiteGo supports currencies in table below.

You should define currency type in every endpoint related to wallet operations.

Common pattern is:

https://api.litego.io:9000/api/v1/:currency/...

So, if you'd like to use Bitcoin wallet you should pass btc as parameter:

https://api.litego.io:9000/api/v1/btc/...

Identifier Currency
btc Bitcoin
eos EOS

Generate Wallet Address

curl -X PUT 'https://api.litego.io:9000/api/v1/btc/address' \
 -H "Content-Type: application/json" \
 -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
 eyJzdWIiOiI5OWExMmJhMC02ZWE1LTRiNGEtYjNhMS00MzFmZjQ4OGNmMzQiLCJ
 leHAiOjE1NDcxMjg2MTYsImlhdCI6MTU0NzA0MjIxNiwicm9sZXMiOltdLCJpc1
 JlZnJlc2hUb2tlbiI6ZmFsc2V9.wzJEOr9mUf2GbCH9dETxnkR0bFwNrC31UkdT
 RKN7IpECU91jOVdj0QSI7kBami76U9L9ZUjZlxMfD9tqJQbO8w"
<?php
try {
    $ch = curl_init();

    $httpHeaders = array(
     'Content-Type: application/json',
     'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
       eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
       jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
       va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
       maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA'
    );

    curl_setopt($ch, CURLOPT_URL, 'https://api.litego.io:9000/api/v1/btc/address');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');

    $response = curl_exec($ch);

    $responseCode           = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $responseHeaderSize     = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $responseContent        = substr($response, $responseHeaderSize);

    $result = json_decode($responseContent);

    curl_close($ch);

} catch(Exception $e) {
    echo $e->getCode() . ": " . $e->getMessage();
}
?>
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.stream.ActorMaterializer

import scala.concurrent.ExecutionContextExecutor
import scala.util.{Failure, Success}

object Main extends App {
  implicit val system: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  val http = Http(system)

  val request = HttpRequest(method = HttpMethods.PUT, uri = "https://api.litego.io:9000/api/v1/btc/address")
    .withHeaders(Authorization(OAuth2BearerToken("YOUR_AUTH_TOKEN")))

  http.singleRequest(request).onComplete {
    case Failure(ex) => System.out.println(s"Failed to put. Reason: $ex")
    case Success(response) => System.out.println(s"Server responded with $response")
  }
}
import okhttp3.*;
import java.io.IOException;

public class Example {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "");
        Request request = new Request.Builder()
          .header("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI1NWU0OTY5ZS0wM2NmLTQ1M2EtOWU2ZC02YWE2NWQxZTRjZGYiLCJleHAiOjE1NTQ5NjUyMzIsImlhdCI6MTU1NDg3ODgzMiwicm9sZXMiOltdLCJpc1JlZnJlc2hUb2tlbiI6ZmFsc2V9.9PbzDJRGF1nxgp6gva5AE3AvYk9FyVIRbeLbsofJKBB5Lb2Qb4m63e0bqQOJBdPyKom6mQuqPKibxLDuTcbl2g")
          .url("https://api.litego.io:9000/api/v1/btc/address")
          .put(body)
          .build();
        Response response = client.newCall(request).execute();
    }
}

Example of response:

{
    "address": "2NDzK6VZ9cKMftUDgEgK3PNMnd3ASD3weyQ"
}

or EOS:

curl -X PUT 'https://api.litego.io:9000/api/v1/eos/address' \
 -H "Content-Type: application/json" \
 -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
 eyJzdWIiOiI5OWExMmJhMC02ZWE1LTRiNGEtYjNhMS00MzFmZjQ4OGNmMzQiLCJ
 leHAiOjE1NDcxMjg2MTYsImlhdCI6MTU0NzA0MjIxNiwicm9sZXMiOltdLCJpc1
 JlZnJlc2hUb2tlbiI6ZmFsc2V9.wzJEOr9mUf2GbCH9dETxnkR0bFwNrC31UkdT
 RKN7IpECU91jOVdj0QSI7kBami76U9L9ZUjZlxMfD9tqJQbO8w"
<?php
try {
    $ch = curl_init();

    $httpHeaders = array(
     'Content-Type: application/json',
     'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
       eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
       jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
       va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
       maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA'
    );

    curl_setopt($ch, CURLOPT_URL, 'https://api.litego.io:9000/api/v1/eos/address');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');

    $response = curl_exec($ch);

    $responseCode           = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $responseHeaderSize     = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $responseContent        = substr($response, $responseHeaderSize);

    $result = json_decode($responseContent);

    curl_close($ch);

} catch(Exception $e) {
    echo $e->getCode() . ": " . $e->getMessage();
}
?>

Example of response:

{
    "account": "litegolitego",
    "address": "41f2f32b-c481-41e3-bec9-96081c66024a"
}

This API call is used to create a new receive address for your wallet.

HTTP Request

PUT /api/v1/:currency/address

Response

An object that contains address

Field Description
BTC
address Bitcoin address in BTC wallet
EOS
address Your merchant ID
account LiteGo service EOS account

Memo

Memo field

Parameter Type Required Description
id String Yes Your merchant ID
data String No Your comment

Send Coins to Address

curl -X POST 'https://api.litego.io:9000/api/v1/btc/sendcoins' \
 -H "Content-Type: application/json" \
 -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
 eyJzdWIiOiI5OWExMmJhMC02ZWE1LTRiNGEtYjNhMS00MzFmZjQ4OGNmMzQiLCJ
 leHAiOjE1NDcxMjg2MTYsImlhdCI6MTU0NzA0MjIxNiwicm9sZXMiOltdLCJpc1
 JlZnJlc2hUb2tlbiI6ZmFsc2V9.wzJEOr9mUf2GbCH9dETxnkR0bFwNrC31UkdT
 RKN7IpECU91jOVdj0QSI7kBami76U9L9ZUjZlxMfD9tqJQbO8w" \
 -d "{
     "address": "2ND3f32GyDLrsxrWnrRBrH2Nr9WzdWPETx6",
     "amount_sat": 1000,
     "comment": "some payment"
    }"
<?php
try {
    $ch = curl_init();

    $httpHeaders = array(
     'Content-Type: application/json',
     'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
       eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
       jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
       va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
       maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA'
    );

    $data = array(
        'address' => '2ND3f32GyDLrsxrWnrRBrH2Nr9WzdWPETx6',
        'amount_sat' => 1000,
        'comment' => 'some payment'
    );

    curl_setopt($ch, CURLOPT_URL, 'https://api.litego.io:9000/api/v1/btc/sendcoins');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

    $response = curl_exec($ch);

    $responseCode           = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $responseHeaderSize     = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $responseContent        = substr($response, $responseHeaderSize);

    $result = json_decode($responseContent);

    curl_close($ch);

} catch(Exception $e) {
    echo $e->getCode() . ": " . $e->getMessage();
}
?>
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import akka.http.scaladsl.marshalling.Marshal
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.stream.ActorMaterializer
import spray.json.{DefaultJsonProtocol, RootJsonFormat}

import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.util.{Failure, Success}

final case class SendBtcRequest (address: String = "", amount_sat: Long = 0L, comment: Option[String] = None)

trait SendBtcProtocol extends DefaultJsonProtocol {
  implicit val format: RootJsonFormat[SendBtcRequest] = jsonFormat3(SendBtcRequest)
}

object Main extends App with SendBtcProtocol with SprayJsonSupport {
  implicit val system: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  val http = Http(system)

  def post(request: SendBtcRequest): Future[HttpResponse] =
    Marshal(request).to[RequestEntity] flatMap { entity =>
      val request = HttpRequest(method = HttpMethods.POST, uri = "https://api.litego.io:9000/api/v1/btc/sendcoins", entity = entity)
        .withHeaders(Authorization(OAuth2BearerToken("YOUR_AUTH_TOKEN")))
      http.singleRequest(request)
    }

  val request = SendBtcRequest("2ND3f32GyDLrsxrWnrRBrH2Nr9WzdWPETx6", 1000L, Some("some payment"))

  post(request) onComplete {
    case Failure(ex) => System.out.println(s"Failed to post $request, reason: $ex")
    case Success(response) => System.out.println(s"Server responded with $response")
  }
}
import okhttp3.*;
import java.io.IOException;

public class Example {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "{\n\t\"address\":\"2ND3f32GyDLrsxrWnrRBrH2Nr9WzdWPETx6\",\n\t\"amount_sat\":1000,\n\t\"comment\":\"some payment\"\n}");
        Request request = new Request.Builder()
                .url("https://api.litego.io:9000/api/v1/btc/sendcoins")
                .post(body)
                .header("Authorization", "YOUR_AUTH_TOKEN")
                .build();
        Response response = client.newCall(request).execute();
    }
}

Example of response:

{
    "id": "6e575dc0-14e0-11e9-b92e-93a3d6bba1bd",
    "txid": "edead84ca0849f22dc9670a3a304fb1378b52bdbadd547b71346367cb10735c8",
    "amount_sat": 1000,
    "blockchain_fee": 166,
    "comment": "some payment"
}

And for EOS

curl -X POST 'https://api.litego.io:9000/api/v1/eos/sendcoins' \
 -H "Content-Type: application/json" \
 -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
 eyJzdWIiOiI5OWExMmJhMC02ZWE1LTRiNGEtYjNhMS00MzFmZjQ4OGNmMzQiLCJ
 leHAiOjE1NDcxMjg2MTYsImlhdCI6MTU0NzA0MjIxNiwicm9sZXMiOltdLCJpc1
 JlZnJlc2hUb2tlbiI6ZmFsc2V9.wzJEOr9mUf2GbCH9dETxnkR0bFwNrC31UkdT
 RKN7IpECU91jOVdj0QSI7kBami76U9L9ZUjZlxMfD9tqJQbO8w" \
 -d "{
     "account": "RecipientAccount",
     "amount_eos": 0.01,
     "memo": "some payment"
    }"

Example of response:

{
    "id": "a27550dc-d990-3dab-9794-c38e0e298740",
    "txid": "e0fe9142b82d6d52826b4cdc3d94b101b07645ce3b3a203f2f00ad0d86060a05",
    "amount_eos": 0.01,
    "memo": "some payment"
}

This API call allows you to send cryptocurrency to a destination address.

HTTP Request

POST /api/v1/:currency/sendcoins

Body Parameters

Parameter Type Required Description
BTC
address String Yes Recipient address
amount_sat Long Yes Amount to be sent to the recipient in satoshi e.g. 1000
comment String No Any additional comment to attach to the transaction
EOS
account String Yes Recipient account
amount_eos Double Yes Amount to be sent to the recipient in eos e.g. 0.01
memo String No Any additional memo to attach to the transaction

Response

An object that contains send information

Field Description
BTC
id ID of transfer for retrieve
txid Blockchain transaction ID
amount_sat The amount that was sent in satoshi e.g. 1000
blockchain_fee The amount of the fee in satoshi
comment Transaction comment
EOS
id ID of transfer for retrieve
txid Blockchain transaction ID
amount_eos The amount that was sent in eos e.g. 0.01
memo Transaction memo

Send Coins to Many

curl -X POST 'https://api.litego.io:9000/api/v1/btc/sendmany' \
 -H "Content-Type: application/json" \
 -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
 eyJzdWIiOiI5OWExMmJhMC02ZWE1LTRiNGEtYjNhMS00MzFmZjQ4OGNmMzQiLCJ
 leHAiOjE1NDcxMjg2MTYsImlhdCI6MTU0NzA0MjIxNiwicm9sZXMiOltdLCJpc1
 JlZnJlc2hUb2tlbiI6ZmFsc2V9.wzJEOr9mUf2GbCH9dETxnkR0bFwNrC31UkdT
 RKN7IpECU91jOVdj0QSI7kBami76U9L9ZUjZlxMfD9tqJQbO8w" \
 -d "{
        "amounts": [
            {
                "address": "2N6Jd4MPeNDXNDtTQPPMgQteobzSyM8AvUy",
                "amount_sat": 2000
            },
            {
                "address": "2Myqv6jPbnPNBNBFwUhLNJikcN8y6eeEe41",
                "amount_sat": 2000
            }
        ],
        "comment": "many"
     }"
<?php
try {
    $ch = curl_init();

    $httpHeaders = array(
     'Content-Type: application/json',
     'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
       eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
       jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
       va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
       maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA'
    );

    $data = array(
        'amounts' => array(
            array(
                'address' => '2N6Jd4MPeNDXNDtTQPPMgQteobzSyM8AvUy',
                'amount_sat' => 2000
            ),
            array(
                'address' => '2Myqv6jPbnPNBNBFwUhLNJikcN8y6eeEe41',
                'amount_sat' => 2000
            )
        ),
        'comment' => 'many'
    );

    curl_setopt($ch, CURLOPT_URL, 'https://api.litego.io:9000/api/v1/btc/sendmany');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

    $response = curl_exec($ch);

    $responseCode           = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $responseHeaderSize     = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $responseContent        = substr($response, $responseHeaderSize);

    $result = json_decode($responseContent);

    curl_close($ch);

} catch(Exception $e) {
    echo $e->getCode() . ": " . $e->getMessage();
}
?>
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import akka.http.scaladsl.marshalling.Marshal
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.stream.ActorMaterializer
import spray.json.{DefaultJsonProtocol, RootJsonFormat}

import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.util.{Failure, Success}

final case class SendBtcRequest(address: String = "", amount_sat: Long = 0L, comment: Option[String] = None)
final case class SendManyBtcRequest(amounts: Seq[SendBtcRequest] = Seq.empty[SendBtcRequest], comment: Option[String] = None)

trait SendManyBtcProtocol extends DefaultJsonProtocol {
  implicit val format: RootJsonFormat[SendBtcRequest] = jsonFormat3(SendBtcRequest)
  implicit val format2: RootJsonFormat[SendManyBtcRequest] = jsonFormat2(SendManyBtcRequest)
}

object Main extends App with SendManyBtcProtocol with SprayJsonSupport {
  implicit val system: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  val http = Http(system)

  def post(request: SendManyBtcRequest): Future[HttpResponse] =
    Marshal(request).to[RequestEntity] flatMap { entity =>
      val request = HttpRequest(method = HttpMethods.POST, uri = "https://api.litego.io:9000/api/v1/btc/sendmany", entity = entity)
        .withHeaders(Authorization(OAuth2BearerToken("YOUR_AUTH_TOKEN")))
      http.singleRequest(request)
    }

  val request = SendManyBtcRequest(
      Seq(
            SendBtcRequest("mprD9vYaWUje3J16UMHevuwjirQ1aYU4RV", 1000L),
            SendBtcRequest("mwuxu2phV1XnRjzeYaq2A1euTnLYmQj4PX", 1100L)
          ), Some("Some comment")
  )

  post(request) onComplete {
    case Failure(ex) => System.out.println(s"Failed to post $request, reason: $ex")
    case Success(response) => System.out.println(s"Server responded with $response")
  }
}
import okhttp3.*;
import java.io.IOException;

public class Example {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "\n{\n\t\"amounts\": [\n\t\t{\n\t\t\t\"address\": \"2N8T6pWVZ4" +
         "UGxtqnYSudjQD1UzUrZn791CL\",\n\t\t\t\"amount_sat\": 600\n\t\t},\n\t\t{\n\t\t\t\"address\": \"2N3vE61eYsV4jsv9d" +
          "xNwzMmnZAtujEv7rgK\",\n\t\t\t\"amount_sat\": 600\n\t\t}\n\t],\n\t\"comment\": \"some comment\"\n}\n\t");
        Request request = new Request.Builder()
                .url("https://api.litego.io:9000/api/v1/btc/sendmany")
                .post(body)
                .header("Authorization", "YOUR_AUTH_TOKEN")
                .build();
        Response response = client.newCall(request).execute();
    }
}

Example of response:

{
    "transfers": [
        {
            "id": "4f4f411e-1fcb-39c9-8e9a-a51f1b6df38f",
            "txid": "8e05af4c557b370a0b432de0d8293b1ffba441da9b58f11708134ffe822db72c",
            "amount_sat": 2000,
            "blockchain_fee": 401
        },
        {
            "id": "33195642-b462-3705-b4df-a9779d924246",
            "txid": "8e05af4c557b370a0b432de0d8293b1ffba441da9b58f11708134ffe822db72c",
            "amount_sat": 2000,
            "blockchain_fee": 401
        }
    ]
}

This API call allows you to send cryptocurrency to many addresses.

HTTP Request

POST /api/v1/btc/sendmany

Body Parameters

Parameter Type Required Description
amounts Array Yes Array of recipient objects and the amount to send to each e.g. [{"address":"N6Jd4MPeNDXNDtTQPPMgQteobzSyM8AvUy", amount_sat: 1000}, …] The amount should be Long
comment String No Any additional comment to attach to the transaction

Amounts

Each amount object has the following key-value-pairs:

Parameter Type Required Description
address String Yes Recipient address
amount_sat Long Yes Amount to be sent to the recipient in satoshi e.g. 1000

Response

Array of send coins to address objects

Field Description
transfers Array of same responses when send coins to single address

Get Transfer

curl 'https://api.litego.io:9000/api/v1/btc/transfer/32bb2ba0-14c9-11e9-8bea-fd20b8b1e6f4' \
 -H "Content-Type: application/json" \
 -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
 eyJzdWIiOiI5OWExMmJhMC02ZWE1LTRiNGEtYjNhMS00MzFmZjQ4OGNmMzQiLCJ
 leHAiOjE1NDcxMjg2MTYsImlhdCI6MTU0NzA0MjIxNiwicm9sZXMiOltdLCJpc1
 JlZnJlc2hUb2tlbiI6ZmFsc2V9.wzJEOr9mUf2GbCH9dETxnkR0bFwNrC31UkdT
 RKN7IpECU91jOVdj0QSI7kBami76U9L9ZUjZlxMfD9tqJQbO8w"
<?php
try {
    $ch = curl_init();

    $httpHeaders = array(
     'Content-Type: application/json',
     'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
       eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
       jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
       va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
       maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA'
    );

    curl_setopt($ch, CURLOPT_URL, 'https://api.litego.io:9000/api/v1/btc/transfer/32bb2ba0-14c9-11e9-8bea-fd20b8b1e6f4');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);

    $response = curl_exec($ch);

    $responseCode           = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $responseHeaderSize     = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $responseContent        = substr($response, $responseHeaderSize);

    $result = json_decode($responseContent);

    curl_close($ch);

} catch(Exception $e) {
    echo $e->getCode() . ": " . $e->getMessage();
}
?>
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.stream.ActorMaterializer

import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.util.{Failure, Success}

object Main extends App {
  implicit val system: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  val http = Http(system)

  val request = HttpRequest(method = HttpMethods.GET, uri = "https://api.litego.io:9000/api/v1/btc/transfer/32bb2ba0-14c9-11e9-8bea-fd20b8b1e6f4")
    .withHeaders(Authorization(OAuth2BearerToken("YOUR_AUTH_TOKEN")))

  http.singleRequest(request).onComplete {
    case Failure(ex) => System.out.println(s"Failed to get. Reason: $ex")
    case Success(response) => System.out.println(s"Server responded with $response")
  }
}
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;
public class Example {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder()
                .url("https://api.litego.io:9000/api/v1/btc/transfer/32bb2ba0-14c9-11e9-8bea-fd20b8b1e6f4")
                .get()
                .header("Authorization", "YOUR_AUTH_TOKEN")
                .build();
        Response response = client.newCall(request).execute();
    }
}

Example of response:

{
    "id": "32bb2ba0-14c9-11e9-8bea-fd20b8b1e6f4",
    "txid": "3e5ab3da1bb239bb6ebc7205835a0fa39a830ce51faa7e4627c31eb4286cfef7",
    "address": "2ND3f32GyDLrsxrWnrRBrH2Nr9WzdWPETx6",
    "amount_sat": 600,
    "blockchain_fee": 400,
    "status": "confirmed",
    "direction": "send",
    "comment": "payment",
    "created_at": "2019-02-27T14:33:38.796Z",
    "status_changed_at": "2019-02-27T14:37:37.218Z"
}

Wallet transfers represent digital currency sends and receives on your wallet

HTTP Request

GET /api/v1/:currency/transfer/:id

Query Parameters

Parameter Type Required Description
id UUID Yes ID of the wallet transfer

Response

Returns an object of transfer

Field Description
BTC
id transaction ID to retrieve transfer
txid Blockchain transaction ID
address Recipient address
amount_sat The amount that was sent or received in satoshi
blockchain_fee The amount of the fee in satoshi only when send
status Transfer status. Can be "created", "performed" - when move to blockchain, "confirmed" - when transaction has at least 2 confirmations
direction Can be "send" or "receive"
comment Any additional comment to attach to the transaction if any
created_at Time when create transfer
status_changed_at Time when status of transfer has changed
EOS
id transaction ID to retrieve transfer
txid Blockchain transaction ID
account Recipient account
amount_eos The amount that was sent or received in eos
status Transfer status. Can be "created", "performed", "confirmed"
direction Can be "send" or "receive"
memo Transaction memo
created_at Time when create transfer
status_changed_at Time when status of transfer has changed

List Wallet Transfers

curl 'https://api.litego.io:9000/api/v1/btc/transfer?page=0&page_size=20' \
-H "Content-Type: application/json" \
-H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
eyJzdWIiOiI5OWExMmJhMC02ZWE1LTRiNGEtYjNhMS00MzFmZjQ4OGNmMzQiLCJ
leHAiOjE1NDcxMjg2MTYsImlhdCI6MTU0NzA0MjIxNiwicm9sZXMiOltdLCJpc1
JlZnJlc2hUb2tlbiI6ZmFsc2V9.wzJEOr9mUf2GbCH9dETxnkR0bFwNrC31UkdT
RKN7IpECU91jOVdj0QSI7kBami76U9L9ZUjZlxMfD9tqJQbO8w"
<?php
try {
    $ch = curl_init();

    $httpHeaders = array(
     'Content-Type: application/json',
     'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
       eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
       jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
       va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
       maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA'
    );

    curl_setopt($ch, CURLOPT_URL, 'https://api.litego.io:9000/api/v1/btc/transfer?page=0&page_size=20');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);

    $response = curl_exec($ch);

    $responseCode           = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $responseHeaderSize     = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $responseContent        = substr($response, $responseHeaderSize);

    $result = json_decode($responseContent);

    curl_close($ch);

} catch(Exception $e) {
    echo $e->getCode() . ": " . $e->getMessage();
}
?>
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.stream.ActorMaterializer

import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.util.{Failure, Success}

object Main extends App {
  implicit val system: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  val http = Http(system)

  val request = HttpRequest(method = HttpMethods.GET, uri = "https://api.litego.io:9000/api/v1/btc/transfer?page=0&page_size=20")
    .withHeaders(Authorization(OAuth2BearerToken("YOUR_AUTH_TOKEN")))

  http.singleRequest(request).onComplete {
    case Failure(ex) => System.out.println(s"Failed to get. Reason: $ex")
    case Success(response) => System.out.println(s"Server responded with $response")
  }
}
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;

public class Example {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder()
                .url("https://api.litego.io:9000/api/v1/btc/transfer?page=0&page_size=20")
                .get()
                .header("Authorization", "YOUR_AUTH_TOKEN")
                .build();
        Response response = client.newCall(request).execute();
    }
}

Example of response:

{
    "data": [],
    "page": 0,
    "page_size": 10,
    "count": 0,
    "object": "list"
}

or

{
    "data": 
    [
        {
            "id": "d8af43a0-13f9-11e9-a0e7-7313934c9587",
            "txid": "9ad34ef2ee63ad1121e7da7557b6e2df67b2219d46a95402b72f07a597525a4b",
            "address": "2MwMbaRn4WLFugZSvsk8VQ9fM68g6p1XS7h",
            "amount_sat": 3000,
            "status": "confirmed",
            "direction": "receive",
            "comment": "some payment",
            "created_at": "2019-02-27T14:17:06.794Z",
            "status_changed_at": "2019-02-27T14:37:37.341Z"
        },
        {
            "id": "e21c4a00-13f9-11e9-a0e7-7313934c9587",
            "txid": "12de5d6381abda8ed874d5cb3a235e1e1b2412905ef8a3985fbeb61f6523780e",
            "address": "2N9VaBdnf3LaaBmuAtykTy251fbj4rFPYUM",
            "amount_sat": 5000,
            "blockchain_fee": 166,
            "status": "confirmed",
            "direction": "send",
            "comment": "some payment",
            "created_at": "2019-02-27T14:17:08.424Z",
            "status_changed_at": "2019-02-27T14:37:37.340Z"
        }
    ],
    "page": 0,
    "page_size": 10,
    "count": 2,
    "object": "list"
}

You can retrieve a list of transfers with status and pagination filters.

HTTP Request

GET /api/v1/:currency/transfer?page&page_size

Query Parameters

Parameter Type Required Description
Filters
page Integer No Page count. Default value is 0.
page_size Integer No Number of transfers in the page. Default value is 10.
status String No Possible values: 'created', 'performed', 'confirmed'.
Not specified - parameter is ignored.
direction String No Possible values: 'send', 'receive'.
Not specified - parameter is ignored.
min_amount Long/Double No Filter transfers by amount:
Return transfers not less than the specified amount.
Long for BTC transfers.
Double for EOS transfers.
Not specified - parameter is ignored.
max_amount Long/Double No Filter transfers by amount:
Return transfers not less than the specified amount.
Long for BTC transfers.
Double for EOS transfers.
Not specified - parameter is ignored.
start_created_at Long No Filter transfers by date of creation:
Return transfers created not earlier than the specified date.
Not specified - parameter is ignored.
Using seconds from the epoch of 1970-01-01T00:00:00Z
end_created_at Long No Filter transfers by date of creation:
Return transfers created no later than the specified date.
Not specified - parameter is ignored.
Using seconds from the epoch of 1970-01-01T00:00:00Z
start_status_changed_at Long No Filter transfers by date of change status:
Return transfers whose status has changed not earlier than the specified date.
Not specified - parameter is ignored.
Using seconds from the epoch of 1970-01-01T00:00:00Z
end_status_changed_at Long No Filter transfers by date of change status:
Return transfers whose status has changed not later than the specified date.
Not specified - parameter is ignored.
Using seconds from the epoch of 1970-01-01T00:00:00Z
Sorting
sort_by String No Sorting transfers by:
amount - sorts by amount
created_at - sorts by date of created
status_changed_at - sorts by date of changed status
not specified - sorts by date of created.
ascending Boolean No Select sort order:
true - sorts by ascending
false - sorts by descending
not specified - sorts by descending.

Response

Returns an array of transfers

Get Balance

curl 'https://api.litego.io:9000/api/v1/btc/balance' \
-H "Content-Type: application/json" \
-H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
eyJzdWIiOiI5OWExMmJhMC02ZWE1LTRiNGEtYjNhMS00MzFmZjQ4OGNmMzQiLCJ
leHAiOjE1NDcxMjg2MTYsImlhdCI6MTU0NzA0MjIxNiwicm9sZXMiOltdLCJpc1
JlZnJlc2hUb2tlbiI6ZmFsc2V9.wzJEOr9mUf2GbCH9dETxnkR0bFwNrC31UkdT
RKN7IpECU91jOVdj0QSI7kBami76U9L9ZUjZlxMfD9tqJQbO8w"
<?php
try {
    $ch = curl_init();

    $httpHeaders = array(
     'Content-Type: application/json',
     'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
       eyJleHAiOjE1MzI2MTU5MDIsImlhdCI6MTUzMjYxNTYwMiwibWVyY2hhbnRJZCI6I
       jhiNjcwM2M0LTBmZmItNDA5My1hNzg1LWVmNDM4ZjA4YzFjNyIsImlzUmVmcmVzaFR
       va2VuIjpmYWxzZX0.4XMYnPKXyqXk_Z5ClZOaeb1dVkRvRGdQzoZH21_15yHjYOrAB
       maK7wZmH-G1Z6Nr18g4m-rfDX6tNS0JJ73hPA'
    );

    curl_setopt($ch, CURLOPT_URL, 'https://api.litego.io:9000/api/v1/btc/balance');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);

    $response = curl_exec($ch);

    $responseCode           = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $responseHeaderSize     = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $responseContent        = substr($response, $responseHeaderSize);

    $result = json_decode($responseContent);

    curl_close($ch);

} catch(Exception $e) {
    echo $e->getCode() . ": " . $e->getMessage();
}
?>
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.stream.ActorMaterializer

import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.util.{Failure, Success}

object Main extends App {
  implicit val system: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  val http = Http(system)

  val request = HttpRequest(method = HttpMethods.GET, uri = "https://api.litego.io:9000/api/v1/btc/balance")
    .withHeaders(Authorization(OAuth2BearerToken("YOUR_AUTH_TOKEN")))

  http.singleRequest(request).onComplete {
    case Failure(ex) => System.out.println(s"Failed to get. Reason: $ex")
    case Success(response) => System.out.println(s"Server responded with $response")
  }
}
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;

public class Example {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder()
                .url("https://api.litego.io:9000/api/v1/btc/balance")
                .get()
                .header("Authorization", "YOUR_AUTH_TOKEN")
                .build();
        Response response = client.newCall(request).execute();
    }
}

Example of response:

{
    "balance_sat": 2248,
    "spendable_balance_sat": 1648
}

And for EOS

curl 'https://api.litego.io:9000/api/v1/eos/balance' \
-H "Content-Type: application/json" \
-H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
eyJzdWIiOiI5OWExMmJhMC02ZWE1LTRiNGEtYjNhMS00MzFmZjQ4OGNmMzQiLCJ
leHAiOjE1NDcxMjg2MTYsImlhdCI6MTU0NzA0MjIxNiwicm9sZXMiOltdLCJpc1
JlZnJlc2hUb2tlbiI6ZmFsc2V9.wzJEOr9mUf2GbCH9dETxnkR0bFwNrC31UkdT
RKN7IpECU91jOVdj0QSI7kBami76U9L9ZUjZlxMfD9tqJQbO8w"

Example of response:

{
    "balance_eos": 2248,
    "spendable_balance_eos": 1648
}

This API call allows you to know balance.

HTTP Request

GET /api/v1/:currency/balance

Response

An object that contains current balance

Field Description
BTC
balance_sat The amount of satoshis you will have at your disposal after all confirmations
spendable_balance_sat The current amount of satoshis that you can spend now
EOS
balance_eos The amount of eos you will have at your disposal after all confirmations
spendable_balance_eos The current amount of eos that you can spend now

Subscribe to Incoming Transfers

<?php
/*
Install Websocket Client for PHP library with Composer
Just add

"require": {
  "textalk/websocket": "1.0.*"
}

in your projects composer.json.
*/

require('vendor/autoload.php');

use WebSocket\Client;

$client = new Client("wss://api.litego.io:9000/api/v1/btc/transfers/subscribe",
    array("headers" => array("authorization" => "Bearer YOUR_TOKEN")));

$client->send("");
$result_string = ""; 
while ($result_string == "") {
    try {
        $result_string = trim($client->receive());
        echo $result_string ."<br/>";
    } catch (Exception $e) {}
}
exit;
?>
import akka.Done
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.http.scaladsl.model.ws._
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.{Keep, Sink, Source}

import scala.concurrent.{ExecutionContextExecutor, Future}

object Main extends App {
  implicit val system: ActorSystem = ActorSystem()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  val http = Http(system)

  val outgoing = Source.repeat(TextMessage(""))

  val incoming: Sink[Message, Future[Done]] =
    Sink.foreach {
      case message: TextMessage.Strict =>
        println(message.text)
    }

  val webSocketFlow =
    http.webSocketClientFlow(
      WebSocketRequest(
        uri = "wss://api.litego.io:9000/api/v1/btc/transfers/subscribe",
        extraHeaders = List(Authorization(OAuth2BearerToken("YOUR_TOKEN")))
      )
    )

  val (upgradeResponse, closed) =
    outgoing
      .viaMat(webSocketFlow)(Keep.right)
      .toMat(incoming)(Keep.both)
      .run()

  val connected = upgradeResponse.map { upgrade =>
    if (upgrade.response.status == StatusCodes.SwitchingProtocols) {
      Done
    } else {
      throw new RuntimeException(s"Connection failed: ${upgrade.response.status}")
    }
  }

  connected.onComplete(println)
  closed.foreach(_ => println("closed"))
}
import okhttp3.WebSocket;
import okhttp3.WebSocketListener;

public class Application {
    public static void main(String[] args) {
        OkHttpClient httpClient = new OkHttpClient();
        Request request = new Request.Builder()
                .url("wss://api.litego.io:9000/api/v1/btc/transfers/subscribe")
                .addHeader("Authorization", "Bearer " + "YOUR_TOKEN")
                .build();
        httpClient.newWebSocket(request, new WebSocketListener() {
                 @Override
                 public void onMessage(WebSocket webSocket, String text) {
                     System.out.println("Receive: " + text);
                 }
        });
    }
}

Example of event:

{
    "id":"15a51f45-fb15-313e-8cab-8557ad150ad5",
    "merchant_id":"b315a206-584a-4535-808d-38d2b06b6840",
    "txid":"f6c11ae594881a87ccb7c041fe6e56de8e31831d26c428f258986909654148cf",
    "amount_eos":0.1234,
    "memo":"b315a206-584a-4535-808d-38d2b06b6840*payment from dev",
    "received_at":"2019-02-27T09:30:51.035Z"
}

or

{
    "id":"89469257-4c2a-3d3a-b045-3aa8460ccf17",
    "merchant_id":"c9d68628-69e6-4229-bb4e-75d7a33e9709",
    "txid":"c23df8a1aafa4f0c6daf3745f22b64f25ac2a6d87e98b43fc6173e2e8bf99ba8",
    "amount_eos":0.5678,
    "memo":"{\"id\":\"c9d68628-69e6-4229-bb4e-75d7a33e9709\",\"data\":\"from dev\"}",
    "received_at":"2019-02-27T09:30:51.035Z"
}

You may subscribe to topic with all incoming transfers for specific currency.

Subscription requires authentication. You need to pass your auth token in header to authorize.

Topic is available at wss://api.litego.io:9000/api/v1/:currency/transfers/subscribe

Easy integration

API libraries

Plugins