คู่มือ
SDK
ไคลเอนต์มากกว่า 30 ภาษา — สร้างด้วยมือสำหรับแพลตฟอร์มหลัก และสร้างอัตโนมัติสำหรับที่เหลือ
AskAIs Customer Service ใช้แนวทางโปรโตคอลมาก่อน: ข้อกำหนด OpenAPI 3.1 เพียงชุดเดียว โปรโตคอล WebSocket เพียงชุดเดียว และไคลเอนต์ในทุกภาษาที่ต้องการ
ระดับ 1 — SDK ที่สร้างด้วยมือ
ดูแลโดยเรา เป็นไปตามแบบแผนของแต่ละแพลตฟอร์ม พร้อมคอมโพเนนต์ UI ครบถ้วนในกรณีที่เหมาะสม:
- Web —
@singlink/web-widget(บันเดิล JS แบบ vanilla, แท็ก script ที่ใช้งานได้ทันที, ประมาณ 30 kB gzip) - iOS — Swift Package, คอมโพเนนต์เนทีฟ UIKit + SwiftUI (แผนงาน)
- Android — ไลบรารี Kotlin + คอมโพเนนต์ Jetpack Compose (แผนงาน)
- Flutter — แพ็กเกจ pub.dev (แผนงาน)
- React Native — แพ็กเกจ npm (แผนงาน)
ระดับ 2 — SDK ที่สร้างอัตโนมัติ
12 ภาษาที่สร้างโดย openapi-generator จากข้อกำหนดของเรา — สร้างใหม่ทุกครั้งที่มีการเปลี่ยนแปลง API:
- Python · Go · Rust · Java · C# / .NET / Unity · PHP
- Ruby · Dart · Kotlin · Swift (ฝั่งเซิร์ฟเวอร์) · TypeScript · C++ (Unreal)
สร้างใหม่ในเครื่อง:
# from repo root, with web app running
pnpm sdks:generate
# subset
./scripts/generate-sdks.sh python go rustระดับ 3 — เอกสารโปรโตคอล
สำหรับ Lua / Perl / Crystal / Elixir / Haskell หรือสิ่งใดก็ตามที่เราไม่ได้สร้างไว้ล่วงหน้า ให้ทำตามข้อกำหนด โดยตรง:
- OpenAPI:
GET /api/v1/openapi.json - WebSocket: ดูเอกสาร Web widget สำหรับ JSON ของอีเวนต์
ตัวอย่างด่วน
Python
from singlink_sdk import ApiClient, AuthApi, MessagesApi
from singlink_sdk.models import IdentifyRequest, SendMessageRequest
client = ApiClient()
auth = AuthApi(client)
identity = auth.identify(
IdentifyRequest(
app_id="ws_abc123",
external_id="user_42",
email="ada@example.com",
)
)
client.set_default_header("Authorization", f"Bearer {identity.token}")
msgs = MessagesApi(client)
conv = msgs.create_conversation()
msgs.send_message(
conv.id,
SendMessageRequest(content="Hi from Python!")
)Go
import (
"context"
singlink "github.com/singlink/singlink-go"
)
cfg := singlink.NewConfiguration()
api := singlink.NewAPIClient(cfg)
resp, _, _ := api.AuthApi.Identify(context.Background()).
IdentifyRequest(singlink.IdentifyRequest{
AppId: "ws_abc123",
Email: singlink.PtrString("ada@example.com"),
}).Execute()
cfg.AddDefaultHeader("Authorization", "Bearer "+resp.Token)Rust
use singlink_sdk::apis::{auth_api, configuration::Configuration};
use singlink_sdk::models::IdentifyRequest;
let mut cfg = Configuration::new();
let identity = auth_api::identify(&cfg, IdentifyRequest {
app_id: "ws_abc123".into(),
email: Some("ada@example.com".into()),
..Default::default()
}).await?;
cfg.bearer_access_token = Some(identity.token);C# / Unity
using SingChat.Sdk.Api;
using SingChat.Sdk.Client;
using SingChat.Sdk.Model;
var cfg = new Configuration();
var auth = new AuthApi(cfg);
var identity = await auth.IdentifyAsync(new IdentifyRequest(
appId: "ws_abc123",
email: "ada@example.com"
));
cfg.DefaultHeaders.Add("Authorization", $"Bearer {identity.Token}");curl ดิบ
# identify (no library at all)
curl https://cs.askais.com/api/v1/auth/identify \
-H "Content-Type: application/json" \
-d '{ "appId": "ws_abc123", "email": "ada@example.com" }'