SDKs & LibrariesQuick Start
SDK v1.4Enterprise DX
Quick Start
Official xaqiiji-sdk npm package and REST guides aligned with the live Xaqiiji API.
1. Install
npm
npm install xaqiiji-sdk2. Set environment variables
.env
XAQIIJI_API_KEY=xq_test_xxxxxxxxxxxxxx# Optional — defaults to https://xaqiiji-api.ahmed-dalab.comXAQIIJI_BASE_URL=https://xaqiiji-api.ahmed-dalab.com3. Verify a citizen
TypeScript
import { Xaqiiji } from "xaqiiji-sdk";const client = new Xaqiiji({ apiKey: process.env.XAQIIJI_API_KEY!, environment: "test", // use "live" with xq_live_* keys});const result = await client.verify.citizen( { nationalId: "12345678901", purpose: "pre_employment", }, { idempotencyKey: "verify-2026-06-02-001" },);console.log(result.result); // verified | not_found | expired | ...console.log(result.reference); // certificate reference numberconsole.log(result.isCached); // true when replayed within idempotency windowconsole.log(result.citizen?.fullName);4. List verification history
TypeScript
const history = await client.verify.list({ page: 1, limit: 10 });console.log(history.data.length);console.log(history.pagination.totalDocs);5. Handle errors
TypeScript
import { XaqiijiAuthError, XaqiijiInsufficientCreditsError, XaqiijiInvalidFormatError, XaqiijiRateLimitError,} from "xaqiiji-sdk";try { await client.verify.citizen({ nationalId: "12345678901", purpose: "pre_employment", });} catch (err) { if (err instanceof XaqiijiInsufficientCreditsError) { // Top up credits in the business portal } else if (err instanceof XaqiijiInvalidFormatError) { // National ID must be exactly 11 digits } else if (err instanceof XaqiijiAuthError) { // Missing, invalid, or revoked API key } else if (err instanceof XaqiijiRateLimitError) { // Back off using err.retryAfter (seconds) } else { throw err; }}Response fields
SDK response
result.result // verified | not_found | expired | service_unavailableresult.reference // certificate reference numberresult.isCached // true when idempotent replayresult.creditDeducted // whether a credit was usedresult.citizen // NIRA profile when availableREST alternative
cURL
curl -X POST http://localhost:8080/api/v1/verify/citizen -H "Authorization: Bearer xq_test_xxx" -H "Content-Type: application/json" -H "Idempotency-Key: verify-2026-06-02-001" -d '{"nationalId":"12345678901","purpose":"pre_employment"}'Edit this page
Was this page helpful?