💬 LanguageChat APIv1
Real-time messaging and video
Messages
Retrieve message history for a session
// Node.js (Express backend example)
const express = require("express");
const app = express();
const NL_API_KEY = process.env.NOWLANGUAGE_API_KEY;
app.get("/book-interpreter", async (req, res) => {
const response = await fetch("https://api.nowlanguage.com/v1/chat/rooms/{sessionId}/messages", {
method: "GET",
headers: {
"Authorization": "Bearer " + NL_API_KEY,
"Content-Type": "application/json"
}
});
const data = await response.json();
res.json(data);
});Send a text message in a session. ## Translation Set `translate: true` to automatically translate the message to the other participant's language.
// Node.js (Express backend example)
const express = require("express");
const app = express();
const NL_API_KEY = process.env.NOWLANGUAGE_API_KEY;
app.get("/book-interpreter", async (req, res) => {
const response = await fetch("https://api.nowlanguage.com/v1/chat/rooms/{sessionId}/messages", {
method: "POST",
headers: {
"Authorization": "Bearer " + NL_API_KEY,
"Content-Type": "application/json"
}
});
const data = await response.json();
res.json(data);
});Rooms
Initialize or join a video call for the session
// Node.js (Express backend example)
const express = require("express");
const app = express();
const NL_API_KEY = process.env.NOWLANGUAGE_API_KEY;
app.get("/book-interpreter", async (req, res) => {
const response = await fetch("https://api.nowlanguage.com/v1/chat/rooms/{sessionId}/video", {
method: "POST",
headers: {
"Authorization": "Bearer " + NL_API_KEY,
"Content-Type": "application/json"
}
});
const data = await response.json();
res.json(data);
});Transcripts
Retrieve the full transcript of a completed session. Available formats: - `json` - Structured message data - `text` - Plain text transcript - `pdf` - Formatted PDF document
// Node.js (Express backend example)
const express = require("express");
const app = express();
const NL_API_KEY = process.env.NOWLANGUAGE_API_KEY;
app.get("/book-interpreter", async (req, res) => {
const response = await fetch("https://api.nowlanguage.com/v1/chat/rooms/{sessionId}/transcripts", {
method: "GET",
headers: {
"Authorization": "Bearer " + NL_API_KEY,
"Content-Type": "application/json"
}
});
const data = await response.json();
res.json(data);
});Real-time
Get WebSocket connection details for real-time updates. ## Events | Event | Description | |-------|-------------| | `message.new` | New message received | | `message.translated` | Translation completed | | `typing.start` | User started typing | | `typing.stop` | User stopped typing | | `participant.joined` | User joined room | | `participant.left` | User left room | | `video.started` | Video call started | | `video.ended` | Video call ended | ## Connection Example ```javascript const ws = new WebSocket('wss://realtime.nowlanguage.com'); ws.send(JSON.stringify({ type: 'subscribe', channel: 'session:sess_abc123', token: 'your_token' })); ws.onmessage = (event) => { const data = JSON.parse(event.data); console.log('Event:', data.type, data.payload); }; ```
// Node.js (Express backend example)
const express = require("express");
const app = express();
const NL_API_KEY = process.env.NOWLANGUAGE_API_KEY;
app.get("/book-interpreter", async (req, res) => {
const response = await fetch("https://api.nowlanguage.com/v1/chat/connect", {
method: "GET",
headers: {
"Authorization": "Bearer " + NL_API_KEY,
"Content-Type": "application/json"
}
});
const data = await response.json();
res.json(data);
});