ガイド
SDK
30 以上の言語クライアント — 主要プラットフォームは手作り、それ以外は自動生成。
AskAIs Customer Service はプロトコルファーストのアプローチを採用しています。1 つの OpenAPI 3.1 仕様、1 つの WebSocket プロトコル、そしてそれを必要とするあらゆる言語のクライアントです。
ティア 1 — 手作りの SDK
当社が保守し、各プラットフォームのイディオムに沿い、該当する場合は完全な UI コンポーネントを提供します。
- Web —
@singlink/web-widget(バニラ JS バンドル、ドロップインの script タグ、約 30 kB gzip) - iOS — Swift Package、ネイティブ UIKit + SwiftUI コンポーネント (ロードマップ)
- Android — Kotlin ライブラリ + Jetpack Compose コンポーネント (ロードマップ)
- Flutter — pub.dev パッケージ (ロードマップ)
- React Native — npm パッケージ (ロードマップ)
ティア 2 — 自動生成された SDK
当社の仕様から openapi-generator によって生成された 12 言語 — 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:イベント JSON については Web ウィジェットドキュメントを参照してください
クイック例
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" }'