Uygulamalarınızdan kataloğu görüntüleyin, fiyat hesaplayın ve siparişleri yönetin. Hesabınızdaki hizmetler, fiyatlar ve bakiye geçerlidir.
Kimlik doğrulama
Açın: hesap ayarları. «API anahtarı» bölümünde «Anahtar oluştur» düğmesine basın ve anahtarı kaydedin.
Anahtarın tamamı yalnızca bir kez gösterilir. Yeniden oluşturulduğunda eski anahtar hemen geçersiz olur. Anahtarı URL’de değil, Authorization: Bearer başlığında gönderin.
Authorization: Bearer YOUR_API_KEY
Temel URL
https://streamkit.su/api/v1
Hizmet satın alma
Katalogdan service_id alın ve fiyat hesaplatın. Satın almak için quote_id ile benzersiz bir Idempotency-Key gönderin. Ardından order_id ile durumu sorgulayın. Fiyat hesaplama ücretsizdir ve 5 dakika geçerlidir.
API para birimi hesap ayarlarından seçilir: RUB, USD veya EUR. Bakiye, katalog ve yeni teklifler bu currency değerini kullanır. Teklif, para birimini ve exchange_rate değerini 5 dakika sabitler; ayar veya kur değişikliği mevcut quote_id ya da ödenmiş siparişin fiyatını değiştirmez.
Tutarlar en fazla 8 ondalık basamaklı metinlerdir; küçük tutarların doğruluğu için unit_price en fazla 18 basamak kullanır. exchange_rate bir para birimi başına RUB değeridir; rate_date kur tarihidir. Asıl kesinti price_rub, temel bakiye balance_rub alanındadır. Örneklerde RUB kullanılır.
Paketler ve yapılandırıcılar durdurulmuş abonelik oluşturur; başlatmak için start kullanılır. YouTube izleyicileri v2 satın alma sonrası otomatik başlar. pending, submitting ve unknown durumları ret anlamına gelmez: yeni sipariş oluşturmak yerine aynı siparişi kontrol edin.
Örnek değişkenleri
Parametre
Açıklama
STREAMKIT_API_KEY
Ortam değişkenindeki tam API anahtarınız.
service_id
Katalogdaki hizmet kimliği; örneğin plan:12 veya smm:45.
quote_id
POST /quotes yanıtındaki teklif UUID’si.
order_id
Satın alma yanıtındaki tam id; örneğin subscription:123.
target
Hizmetin satın alındığı kanal, video veya profil.
Idempotency-Key
Benzersiz satın alma anahtarınız. Yeniden denemelerde ilk değeri kullanın.
Kimlikler, fiyatlar ve yanıtlar örnektir. Kendi katalog, teklif ve siparişinizdeki değerleri kullanın.
Hizmetler
Ürünler, paketler, yapılandırıcılar, YouTube izleyicileri v2 ve yapay zekâ sohbet botları aynı fiyat hesaplama ve satın alma metotlarını kullanır. family ile filtreleyin. Geçerli service_id ve parametreleri GET /services yanıtından alın. available: false olan hizmetler geçici olarak kullanılamaz.
Sayfalama pagination içinde döner: page, limit, total, pages. Katalog ayrıca platform ve kind filtrelerini destekler. service_id ve order_id farklı nesneleri belirtir; yanıttaki tam kimlikleri kullanın.
Ürünler
Tüm platformlar için takipçi, beğeni, görüntülenme ve diğer ürünler. Sipariş miktarını quantity ile belirtin; parameters.quantity içindeki minimum, maximum ve step değerlerine uyun. Satın alma bir product:<id> siparişi döndürür.
Katalog filtresi
GET /services?family=product
Parametre
Açıklama
target
Seçilen platformdaki kanal, profil, gönderi veya videonun kullanıcı adı ya da URL’si.
Twitch, Kick, YouTube ve VK Live için hazır izleyici paketleri. İzleyici sayısı paketin viewers alanında belirtilir; kanalı ve duration değerini siz seçersiniz. subscription:<id> aboneliği durdurulmuş olarak oluşturulur. Başlatma, duraklatma ve diğer işlemler API ve panelden yapılabilir.
Katalog filtresi
GET /services?family=plan
Parametre
Açıklama
target
Seçilen platformun kanalı; YouTube için kanal bağlantısı veya @handle kullanın. Yayın bağlantısı sahibinin kanalına dönüştürülür.
Twitch, Kick, YouTube ve VK Live için izleyici sayısı ve süreyi seçin. Fiyat parametrelere göre hesaplanır. Paketler gibi, panelden yönetilen bir subscription:<id> aboneliği oluşturur. Satın alma sonrasında start gerekir.
Katalog filtresi
GET /services?family=configurator
Parametre
Açıklama
target
Seçilen platformun kanalı. YouTube için youtube.com/@handle veya youtube.com/channel/UC… kullanın.
viewers
parameters.viewers.minimum ile maximum arasında tam sayı izleyici sayısı.
duration_hours
Saat cinsinden süre: 1–8760.
duration
duration_hours yerine 1h, 1d, 7d veya 30d gönderilebilir.
YouTube canlı yayın izleyicileri satın alma sonrası otomatik başlar. Sipariş product:<id> olarak döner. v2’de abonelik paneli, duraklatma, kanal veya izleyici sayısı değiştirme yoktur.
Katalog alanıdır, satın alma parametresi değildir. Süre hizmete bağlıdır; örneğin 60 dakika. Başka bir süre için farklı bir service_id seçin. Yüksek izleyici sayıları kullanılabilir; kesin sınır parameters.quantity.maximum alanındadır.
Twitch, Kick, VK Live ve YouTube için yapay zekâ sohbet botları. Twitch, Kick ve VK Live için bots, hours, variant; YouTube için messages, speed, language gönderin. Değerleri offers içinden seçin. Tüm siparişler chatbot:<id> olarak döner.
Katalog filtresi
GET /services?family=ai_chatbots
Twitch / Kick / VK Live
Parametre
Açıklama
target
Canlı yayın kanalı.
bots
offers içindeki kullanılabilir teklifteki bot sayısı.
hours
Seçilen teklifte kullanılabilen saat cinsinden süre.
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);
actions alanı desteklenen işlemleri listeler. Aboneliklerde start, pause, stop, viewers ve channel kullanılabilir. viewers, 1 ile purchased_viewers arasında olmalıdır. Kanal değişimi kota ve bekleme süresine bağlıdır. Yapay zekâ siparişi ready durumundayken start ile başlatılabilir.
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);
Tam satın alma örneği. Ödeme öncesinde quote_id ve Idempotency-Key değerlerini kaydedin; ağ hatasından sonra aynı değerleri kullanın.
# 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.
İstekleri yeniden deneme
Ağ hatasından sonra aynı quote_id ve Idempotency-Key ile yeniden deneyin. Yeniden ücret alınmadan aynı siparişi ve güncel durumunu alırsınız. Aynı anahtarı farklı bir quote_id ile kullanmak 409 döndürür. Her fiyat teklifi yalnızca bir kez ödenebilir.
Anahtar başına dakikada 600 GET ve 120 POST isteği. limit: 1–100, varsayılan 25. JSON gövdesi en fazla 32 KiB olabilir. 429 yanıtındaki Retry-After, bekleme süresini saniye olarak belirtir.