Skip to content

WebSockets

To receive real-time updates for your tasks and jobs, you can use the Freeconvert.me WebSockets API. The hostname for WebSocket updates is notification.freeconvert.me. Socket.io clients are available in Javascript and many other languages. See API code examples.

To join a channel, you must authorize using the Authorization: Bearer API_KEY as shown below.

const socket = io("https://notification.freeconvert.me/", {
  transports: ["websocket"],
  path: "/socket.io",
  auth: { token: `Bearer ${YOUR_TOKEN_HERE}` },
});
//for subscribe job and task
socket.emit("subscribe", `job.{jobId}`);
socket.emit("subscribe", `task.{taskId}`);

//for unsubscribe job and task
socket.emit("unsubscribe", `job.{jobId}`);
socket.emit("unsubscribe", `task.{taskId}`);

socket.on("task_started", (data) => {
  console.log("task_started", data);
});

socket.on("job_started", (data) => {
  console.log("job_started", data);
});

Note:

When you initiate a job with the Create job API, you can receive real-time updates for your tasks and jobs via WebSockets. In rare cases, an export job may complete before you have subscribed to the WebSocket. To avoid this, call the Show job API once after subscribing to check whether the job has already finished.

The recommended approach is to check whether the socket returns the expected url value immediately after subscribing. If it does not, call the Show job API once and check the value manually. If the GET API does not return the url, the job is still processing.

Websocket Channels & Events

Channel description available events
job.{jobId} Job update events job_started job_failed job_completed
task.{taskId} All task-related events task_started task_completed task_failed task_min_update
user.{userId}.jobs User job-related events job_started job_failed job_completed
user.{userId}.tasks User task-related events task_started task_completed task_failed task_min_update