SDKs
Overview

SDKs

Client libraries อย่างเป็นทางการสำหรับ Pcampus Platform

ภาษาสถานะPackage
JavaScript / TypeScriptเร็วๆ นี้@pcampus-studio/sdk
Pythonวางแผน
Goวางแผน
Flutter / Dartวางแผนpcampus_sdk (pub.dev)
Rustวางแผนpcampus-sdk (crates.io)

JavaScript SDK อยู่ระหว่างพัฒนา (G-047) ระหว่างนี้ให้ใช้ REST APIs โดยตรง — ทุก endpoint มีเสถียรภาพและมีเอกสารครบถ้วน Flutter และ Rust libraries จะตามมาหลัง JS SDK เสร็จ

ใช้ REST API โดยตรง

ทุก Pcampus API เป็น HTTP ปกติที่ใช้ JSON ทุก HTTP client ใช้ได้:

# cURL
curl https://pip.pcampus.co/identity/me \
  -H "Authorization: Bearer $PIP_API_KEY"
// JavaScript — fetch (Node 18+ / browser)
const res = await fetch('https://pip.pcampus.co/identity/me', {
  headers: { Authorization: `Bearer ${process.env.PIP_API_KEY}` },
})
# Python — httpx
import httpx
r = httpx.get('https://pip.pcampus.co/identity/me',
               headers={'Authorization': f"Bearer {api_key}"})
// Flutter / Dart — http package
import 'package:http/http.dart' as http;
 
final response = await http.get(
  Uri.parse('https://pip.pcampus.co/identity/me'),
  headers: {'Authorization': 'Bearer $pipApiKey'},
);
// Rust — reqwest
use reqwest::header::{AUTHORIZATION, HeaderMap, HeaderValue};
 
let mut headers = HeaderMap::new();
headers.insert(
    AUTHORIZATION,
    HeaderValue::from_str(&format!("Bearer {}", pip_api_key))?,
);
 
let client = reqwest::Client::new();
let res = client
    .get("https://pip.pcampus.co/identity/me")
    .headers(headers)
    .send()
    .await?;

หมายเหตุสำหรับ Flutter

Flutter apps ที่ใช้ Firebase Auth สามารถใช้ Connect widget ได้ผ่าน External IdP binding — ดู Connect — External IdP:

import 'package:firebase_auth/firebase_auth.dart';
 
// ดึง Firebase ID token
final token = await FirebaseAuth.instance.currentUser?.getIdToken();
 
// ส่งไป Connect identity exchange
final res = await http.post(
  Uri.parse('https://connect-api.pcampus.co/v1/identity/exchange'),
  headers: {
    'Content-Type': 'application/json',
    'x-tenant-id': 'your-tenant-id',
  },
  body: jsonEncode({
    'provider': 'firebase',
    'identityToken': token,
  }),
);

รับการแจ้งเตือน

เพื่อรับการแจ้งเตือนเมื่อ SDK พร้อมใช้งาน ติดตาม repository pcampus-developers (opens in a new tab) หรืออีเมล support@pcampus.co

SDKs

Official client libraries for the Pcampus Platform.

LanguageStatusPackage
JavaScript / TypeScriptComing soon@pcampus-studio/sdk
PythonPlanned
GoPlanned
Flutter / DartPlannedpcampus_sdk (pub.dev)
RustPlannedpcampus-sdk (crates.io)

The JavaScript SDK is in development (G-047). Until it ships, use the REST APIs directly — they are stable and well-documented. Flutter and Rust libraries will follow after the JS SDK ships.

Using the REST API directly

All Pcampus APIs are plain HTTP with JSON. Any HTTP client works:

# cURL
curl https://pip.pcampus.co/identity/me \
  -H "Authorization: Bearer $PIP_API_KEY"
// JavaScript — fetch (Node 18+ / browser)
const res = await fetch('https://pip.pcampus.co/identity/me', {
  headers: { Authorization: `Bearer ${process.env.PIP_API_KEY}` },
})
# Python — httpx
import httpx
r = httpx.get('https://pip.pcampus.co/identity/me',
               headers={'Authorization': f"Bearer {api_key}"})
// Flutter / Dart — http package
import 'package:http/http.dart' as http;
 
final response = await http.get(
  Uri.parse('https://pip.pcampus.co/identity/me'),
  headers: {'Authorization': 'Bearer $pipApiKey'},
);
// Rust — reqwest
use reqwest::header::{AUTHORIZATION, HeaderMap, HeaderValue};
 
let mut headers = HeaderMap::new();
headers.insert(
    AUTHORIZATION,
    HeaderValue::from_str(&format!("Bearer {}", pip_api_key))?,
);
 
let client = reqwest::Client::new();
let res = client
    .get("https://pip.pcampus.co/identity/me")
    .headers(headers)
    .send()
    .await?;

Flutter integration notes

Flutter apps using Firebase Auth can use the Connect widget via External IdP binding — see Connect — External IdP:

import 'package:firebase_auth/firebase_auth.dart';
 
// Get Firebase ID token
final token = await FirebaseAuth.instance.currentUser?.getIdToken();
 
// Send to Connect identity exchange
final res = await http.post(
  Uri.parse('https://connect-api.pcampus.co/v1/identity/exchange'),
  headers: {
    'Content-Type': 'application/json',
    'x-tenant-id': 'your-tenant-id',
  },
  body: jsonEncode({
    'provider': 'firebase',
    'identityToken': token,
  }),
);

Get notified

To be notified when SDKs ship, watch the pcampus-developers (opens in a new tab) repository or email support@pcampus.co.