Skip to content
</> CODE RECIPES

Integration examples: Node.js, Python and PHP

Real read-only REST examples that run on your server. They do not need user cookies or hard-coded account credentials.

Current capabilities only — admin-issued scoped API keys; first-party WebSocket only

Node.js 24+

Read and validate the room listing, then apply caching and rate limiting appropriate for your own traffic.

JavaScript
// Node.js 24+. Run on your own server, not in a cross-origin browser script.
const response = await fetch('https://chat.egytag.com/api/rooms', {
  headers: { Accept: 'application/json' },
  signal: AbortSignal.timeout(8000)
});
if (!response.ok) throw new Error(`Chat Live HTTP ${response.status}`);
const data = await response.json();
if (!data.ok || !Array.isArray(data.rooms)) throw new Error('Bad response');
const rooms = data.rooms.filter(r => !r.private && !r.hidden);
console.log(rooms.map(r => ({ title: r.title, slug: r.slug, online: r.online })));

Python requests

First run pip install requests. The example lists rooms marked joinable by discovery.

Python
# Python 3, requires: pip install requests
import requests
url = 'https://chat.egytag.com/api/discovery'
response = requests.get(url, timeout=8)
response.raise_for_status()
data = response.json()
if not data.get('ok'):
    raise RuntimeError('Chat Live discovery failed')
for room in data.get('rooms', []):
    if room.get('joinable') and room.get('slug'):
        print(room['title'], room['slug'], room.get('online', 0))

PHP with cURL

Requires the PHP cURL extension. Check HTTP errors and HTML-escape any text you render.

PHP
<?php
// Server-side PHP (with cURL enabled).
$ch = curl_init('https://chat.egytag.com/api/rooms');
curl_setopt_array($ch, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 8,
  CURLOPT_HTTPHEADER => ['Accept: application/json'],
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($body === false || $status !== 200) {
  throw new RuntimeException('Chat Live API request failed');
}
$data = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
foreach (($data['rooms'] ?? []) as $room) {
  if (empty($room['private']) && empty($room['hidden'])) {
    echo htmlspecialchars($room['title'], ENT_QUOTES, 'UTF-8') . "\n";
  }
}

Move from discovery to the room

Use the validated slug to navigate to the official Chat Live room URL. Avoid copying the sign-in flow or extracting user cookies on another origin.

JavaScript
// Your backend returns the official URL; it does NOT proxy user messages.
function officialRoomLink(slug, lang = 'ar') {
  if (!/^[a-z0-9-]{1,80}$/.test(slug)) throw Error('Invalid slug');
  return `https://chat.egytag.com/${lang === 'en' ? 'en' : 'ar'}/room/${slug}`;
}