Read the catalog, get quotes and manage orders from your applications. The same services, prices and balance as your dashboard.
Authentication
Open account settings. In the “API key” section, click “Create key” and save it.
The full key is shown once. Rotating it immediately invalidates the previous key. Send it in the Authorization: Bearer header, never in the URL.
Authorization: Bearer YOUR_API_KEY
Base URL
https://streamkit.su/api/v1
Purchasing services
Get a service_id from the catalog and request a quote. Purchase with the quote_id and a unique Idempotency-Key, then read the status using order_id. Quotes are free and valid for 5 minutes.
Select the API currency in account settings: RUB, USD or EUR. The balance, catalog and new quotes use this currency. A quote locks its currency and exchange_rate for 5 minutes; changing preferences or rates does not alter an existing quote_id or the original price of a purchased order.
Amounts are strings with up to 8 decimal places; unit_price uses up to 18 to retain small amounts. The exchange_rate is RUB per unit of account currency; rate_date is the rate date. Internal debit amounts use price_rub; the base balance is balance_rub. Examples below use RUB.
Plans and configurators create stopped subscriptions and use a separate start action. YouTube viewers v2 launch after purchase. States pending, submitting and unknown do not mean rejection: check the same order instead of creating another.
Example variables
Parameter
Description
STREAMKIT_API_KEY
Your full API key in an environment variable.
service_id
The catalog service ID, such as plan:12 or smm:45.
quote_id
The quote UUID returned by POST /quotes.
order_id
The full purchase response id, for example subscription:123.
target
The channel, video or profile receiving the service.
Idempotency-Key
Your unique purchase key. Retain the original value for retries.
IDs, prices and responses in examples are illustrative. Substitute values from your catalog, quote and order.
Services
Products, plans, configurators, YouTube viewers v2 and AI chatbots share quote and purchase methods. Use family to select a service type. Get actual service_id values and constraints from GET /services. Services with available: false are temporarily unavailable.
The pagination object contains page, limit, total and pages. Additional catalog filters are platform and kind. Values service_id and order_id refer to different objects: retain the full identifiers from responses.
Products
Followers, likes, views and other products across platforms. Set the order volume in quantity and respect minimum, maximum and step from parameters.quantity. A purchase returns a product:<id> order.
Catalog filter
GET /services?family=product
Parameter
Description
target
A login or URL for the selected platform’s channel, profile, post or video.
quantity
An integer unit count respecting the service step.
Fixed viewer packages for Twitch, Kick, YouTube and VK Live. The plan defines the viewers count. Choose a target and duration. A subscription:<id> is created stopped; start, pause and other controls are available through the API and dashboard.
Catalog filter
GET /services?family=plan
Parameter
Description
target
The selected platform's channel; for YouTube use a channel URL or @handle. A broadcast URL is resolved to its owner's channel.
Choose the viewer count and duration for Twitch, Kick, YouTube and VK Live. Pricing depends on the parameters. Like a plan, this creates a subscription:<id> with dashboard controls and requires start after purchase.
Catalog filter
GET /services?family=configurator
Parameter
Description
target
The selected platform's channel. For YouTube use youtube.com/@handle or youtube.com/channel/UC….
viewers
Integer viewer count between parameters.viewers.minimum and maximum.
duration_hours
Duration in hours: 1–8760.
duration
An alternative to duration_hours: 1h, 1d, 7d or 30d.
Viewers for YouTube live streams, launched automatically after purchase. Orders return as product:<id>. There are no subscription panel controls, pauses, channel changes or viewer adjustments.
Catalog filter
GET /services?family=youtube_v2
Parameter
Description
target
YouTube live stream URL.
quantity
Viewer count. Limits are in parameters.quantity.
duration_minutes
A catalog field, not an input. Viewer duration belongs to the selected service, for example 60 minutes. Choose a different service_id for another duration. Larger viewer volumes are available; the exact limit is parameters.quantity.maximum.
AI chatbots for Twitch, Kick, VK Live and YouTube. Send bots, hours and variant for Twitch, Kick and VK Live; use messages, speed and language for YouTube. Select values from offers. All purchases return chatbot:<id>.
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
var apiKey = Environment.GetEnvironmentVariable("STREAMKIT_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey)) throw new InvalidOperationException("Set STREAMKIT_API_KEY");
using var client = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false })
{ Timeout = TimeSpan.FromSeconds(60) };
using var request = new HttpRequestMessage(HttpMethod.Get, "https://streamkit.su/api/v1/account");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
using var response = await client.SendAsync(request);
var responseBody = await response.Content.ReadAsStringAsync();
response.EnsureSuccessStatusCode();
Console.WriteLine(responseBody);
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
var apiKey = Environment.GetEnvironmentVariable("STREAMKIT_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey)) throw new InvalidOperationException("Set STREAMKIT_API_KEY");
using var client = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false })
{ Timeout = TimeSpan.FromSeconds(60) };
using var request = new HttpRequestMessage(HttpMethod.Get, "https://streamkit.su/api/v1/services?family=youtube_v2&platform=youtube&page=1&limit=25");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
using var response = await client.SendAsync(request);
var responseBody = await response.Content.ReadAsStringAsync();
response.EnsureSuccessStatusCode();
Console.WriteLine(responseBody);
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
var apiKey = Environment.GetEnvironmentVariable("STREAMKIT_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey)) throw new InvalidOperationException("Set STREAMKIT_API_KEY");
using var client = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false })
{ Timeout = TimeSpan.FromSeconds(60) };
using var request = new HttpRequestMessage(HttpMethod.Get, "https://streamkit.su/api/v1/services/plan:12");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
using var response = await client.SendAsync(request);
var responseBody = await response.Content.ReadAsStringAsync();
response.EnsureSuccessStatusCode();
Console.WriteLine(responseBody);
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
var apiKey = Environment.GetEnvironmentVariable("STREAMKIT_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey)) throw new InvalidOperationException("Set STREAMKIT_API_KEY");
using var client = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false })
{ Timeout = TimeSpan.FromSeconds(60) };
using var request = new HttpRequestMessage(HttpMethod.Post, "https://streamkit.su/api/v1/quotes");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
request.Content = new StringContent("{\"service_id\":\"plan:12\",\"parameters\":{\"target\":\"your_channel\",\"duration\":\"8h\"}}", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
var responseBody = await response.Content.ReadAsStringAsync();
response.EnsureSuccessStatusCode();
Console.WriteLine(responseBody);
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
var apiKey = Environment.GetEnvironmentVariable("STREAMKIT_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey)) throw new InvalidOperationException("Set STREAMKIT_API_KEY");
using var client = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false })
{ Timeout = TimeSpan.FromSeconds(60) };
using var request = new HttpRequestMessage(HttpMethod.Post, "https://streamkit.su/api/v1/orders");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
request.Content = new StringContent("{\"quote_id\":\"cebe71b9-c8cb-4dfb-8315-c56ad787c640\"}", Encoding.UTF8, "application/json");
request.Headers.Add("Idempotency-Key", "my-order-0001");
using var response = await client.SendAsync(request);
var responseBody = await response.Content.ReadAsStringAsync();
response.EnsureSuccessStatusCode();
Console.WriteLine(responseBody);
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
var apiKey = Environment.GetEnvironmentVariable("STREAMKIT_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey)) throw new InvalidOperationException("Set STREAMKIT_API_KEY");
using var client = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false })
{ Timeout = TimeSpan.FromSeconds(60) };
using var request = new HttpRequestMessage(HttpMethod.Get, "https://streamkit.su/api/v1/orders?page=1&limit=25");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
using var response = await client.SendAsync(request);
var responseBody = await response.Content.ReadAsStringAsync();
response.EnsureSuccessStatusCode();
Console.WriteLine(responseBody);
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
var apiKey = Environment.GetEnvironmentVariable("STREAMKIT_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey)) throw new InvalidOperationException("Set STREAMKIT_API_KEY");
using var client = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false })
{ Timeout = TimeSpan.FromSeconds(60) };
using var request = new HttpRequestMessage(HttpMethod.Get, "https://streamkit.su/api/v1/orders/subscription:123");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
using var response = await client.SendAsync(request);
var responseBody = await response.Content.ReadAsStringAsync();
response.EnsureSuccessStatusCode();
Console.WriteLine(responseBody);
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
var apiKey = Environment.GetEnvironmentVariable("STREAMKIT_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey)) throw new InvalidOperationException("Set STREAMKIT_API_KEY");
using var client = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false })
{ Timeout = TimeSpan.FromSeconds(60) };
using var request = new HttpRequestMessage(HttpMethod.Post, "https://streamkit.su/api/v1/orders/subscription:123/actions");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
request.Content = new StringContent("{\"action\":\"start\",\"viewers\":50}", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
var responseBody = await response.Content.ReadAsStringAsync();
response.EnsureSuccessStatusCode();
Console.WriteLine(responseBody);
The actions array lists supported operations. Subscriptions support start, pause, stop, viewers and channel. The viewers count must be 1–purchased_viewers. Channel changes depend on quota and cooldown. AI orders can use start when their state is ready.
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
var apiKey = Environment.GetEnvironmentVariable("STREAMKIT_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey)) throw new InvalidOperationException("Set STREAMKIT_API_KEY");
using var client = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false })
{ Timeout = TimeSpan.FromSeconds(60) };
using var request = new HttpRequestMessage(HttpMethod.Post, "https://streamkit.su/api/v1/orders/subscription:123/actions");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
request.Content = new StringContent("{\"action\":\"start\",\"viewers\":50}", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
var responseBody = await response.Content.ReadAsStringAsync();
response.EnsureSuccessStatusCode();
Console.WriteLine(responseBody);
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
var apiKey = Environment.GetEnvironmentVariable("STREAMKIT_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey)) throw new InvalidOperationException("Set STREAMKIT_API_KEY");
using var client = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false })
{ Timeout = TimeSpan.FromSeconds(60) };
using var request = new HttpRequestMessage(HttpMethod.Post, "https://streamkit.su/api/v1/orders/subscription:123/actions");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
request.Content = new StringContent("{\"action\":\"pause\"}", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
var responseBody = await response.Content.ReadAsStringAsync();
response.EnsureSuccessStatusCode();
Console.WriteLine(responseBody);
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
var apiKey = Environment.GetEnvironmentVariable("STREAMKIT_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey)) throw new InvalidOperationException("Set STREAMKIT_API_KEY");
using var client = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false })
{ Timeout = TimeSpan.FromSeconds(60) };
using var request = new HttpRequestMessage(HttpMethod.Post, "https://streamkit.su/api/v1/orders/subscription:123/actions");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
request.Content = new StringContent("{\"action\":\"stop\"}", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
var responseBody = await response.Content.ReadAsStringAsync();
response.EnsureSuccessStatusCode();
Console.WriteLine(responseBody);
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
var apiKey = Environment.GetEnvironmentVariable("STREAMKIT_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey)) throw new InvalidOperationException("Set STREAMKIT_API_KEY");
using var client = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false })
{ Timeout = TimeSpan.FromSeconds(60) };
using var request = new HttpRequestMessage(HttpMethod.Post, "https://streamkit.su/api/v1/orders/subscription:123/actions");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
request.Content = new StringContent("{\"action\":\"viewers\",\"viewers\":25}", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
var responseBody = await response.Content.ReadAsStringAsync();
response.EnsureSuccessStatusCode();
Console.WriteLine(responseBody);
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
var apiKey = Environment.GetEnvironmentVariable("STREAMKIT_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey)) throw new InvalidOperationException("Set STREAMKIT_API_KEY");
using var client = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false })
{ Timeout = TimeSpan.FromSeconds(60) };
using var request = new HttpRequestMessage(HttpMethod.Post, "https://streamkit.su/api/v1/orders/subscription:123/actions");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
request.Content = new StringContent("{\"action\":\"channel\",\"target\":\"new_channel\"}", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
var responseBody = await response.Content.ReadAsStringAsync();
response.EnsureSuccessStatusCode();
Console.WriteLine(responseBody);
Complete purchase example. Persist quote_id and Idempotency-Key before checkout and reuse both values after a timeout.
# 1. Read the catalog and choose a real service_id
curl "https://streamkit.su/api/v1/services?limit=25" \
-H "Authorization: Bearer $STREAMKIT_API_KEY"
# 2. Request a quote using that service's parameters
curl -X POST "https://streamkit.su/api/v1/quotes" \
-H "Authorization: Bearer $STREAMKIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"service_id":"product:123","parameters":{"target":"https://t.me/your_channel","quantity":100}}'
# 3. Replace QUOTE_ID with the quote_id returned above
curl -X POST "https://streamkit.su/api/v1/orders" \
-H "Authorization: Bearer $STREAMKIT_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: my-order-0001" \
-d '{"quote_id":"QUOTE_ID"}'
require 'net/http'
require 'json'
require 'securerandom'
BASE = "https://streamkit.su/api/v1"
API_KEY = ENV.fetch('STREAMKIT_API_KEY')
def call(path, method = 'GET', body = nil, idempotency_key = nil)
uri = URI(BASE + path)
request = (method == 'GET' ? Net::HTTP::Get : Net::HTTP::Post).new(uri)
request['Authorization'] = "Bearer #{API_KEY}"
if body
request['Content-Type'] = 'application/json'
request.body = JSON.generate(body)
end
request['Idempotency-Key'] = idempotency_key if idempotency_key
http = Net::HTTP.new(uri.hostname, uri.port)
http.use_ssl = uri.scheme == 'https'
http.open_timeout = 10
http.read_timeout = http.write_timeout = 60
http.max_retries = 0
response = http.request(request)
response.value
JSON.parse(response.body)
end
puts JSON.pretty_generate(call('/services?family=product&limit=25'))
# Choose a real service_id and parameters from your catalog.
quote = call('/quotes', 'POST', JSON.parse('{"service_id":"product:123","parameters":{"target":"https://t.me/your_channel","quantity":100}}'))
purchase = { 'quote_id' => quote.fetch('data').fetch('quote_id'), 'idempotency_key' => SecureRandom.uuid }
# Persist BEFORE payment; refuse to overwrite an unresolved purchase.
File.open('streamkit-purchase.json', File::WRONLY | File::CREAT | File::EXCL, 0600) do |file|
file.write(JSON.generate(purchase))
end
puts JSON.pretty_generate(call('/orders', 'POST', { 'quote_id' => purchase.fetch('quote_id') }, purchase.fetch('idempotency_key')))
# On timeout, read the saved file and retry ONLY /orders with the same pair.
import json, os, uuid, requests
from pathlib import Path
base = "https://streamkit.su/api/v1"
headers = {"Authorization": "Bearer " + os.environ["STREAMKIT_API_KEY"]}
catalog = requests.get(base + "/services", headers=headers, timeout=30)
catalog.raise_for_status()
print(catalog.json())
# Select a real service_id from the catalog, then quote it.
quote = requests.post(base + "/quotes", headers=headers, json={
"service_id": "product:123",
"parameters": {"target": "https://t.me/your_channel", "quantity": 100}
}, timeout=30)
quote.raise_for_status()
# Save BOTH values before sending. Reuse them after any network timeout.
quote_id = quote.json()["data"]["quote_id"]
idempotency_key = str(uuid.uuid4())
# Persist BEFORE payment; refuse to overwrite an unresolved purchase.
with Path("streamkit-purchase.json").open("x", encoding="utf-8") as saved:
json.dump({"quote_id": quote_id, "idempotency_key": idempotency_key}, saved)
order = requests.post(base + "/orders",
headers={**headers, "Idempotency-Key": idempotency_key},
json={"quote_id": quote_id}, timeout=60)
order.raise_for_status()
print(order.json())
# On timeout, read the saved file and retry ONLY /orders with the same pair.
<?php
$base = "https://streamkit.su/api/v1";
$apiKey = getenv('STREAMKIT_API_KEY');
if (!$apiKey) throw new RuntimeException('Set STREAMKIT_API_KEY on the server');
function callApi(string $path, string $method = 'GET', ?array $body = null, ?string $idempotencyKey = null): array {
global $base, $apiKey;
$headers = ['Authorization: Bearer ' . $apiKey];
if ($body !== null) $headers[] = 'Content-Type: application/json';
if ($idempotencyKey !== null) $headers[] = 'Idempotency-Key: ' . $idempotencyKey;
$client = curl_init($base . $path);
$options = [CURLOPT_CUSTOMREQUEST => $method, CURLOPT_HTTPHEADER => $headers,
CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => false,
CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_TIMEOUT => 60];
if ($body !== null) $options[CURLOPT_POSTFIELDS] = json_encode($body, JSON_THROW_ON_ERROR);
curl_setopt_array($client, $options);
$response = curl_exec($client);
if ($response === false) throw new RuntimeException(curl_error($client));
$status = curl_getinfo($client, CURLINFO_RESPONSE_CODE);
if ($status < 200 || $status >= 300) throw new RuntimeException("HTTP $status: $response");
return json_decode($response, true, 512, JSON_THROW_ON_ERROR);
}
print_r(callApi('/services?family=product&limit=25'));
// Choose a real service_id and parameters from your catalog.
$quote = callApi('/quotes', 'POST', json_decode('{"service_id":"product:123","parameters":{"target":"https://t.me/your_channel","quantity":100}}', true, 512, JSON_THROW_ON_ERROR));
$purchase = ['quote_id' => $quote['data']['quote_id'], 'idempotency_key' => bin2hex(random_bytes(16))];
// Persist BEFORE payment; refuse to overwrite an unresolved purchase.
$saved = json_encode($purchase, JSON_THROW_ON_ERROR);
$file = fopen('streamkit-purchase.json', 'x');
if ($file === false) throw new RuntimeException('Check the saved purchase before continuing');
if (fwrite($file, $saved) !== strlen($saved)) throw new RuntimeException('Could not save purchase');
if (!fclose($file)) throw new RuntimeException('Could not close purchase file');
print_r(callApi('/orders', 'POST', ['quote_id' => $purchase['quote_id']], $purchase['idempotency_key']));
// On timeout, read the saved file and retry ONLY /orders with the same pair.
// Java 11+. Add com.fasterxml.jackson.core:jackson-databind (2.x) to your project.
import com.fasterxml.jackson.databind.ObjectMapper;
import java.net.URI;
import java.net.http.*;
import java.nio.file.*;
import java.time.Duration;
import java.util.*;
public class StreamKitExample {
private static final String BASE = "https://streamkit.su/api/v1";
private static final String API_KEY = System.getenv("STREAMKIT_API_KEY");
private static final ObjectMapper JSON = new ObjectMapper();
private static final HttpClient CLIENT = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(10)).build();
private static String call(String path, String method, Object body, String idempotencyKey) throws Exception {
if (API_KEY == null || API_KEY.isBlank()) throw new IllegalStateException("Set STREAMKIT_API_KEY");
HttpRequest.Builder request = HttpRequest.newBuilder(URI.create(BASE + path))
.timeout(Duration.ofSeconds(60)).header("Authorization", "Bearer " + API_KEY);
if (body != null) request.header("Content-Type", "application/json");
if (idempotencyKey != null) request.header("Idempotency-Key", idempotencyKey);
request.method(method, body == null ? HttpRequest.BodyPublishers.noBody()
: HttpRequest.BodyPublishers.ofString(JSON.writeValueAsString(body)));
HttpResponse<String> response = CLIENT.send(request.build(), HttpResponse.BodyHandlers.ofString());
if (response.statusCode() < 200 || response.statusCode() >= 300)
throw new IllegalStateException("HTTP " + response.statusCode() + ": " + response.body());
return response.body();
}
public static void main(String[] args) throws Exception {
System.out.println(call("/services?family=product&limit=25", "GET", null, null));
// Choose a real service_id and parameters from your catalog.
String quote = call("/quotes", "POST", JSON.readTree("{\"service_id\":\"product:123\",\"parameters\":{\"target\":\"https://t.me/your_channel\",\"quantity\":100}}"), null);
String quoteId = JSON.readTree(quote).path("data").path("quote_id").asText();
if (quoteId.isBlank()) throw new IllegalStateException("Missing quote_id");
String idempotencyKey = UUID.randomUUID().toString();
Map<String, String> purchase = Map.of("quote_id", quoteId, "idempotency_key", idempotencyKey);
// Persist BEFORE payment; refuse to overwrite an unresolved purchase.
Files.writeString(Path.of("streamkit-purchase.json"), JSON.writeValueAsString(purchase), StandardOpenOption.CREATE_NEW);
System.out.println(call("/orders", "POST", Map.of("quote_id", quoteId), idempotencyKey));
// On timeout, read the saved file and retry ONLY /orders with the same pair.
}
}
import { writeFile } from "node:fs/promises";
import { randomUUID } from "node:crypto";
const base = "https://streamkit.su/api/v1";
const apiKey = process.env.STREAMKIT_API_KEY;
if (!apiKey) throw new Error("Set STREAMKIT_API_KEY on the server");
async function call(path, method = "GET", body, idempotencyKey) {
const headers = { Authorization: `Bearer ${apiKey}` };
if (body !== undefined) headers["Content-Type"] = "application/json";
if (idempotencyKey) headers["Idempotency-Key"] = idempotencyKey;
const response = await fetch(base + path, {
method, headers, redirect: "error",
body: body === undefined ? undefined : JSON.stringify(body),
signal: AbortSignal.timeout(60_000),
});
const result = await response.json();
if (!response.ok) throw new Error(result.error?.message ?? `HTTP ${response.status}`);
return result;
}
console.log(await call("/services?family=product&limit=25"));
// Choose a real service_id and parameters from your catalog.
const quote = await call("/quotes", "POST", {"service_id":"product:123","parameters":{"target":"https://t.me/your_channel","quantity":100}});
const purchase = { quote_id: quote.data.quote_id, idempotency_key: randomUUID() };
// Persist BEFORE payment; do not overwrite an unresolved purchase.
await writeFile("streamkit-purchase.json", JSON.stringify(purchase), { flag: "wx", mode: 0o600 });
console.log(await call("/orders", "POST", { quote_id: purchase.quote_id }, purchase.idempotency_key));
// On timeout, read the saved file and retry ONLY /orders with the same pair.
package main
import (
"bytes"
"crypto/rand"
"encoding/hex"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"time"
)
const base = "https://streamkit.su/api/v1"
func call(path, method string, body any, idempotencyKey string) (map[string]any, error) {
apiKey := os.Getenv("STREAMKIT_API_KEY")
if apiKey == "" { return nil, fmt.Errorf("set STREAMKIT_API_KEY") }
var payload []byte
var err error
if body != nil {
payload, err = json.Marshal(body)
if err != nil { return nil, err }
}
request, err := http.NewRequest(method, base + path, bytes.NewReader(payload))
if err != nil { return nil, err }
request.Header.Set("Authorization", "Bearer " + apiKey)
if body != nil { request.Header.Set("Content-Type", "application/json") }
if idempotencyKey != "" { request.Header.Set("Idempotency-Key", idempotencyKey) }
client := &http.Client{Timeout: 60 * time.Second,
CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse },
}
response, err := client.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 < 200 || response.StatusCode >= 300 {
return nil, fmt.Errorf("HTTP %d: %s", response.StatusCode, data)
}
var result map[string]any
err = json.Unmarshal(data, &result)
return result, err
}
func main() {
catalog, err := call("/services?family=product&limit=25", "GET", nil, "")
if err != nil { panic(err) }
fmt.Println(catalog)
// Choose a real service_id and parameters from your catalog.
var parameters map[string]any
if err := json.Unmarshal([]byte("{\"service_id\":\"product:123\",\"parameters\":{\"target\":\"https://t.me/your_channel\",\"quantity\":100}}"), ¶meters); err != nil { panic(err) }
quote, err := call("/quotes", "POST", parameters, "")
if err != nil { panic(err) }
quoteID := quote["data"].(map[string]any)["quote_id"].(string)
random := make([]byte, 16)
if _, err := rand.Read(random); err != nil { panic(err) }
key := hex.EncodeToString(random)
purchase, err := json.Marshal(map[string]string{"quote_id": quoteID, "idempotency_key": key})
if err != nil { panic(err) }
// Persist BEFORE payment; refuse to overwrite an unresolved purchase.
file, err := os.OpenFile("streamkit-purchase.json", os.O_WRONLY | os.O_CREATE | os.O_EXCL, 0600)
if err != nil { panic(err) }
if _, err := file.Write(purchase); err != nil { file.Close(); panic(err) }
if err := file.Close(); err != nil { panic(err) }
order, err := call("/orders", "POST", map[string]string{"quote_id": quoteID}, key)
if err != nil { panic(err) }
fmt.Println(order)
// On timeout, read the saved file and retry ONLY /orders with the same pair.
}
#nullable enable
using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
var apiKey = Environment.GetEnvironmentVariable("STREAMKIT_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey)) throw new InvalidOperationException("Set STREAMKIT_API_KEY");
var baseUrl = "https://streamkit.su/api/v1";
using var client = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false })
{ Timeout = TimeSpan.FromSeconds(60) };
async Task<string> CallAsync(string path, HttpMethod method, object? body = null, string? idempotencyKey = null) {
using var request = new HttpRequestMessage(method, baseUrl + path);
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
if (body is not null) request.Content = new StringContent(JsonSerializer.Serialize(body), Encoding.UTF8, "application/json");
if (idempotencyKey is not null) request.Headers.Add("Idempotency-Key", idempotencyKey);
using var response = await client.SendAsync(request);
var responseBody = await response.Content.ReadAsStringAsync();
response.EnsureSuccessStatusCode();
return responseBody;
}
Console.WriteLine(await CallAsync("/services?family=product&limit=25", HttpMethod.Get));
// Choose a real service_id and parameters from your catalog.
using var parameters = JsonDocument.Parse("{\"service_id\":\"product:123\",\"parameters\":{\"target\":\"https://t.me/your_channel\",\"quantity\":100}}");
using var quote = JsonDocument.Parse(await CallAsync("/quotes", HttpMethod.Post, parameters.RootElement));
var quoteId = quote.RootElement.GetProperty("data").GetProperty("quote_id").GetString()
?? throw new InvalidOperationException("Missing quote_id");
var idempotencyKey = Guid.NewGuid().ToString();
var purchase = new { quote_id = quoteId, idempotency_key = idempotencyKey };
// Persist BEFORE payment; refuse to overwrite an unresolved purchase.
using (var file = new FileStream("streamkit-purchase.json", FileMode.CreateNew, FileAccess.Write, FileShare.None)) {
await JsonSerializer.SerializeAsync(file, purchase);
}
Console.WriteLine(await CallAsync("/orders", HttpMethod.Post, new { quote_id = quoteId }, idempotencyKey));
// On timeout, read the saved file and retry ONLY /orders with the same pair.
Retrying requests
After a network error, retry the same quote_id and Idempotency-Key. You receive the same order and current status without another debit. Reusing the key for a different quote returns 409. Each quote can be purchased once.
600 GET and 120 POST requests per minute per key. The limit parameter is 1–100, default 25. JSON bodies: up to 32 KiB. A 429 response includes Retry-After with the waiting time in seconds.