NAV Navbar
cURL PHP Scala Java

Introduction

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

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

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

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

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

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

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

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"
  }
]

Example of the response with errors:

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

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"
  }
]

Examples of the response with errors:

[
  {
    "name": "Forbidden",
    "detail": "Refresh token is invalid."
  }

OR

  {
    "name": "Forbidden",
    "detail": "Token does not owned by the any merchant."
  }

OR

  {
    "name": "Forbidden",
    "detail": "Token is not refresh token."
  }

OR

  {
    "name": "Forbidden",
    "detail": "Unable to decode token."
  }
]

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",
    "object": "merchant"
  }
]

Example of the response with errors:

[
  {
    "name": "Forbidden",
    "detail": "Authorization token is invalid"
  }

  OR

  {
    "name": "NotFound",
    "detail": "Unable to find merchant summary."
  }
]

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"
}

Example of the response with errors:

[
  {
    "name":"Forbidden",
    "detail":"Authorization token is invalid"
  }
]

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":"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"
      }
    ],
    "page":0,
    "page_size":10,
    "count":1,
    "object": "list"
  }
]

Example of the response with errors:

[
  {
    "name":"Forbidden",
    "detail":"Authorization token is invalid"
  }
]

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.
size Integer Number of charges in the page. Default value is 10.
Response
An object that contains an array of charges

Get a single charge

curl 'https://api.litego.io:9000/api/v1/charges/aee91a40-9155-11e8-aac3-f758db4d43e0' \
    -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/aee91a40-9155-11e8-aac3-f758db4d43e0');
    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/6a432360-de8d-11e8-9ede-2d69f348ade2")
    .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/8fa6f600-deb9-11e8-9ede-2d69f348ade2")
                .get()
                .header("Authorization", "YOUR_AUTH_TOKEN")
                .build();
        Response response = client.newCall(request).execute();
    }
}

Example of a single charge response:

[
  {
    "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"
  }
]

Example of the response with errors:

[
  {
    "name": "NotFound",
    "detail": "Unable to find charge ab89ca70-a6d1-12e8-b320-8701dae91d57"
  }

  OR

  {
    "name": "Forbidden",
    "detail": "Charge ef15a050-aa8e-11e8-ac1f-7bc551141d30 is owned by other merchant."
  }

  OR

  {
    "name": "Forbidden",
    "detail": "Authorization token is invalid"
  }
]

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"
}

Example of the response with errors:

[
  {
    "name": "BadRequest",
    "detail": "Notification URL some_url is incorrect. URL scheme different from HTTP or HTTPS does not supported."
  }

OR

  {
    "name": "Forbidden",
    "detail": "Authorization token is invalid"
  }
]

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":0,
    "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":2,
    "count":2,
    "object": "list"
  }
]

Example of the response with errors:

[
  {
    "name":"Forbidden",
    "detail":"Authorization token is invalid"
  }
]

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"
  }

]

Example of the response with errors:

[
  {
    "name": "BadRequest",
    "detail": "Address type some_type is invalid. Only regular and extended are supported."
  }

OR

  {
    "name": "BadRequest",
    "detail": "Address some_address is incorrect or does not correspond to environment (TESTNET or MAINNET). It must be valid bitcoin address."
  }

OR

  {
    "name": "Forbidden",
    "detail": "Authorization token is invalid"
  }
]

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

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",
  "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"
}

Example of response with errors:

[
  {
    "name": "InsufficientBalance",
    "detail": "Current balance 0 satoshi is not high enough for a manual withdrawal. It must be at least 60000 satoshi"
  }

OR

  {
    "name": "UnfinishedWithdrawal",
    "detail": "Previous withdrawal operation does not finished. Wait for transaction confirmation to initiate new withdrawal"
  }

OR

  {
    "name": "MissingAddress",
    "detail": "Withdrawal address not specified"
  }

OR

  {
    "name": "WithdrawalError",
    "detail": "Withdrawal to address `address` failed."
  }

OR

  {
    "name": "Forbidden",
    "detail": "Authorization token is invalid"
  }
]

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

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",
        "merchantId": "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"
}

Example of the response with errors:

{
    "name":"Forbidden",
    "detail":"Authorization token is invalid"
}

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.
size Integer Number of charges in the page. Default value is 10.
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.01,
    "withdrawal_manual_fee": 46000,
    "withdrawal_min_amount": 60000
}

Example of the response with errors:

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

You can get withdrawal settings.

GET /merchant/me/withdrawals
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.

Easy integration

API libraries

Plugins