API reference

The browser SDK, the embed frame and the in-page window.eeshgarg API: functions, arguments, results, errors and versions.

There are four ways to run the site's processing from code. They run in different places, so pick by where your code runs.

  • Building a web page that processes files: use the browser SDK.
  • Trying something in the console on eeshgarg.com: use window.eeshgarg.
  • Running a saved chain of tools: use the workflow runtime.
  • Batch jobs on your own computer: use the command line.
SurfaceWhere it runsUse it for
Browser SDK (/sdk/v1/eeshgarg-sdk.mjs)Your page, plus a hidden frame on eeshgarg.com that does the work on the user's deviceYour own web app that processes files the user picks
window.eeshgargThe eeshgarg.com tab itselfThe browser console and quick scripts on the site
Workflow runtimeInside the SDK or the site, in the browserRunning a saved workflow graph (JSON)
Command lineYour computer, with NodeBatch jobs in scripts (see CLI and scripting)

There is no remote HTTP processing endpoint. The site does not accept files by HTTP request, and no server processes your files. Any page that sends a file to a URL on this site to get it converted is not using an eeshgarg API.

Browser SDK

The SDK is one dependency-free ES module, /sdk/v1/eeshgarg-sdk.mjs, version 1.0.0 (wire protocol 1). It has no build step. Import it from your page:

import { createClient, SdkError } from "https://eeshgarg.com/sdk/v1/eeshgarg-sdk.mjs";

const client = await createClient({ origin: "https://eeshgarg.com", timeoutMs: 120000 });
const { files } = await client.run("feature:text-transform", [file], { op: "upper" });

createClient(options) opens a hidden frame at {origin}/embed/v1/ and resolves once the frame says it is ready. Options: origin (default https://eeshgarg.com; must be https, or http for localhost, 127.0.0.1 or [::1] for local testing) and timeoutMs (the handshake and each call; default 120000). It rejects with frame_unavailable if the frame does not answer, or incompatible if the frame speaks another protocol.

Methods

client.version, client.apiVersion, client.origin, client.frameUrl
The SDK version, the scripting API version reported by the frame (currently 2.1.0), and where the frame is.
listCapabilities()
Every tool and feature op: [{ id, title, category, accept, defaults, options }]. Use it to find the id to pass to run; the ids match the catalog.
describe(id)
One entry in full, with kind ("tool" or "feature") and a description when it has one.
validateWorkflow(definition)
Returns { ok, errors, converted }. It does not run the workflow and does not reject for invalid input.
run(id, files, options?, { signal?, onProgress? })
Runs one tool or feature op. Resolves to { files: [{ name, type, bytes }], summary, warnings }, where bytes is a Uint8Array. onProgress({ done, total, label }) is called while it runs.
runWorkflow(definition, files, { signal?, onNode? })
Runs a workflow (a version 2 object, a version 1 pipeline, or JSON text of either). Resolves to { status, files, outputs, nodes }. onNode({ id, type, status, message }) fires on each change. See Workflow semantics.
checkCompatibility()
What the frame's browser supports: { ok, missing, features, protocol, apiVersion, sdkVersion }.
dispose()
Removes the frame and rejects every pending call with frame_unavailable. Call it when your page is done with the client.

Files

A file is a File, a Blob with a name, or { name, bytes } where bytes is a Uint8Array or ArrayBuffer. The SDK copies your bytes, so your objects stay usable after a run. A request takes at most 25 files, 64 MiB per file and 128 MiB in total. Output files come back as plain objects with name, type and bytes.

Results

A run resolves to { files, summary, warnings }. Each output file has name, type and bytes. The type comes from the file extension (.pdf is application/pdf, .txt is text/plain), and an unknown extension is application/octet-stream. The number of output files and their names are set by each operation, and the capability list does not declare them yet, so read files.length and files[i].name. ArunWorkflow result lists its outputs as outputs: [{ id, files }], one entry per output block.

Errors

Every method rejects with an SdkError whose code is one of these:

CodeMeaning
bad_requestThe request is malformed, or a workflow is invalid (then errors lists each problem).
unknown_opNo tool or feature op has that id. Call listCapabilities().
bad_optionsAn option name is unknown or has the wrong kind or value.
bad_filesThe file count, a file type, a name or a size is not accepted by that tool, or the operation refused the file's content (for example a conversion target that file cannot take, or a damaged file). The message says which.
abortedThe signal was aborted. The client sends a cancel to the frame.
timeoutA call did not finish within timeoutMs. It is cancelled.
frame_unavailableThe frame did not load or answer, or the client was disposed.
incompatibleThe frame and the SDK speak different wire protocols.
internalSomething failed inside the frame. The message does not include file contents.

Operation contract

Every operation, whether a tool or a feature op (ids starting feature:), is described by one live entry, so the list below cannot go out of date. Call listCapabilities() (SDK) or listTools() (on the site) for all of them, or describe(id) for one. Each entry gives:

  • id, title and category: the id is what you pass to run.
  • accept: types (the file kinds it takes; any means any file), min, max when set, and multiple (false means exactly one file).
  • options: each option's name, type (string, number, boolean, array or object), default and, for a pick-one option, choices. Every option is optional: whatever you leave out takes its default.

Rules that hold for every operation. An option you pass must be one the entry lists, with the same kind as its default and, where choices is given, one of them; otherwise the call fails with bad_options before any file is read. The wrong number of files, or a file of a kind the operation does not take, fails with bad_files. An operation that takes several files (multiple not false) treats them as one batch and returns its own set of output files; a tool that takes one file runs once per call, so loop over your files for a batch. A workflow runs the same operations, one block per call. Aborting the signal before the call starts rejects it with aborted and runs nothing.

onProgress is reported by tools that process in steps. Feature ops do not report progress; they only resolve when done. Output file names and counts are chosen by each operation (see Results above).

Not part of the contract. Only the methods on this page are supported. The modules behind them (src/api/index.js, the worker, the engine functions, the stored settings, and anything you can reach by inspecting the site) are internal and can change at any time without a version bump.

The embed frame

Third-party pages cannot run the site's worker and WebAssembly code directly: module workers and most WASM loads must come from the same origin as the page. So the SDK talks to /embed/v1/, a page on eeshgarg.com with no interface, no header and no stored settings. The frame answers only its parent window and replies to the parent's origin. Processing does not read or write localStorage or IndexedDB. The one storage read on the run path is the statistics opt-in flag, and only in a build that sets a statistics endpoint; the flag is off unless the user turns it on, and nothing is sent without it. Files are moved to the frame as transferred buffers and come back the same way. Processing stays on the user's device.

The frame is the only page on the site that may be framed by other sites (frame-ancestors *). Every other page still sends frame-ancestors 'none'. Usage counting is off unless the site is configured and the user opts in; see Statistics.

window.eeshgarg (on the site)

On eeshgarg.com itself, window.eeshgarg has version, listTools, describe, runTool, runWorkflow, relatedTools, exportWorkflowHtml and parseWorkflowLink. They run in the page's own origin, so they need no frame. The module behind them is the scripting API (src/api/index.js); the function signatures are the same as the SDK's, without the client.

relatedTools(idOrRoute)
The pages connected to one tool, from the same data as the Related strip: { id, route, title, docs, api, workflowOp, related }, with at most 6 related entries.
exportWorkflowHtml(definition, { name?, usage? })
A workflow as one self-contained .html file: { fileName, html, importUrl }. The file makes no requests; its import link carries the workflow in the URL fragment, which no server sees.
parseWorkflowLink(linkOrHash)
Reads the workflow from an import link or its #import= fragment: { ok, name, graph, errors }. Never throws.

Versions and pinning

  • The SDK path carries the major version: /sdk/v1/. Additive changes stay in v1 (SDK 1.x). A breaking change gets a new path, /sdk/v2/, and v1 stays served.
  • Pin the path you test against, and call client.apiVersion to see what the frame runs.
  • The wire protocol is checked on every connection. A different number fails with incompatible, so a mismatch cannot silently produce wrong output.
  • Workflow definitions carry a version (2 for graphs; 1 pipelines are converted on import).

CORS, CSP, isolation

  • CORS. /sdk/* sends Access-Control-Allow-Origin: * and Cross-Origin-Resource-Policy: cross-origin, so any page can import the module.
  • CSP. The site's policy is default-src 'self' with script-src 'self' 'wasm-unsafe-eval'. Your page's own CSP must allow frame-src https://eeshgarg.com (or the origin you use) and script-src https://eeshgarg.com for the module.
  • Isolation. The site sends Cross-Origin-Opener-Policy: same-origin but not a cross-origin embedder policy, so the site is not cross-origin isolated. The processing code does not use SharedArrayBuffer, so the SDK does not need isolation, and your page does not need to set it.
  • Frame. The frame's policy is the same, except that it may be framed by any origin. It allows wasm-unsafe-eval and blob: workers, which the engine uses.

Limits and what is not guaranteed

  • A workflow JSON is at most 256 KB (UTF-8), with at most 100 nodes and 200 edges, and at most 32 levels of nesting.
  • Cancellation aborts the run's signal in the frame. An operation stops when it checks that signal, and not every operation checks it often. The time from cancel to stop has not been measured for every operation.
  • The frame loads the site's application code from eeshgarg.com. Your page depends on eeshgarg.com being reachable; the SDK has no offline mode.
  • Some operations use third-party engines. The FFmpeg build is GPL-licensed and loaded only by media operations. Its source offer is in licences.
  • The SDK is source available, not open source. You may use, modify and share it under its licence: keep the licence with any copy, and do not use it against your users. Permission can be withdrawn from anyone who abuses it.
  • Nothing here is a server API. You cannot send a file to eeshgarg.com and receive the output over HTTP.