Check an API key
/merchant/pingAnswers when the key is valid and tells you which project and service it belongs to.
curl "https://api.lirchain.com/merchant/ping" \
-H "x-api-key: YOUR_API_KEY"const API_KEY = "YOUR_API_KEY";
async function checkApiKey() {
const response = await fetch("https://api.lirchain.com/merchant/ping", {
headers: { "x-api-key": API_KEY },
});
if (!response.ok) {
throw new Error(`LirChain API ${response.status}: ${await response.text()}`);
}
return response.json();
}
const result = await checkApiKey();const API_KEY = "YOUR_API_KEY";
type CheckApiKeyResult = {
status: string;
project_id: string;
service: string;
};
async function checkApiKey(): Promise<CheckApiKeyResult> {
const response = await fetch("https://api.lirchain.com/merchant/ping", {
headers: { "x-api-key": API_KEY },
});
if (!response.ok) {
throw new Error(`LirChain API ${response.status}: ${await response.text()}`);
}
return response.json();
}
const result = await checkApiKey();import requests
API_KEY = "YOUR_API_KEY"
def check_api_key():
response = requests.get(
"https://api.lirchain.com/merchant/ping",
headers={"x-api-key": API_KEY},
timeout=30,
)
response.raise_for_status()
return response.json()
result = check_api_key()<?php
const API_KEY = "YOUR_API_KEY";
function check_api_key(): array
{
$curl = curl_init("https://api.lirchain.com/merchant/ping");
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["x-api-key: " . API_KEY],
]);
$body = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($body === false || $status >= 400) {
throw new Exception("LirChain API $status: $body");
}
return json_decode($body, true);
}
$result = check_api_key();package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
)
const apiKey = "YOUR_API_KEY"
func CheckApiKey() (map[string]any, error) {
request, err := http.NewRequest("GET", "https://api.lirchain.com/merchant/ping", nil)
if err != nil {
return nil, err
}
request.Header.Set("x-api-key", apiKey)
response, err := http.DefaultClient.Do(request)
if err != nil {
return nil, err
}
defer response.Body.Close()
data, err := io.ReadAll(response.Body)
if err != nil {
return nil, err
}
if response.StatusCode >= 400 {
return nil, fmt.Errorf("LirChain API %d: %s", response.StatusCode, data)
}
var result map[string]any
return result, json.Unmarshal(data, &result)
}
func main() {
result, err := CheckApiKey()
fmt.Println(result, err)
}{
"status": "ok",
"project_id": "3d6b1130-da92-4ddf-bad2-93f898993c39",
"service": "one_time_payments"
}