SDK Resmi Kirem
Kirem menyediakan SDK resmi untuk mempermudah integrasi aplikasi Anda dengan seluruh layanan Kirem WABA Dev Platform & Omnichannel Publishing. SDK kami tersedia dalam bahasa TypeScript/Node.js, Go, dan PHP.
Seluruh SDK mendukung pengetikan statis (strongly typed), streaming unduhan media, manajemen error standar, serta integrasi AI Agent berbasis Model Context Protocol (MCP).
⚙️ Fitur yang Didukung
Seluruh SDK mendukung rangkaian fitur API Kirem secara lengkap:
| Fitur / Layanan | TypeScript | Go | PHP |
|---|---|---|---|
| Kirim Teks, Gambar, Video, Dokumen, Audio | ✅ | ✅ | ✅ |
| Kirim Pesan Interaktif & Lokasi | ✅ | ✅ | ✅ |
| Kirim Templat WhatsApp Resmi | ✅ | ✅ | ✅ |
| Tanda Telah Dibaca (Read Receipt / Blue Ticks) | ✅ | ✅ | ✅ |
| Unggah Media Meta (Multipart) | ✅ | ✅ | ✅ |
| Unduh Media Streaming (Download Stream/Binary) | ✅ | ✅ | ✅ |
| Manajemen Templat & Profil Bisnis | ✅ | ✅ | ✅ |
| Manajemen Aturan Webhook Routing (Coexistence) | ✅ | ✅ | ✅ |
| Tarik Log Pesan & Log Webhook (Analytics) | ✅ | ✅ | ✅ |
| Koneksi Sosial & Publikasi Konten (Omnichannel) | ✅ | ✅ | ✅ |
| Model Context Protocol (MCP Client & AI Tools) | ✅ | ✅ | ✅ |
📦 SDK TypeScript / Node.js
TypeScript SDK kompatibel dengan lingkungan Node.js (v18+), Bun, Deno, dan runtime modern lainnya.
Instalasi
# Menggunakan npm
npm install @kiremco/sdk
# Menggunakan pnpm
pnpm add @kiremco/sdk
# Menggunakan yarn
yarn add @kiremco/sdk
Inisialisasi & Contoh Penggunaan
import { KiremClient } from '@kiremco/sdk';
const kirem = new KiremClient({
apiKey: process.env.KIREM_API_KEY || 'kd_live_your_api_key',
});
async function main() {
// 1. Kirim pesan teks
await kirem.sendText({
to: '628123456789',
text: 'Halo dari Kirem TypeScript SDK! 🚀',
});
// 2. Kirim pesan template WhatsApp
await kirem.sendTemplate({
to: '628123456789',
template: {
name: 'order_status_update',
language: { code: 'id' },
components: [
{
type: 'body',
parameters: [
{ type: 'text', text: 'Budi Santoso' },
{ type: 'text', text: 'ORD-2026-9901' },
],
},
],
},
});
// 3. Unduh file media (streaming blob)
const fileBlob = await kirem.downloadMedia('media_id_12345');
console.log('Ukuran file:', fileBlob.size);
// 4. Publikasi konten lintas platform (Omnichannel)
const post = await kirem.publishPost({
content: 'Peluncuran produk terbaru kami hari ini! 🎉',
platforms: ['facebook', 'instagram', 'linkedin', 'whatsapp'],
media_url: 'https://example.com/banner.jpg',
});
console.log('Post published:', post);
// 5. Eksekusi via AI Agent MCP Tool
const mcpResult = await kirem.mcpDistributeContent({
platforms: ['facebook', 'linkedin'],
content: 'Otomatisasi pengumuman produk via MCP!',
});
console.log('MCP result:', mcpResult);
}
main().catch(console.error);
📦 Go SDK
Go SDK dirancang secara idiomatik untuk ekosistem Go, menggunakan context.Context untuk timeout dan pembatalan operasi.
Instalasi
go get github.com/kiremco/kirem-sdk-go
Inisialisasi & Contoh Penggunaan
package main
import (
"context"
"fmt"
"io"
"log"
"os"
"time"
"github.com/kiremco/kirem-sdk-go"
)
func main() {
client := kirem.NewClient(
kirem.WithAPIKey("kd_live_your_api_key"),
)
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
// 1. Kirim pesan teks
resp, err := client.SendText(ctx, "628123456789", "Halo dari Kirem Go SDK! 🐹")
if err != nil {
log.Fatalf("Gagal mengirim pesan: %v", err)
}
fmt.Printf("Pesan terkirim: %s\n", string(resp))
// 2. Unduh media streaming
stream, err := client.DownloadMedia(ctx, "media_id_12345")
if err != nil {
log.Fatalf("Gagal download media: %v", err)
}
defer stream.Close()
outFile, _ := os.Create("downloaded_media.jpg")
defer outFile.Close()
io.Copy(outFile, stream)
// 3. Publikasi Omnichannel
postResp, err := client.PublishPost(ctx, &kirem.CreatePostRequest{
Content: "Pengumuman resmi via Kirem Go SDK 🚀",
Platforms: []string{"facebook", "instagram", "linkedin"},
})
if err != nil {
log.Fatalf("Gagal posting: %v", err)
}
fmt.Printf("Total post diterbitkan: %d\n", len(postResp.Posts))
// 4. Distribusi konten via MCP
mcpResp, err := client.MCPDistributeContent(ctx, []string{"facebook"}, "Halo dari MCP!", nil)
if err != nil {
log.Fatalf("Gagal memanggil MCP: %v", err)
}
fmt.Printf("MCP Status: %v\n", mcpResp.Result)
}
📦 PHP SDK
PHP SDK mendukung PHP 8.1+ dan memanfaatkan Guzzle secara native untuk HTTP request berperforma tinggi.
Instalasi
composer require kiremco/sdk
Inisialisasi & Contoh Penggunaan
<?php
require_once 'vendor/autoload.php';
use Kirem\Client as KiremClient;
use Kirem\ApiException;
$kirem = new KiremClient('kd_live_your_api_key');
try {
// 1. Kirim pesan teks
$result = $kirem->sendText('628123456789', 'Halo dari Kirem PHP SDK! 🐘');
echo "Pesan berhasil dikirim!\n";
// 2. Kirim pesan templat
$tmplResult = $kirem->sendTemplate('628123456789', [
'name' => 'order_status_update',
'language' => ['code' => 'id'],
'components' => [
[
'type' => 'body',
'parameters' => [
['type' => 'text', 'text' => 'Budi'],
],
],
],
]);
// 3. Unduh file media (binary string)
$mediaData = $kirem->downloadMedia('media_id_12345');
file_put_contents('invoice.pdf', $mediaData);
// 4. Publikasi Omnichannel ke Sosial Media
$postResult = $kirem->publishPost([
'content' => 'Promo Gajian dimulai hari ini! 🎁',
'platforms' => ['facebook', 'instagram', 'linkedin', 'whatsapp'],
'media_url' => 'https://example.com/promo.jpg',
]);
print_r($postResult);
// 5. Eksekusi tool MCP
$mcpResult = $kirem->mcpDistributeContent(
['facebook', 'linkedin'],
'Konten terdistribusi otomatis via MCP PHP!',
);
print_r($mcpResult);
} catch (ApiException $e) {
echo "Error ({$e->getCode()}): {$e->getMessage()}\n";
if ($e->getErrors()) {
print_r($e->getErrors());
}
}