📖 Introduction
Qubitchain Gateway は、Lightning Network を使用したマイクロ課金 API Gateway です。 各 API リクエストごとに Bitcoin Lightning Network を通じて支払いが行われます。
主な特徴
- 即座の支払い確認: Lightning Network による数秒での決済完了
- マイクロペイメント: 1リクエストあたり 5 sats という超低コスト
- シンプルな統合: REST API による簡単な実装
- リアルタイム追跡: 使用状況と課金履歴の即時確認
🔐 Authentication
すべての API リクエストには API Key が必要です。 API Key は Dashboard で生成できます。
API Key の取得
- Dashboard にアクセス
- 「Generate API Key」ボタンをクリック
- 生成された API Key をコピーして安全に保管
API Key の使用方法
API Key は URL のクエリパラメータとして渡します:
https://your-gateway.com/api/endpoint?key=YOUR_API_KEY
🔌 Endpoints
GET /api/hello
シンプルな Hello World エンドポイント。API のテストに最適です。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| key | string | Yes | Your API Key |
Response
{
"success": true,
"message": "Hello from Qubitchain Gateway! ⚡",
"credits_charged": 5,
"timestamp": "2025-11-14T10:30:00.000Z",
"api_key_id": "uuid-here"
}
Cost
💸 Payment Flow
Qubitchain Gateway は以下のフローで支払いを処理します:
API Request
クライアントが API Key を含めて API エンドポイントにリクエストを送信します。
GET /api/hello?key=qbhk_xxx
Invoice Generation
システムが LNbits API を使用して Lightning Invoice を生成します。 Invoice には QR コードと payment request が含まれます。
Payment
ユーザーが Lightning ウォレットで Invoice を支払います。 QR コードをスキャンするか、payment request をコピーして使用します。
Confirmation & Response
支払いが確認されると、システムが API レスポンスを返します。 通常、支払い確認は数秒以内に完了します。
💻 Code Examples
JavaScript / Node.js
// Fetch API を使用
const apiKey = 'qbhk_your_api_key_here';
const response = await fetch(
`https://your-gateway.com/api/hello?key=${apiKey}`
);
const data = await response.json();
console.log(data);
// {
// "success": true,
// "message": "Hello from Qubitchain Gateway! ⚡",
// "credits_charged": 5,
// ...
// }
cURL
curl -X GET \ "https://your-gateway.com/api/hello?key=qbhk_your_api_key_here"
Python
import requests
api_key = 'qbhk_your_api_key_here'
url = f'https://your-gateway.com/api/hello?key={api_key}'
response = requests.get(url)
data = response.json()
print(data)
❌ Error Handling
API は以下のエラーコードを返す可能性があります:
| Status Code | Error | Description |
|---|---|---|
| 400 | Bad Request | リクエストパラメータが不正です |
| 401 | Unauthorized | API Key が無効または欠落しています |
| 402 | Payment Required | 支払いが必要ですが完了していません |
| 408 | Request Timeout | 支払いがタイムアウトしました |
| 500 | Internal Server Error | サーバーエラーが発生しました |
Error Response Format
{
"success": false,
"error": "Unauthorized",
"message": "Invalid API Key",
"code": 401
}
⏱️ Rate Limits
現在、レート制限は実装されていませんが、将来的に以下の制限が適用される可能性があります:
- リクエスト数: 1 API Key あたり 100 requests/minute
- 並行リクエスト: 最大 10 concurrent requests
- 1日の上限: 10,000 requests/day
📦 SDKs & Libraries
以下の言語用の SDK を開発予定です:
JavaScript/TypeScript
Coming Soon
Python
Coming Soon
Go
Coming Soon
Rust
Coming Soon