API Documentation

Authentication

All API requests require authentication via the x-api-key header.

Get your API key: API Key Documentation

All API responses include rate limit headers (x-ratelimit-limit, x-ratelimit-used, x-ratelimit-remaining). See Rate Limiting for details.


Available Endpoints

EndpointDescriptionDocumentation
POST /html2pdfConvert HTML to PDF with optional Nunjucks templatingHTML to PDF
POST /markdown2pdfConvert Markdown to PDFMarkdown to PDF
POST /screenshotCapture website screenshots with automationScreenshot API
POST /scraperScrape HTML content from websitesHTML Scraper
POST /__js1-Execute custom JavaScript codeJavaScript Execution
POST /pages/page/upsert-htmlHost and deploy HTML pagesHTML Pages API

PDF Generator API

POST /html2pdf

https://e.customjs.io/html2pdf

Converts HTML to PDF with optional template rendering using Nunjucks.

Headers

NameTypeRequiredDescription
x-api-keystring✓Your API key
Content-Typestring✓Must be application/json

Request Body

{
  "input": {
    "html": "<h1>Hello {{ name }}</h1>",
    "data": {
      "name": "World"
    },
    "config": {
      "pdfWidthMm": 210,
      "pdfHeightMm": 297
    }
  }
}

Parameters

NameTypeRequiredDescription
htmlstring✓HTML content to convert to PDF
dataobject✗Template data - when provided, HTML is automatically rendered using Nunjucks template engine
configobject✗Optional configuration object
config.pdfWidthMmnumber✗PDF page width in millimeters. Defaults to A4 (210) when omitted
config.pdfHeightMmnumber✗PDF page height in millimeters. Defaults to A4 (297) when omitted

Example Request

Simple HTML:

curl -X POST 'https://e.customjs.io/html2pdf' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "input": {
      "html": "<h1>Hello World</h1>"
    }
  }' \
  > output.pdf

With Template Data:

curl -X POST 'https://e.customjs.io/html2pdf' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "input": {
      "html": "<h1>Hello {{ name }}</h1><p>Total: {{ total }}</p>",
      "data": {
        "name": "John",
        "total": 100
      },
      "config": {
        "pdfWidthMm": 150,
        "pdfHeightMm": 150
      }
    }
  }' \
  > output.pdf

Response

Content-Type: application/pdf

Returns binary PDF data.


POST /markdown2pdf

https://e.customjs.io/markdown2pdf

Converts Markdown to PDF.

Headers

NameTypeRequiredDescription
x-api-keystring✓Your API key
Content-Typestring✓Must be application/json

Request Body

{
  "input": {
    "markdown": "# Hello World\n\nThis is **bold** text."
  }
}

Parameters

NameTypeRequiredDescription
markdownstring✓Markdown content to convert to PDF

Example Request

curl -X POST 'https://e.customjs.io/markdown2pdf' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "input": {
      "markdown": "# Hello World\n\nThis is **bold** text."
    }
  }' \
  > output.pdf

Response

Content-Type: application/pdf

Returns binary PDF data.


Screenshot API

POST /screenshot

https://e.customjs.io/screenshot

Captures a screenshot of a web page with optional automation commands and custom viewport.

Headers

NameTypeRequiredDescription
x-api-keystring✓Your API key
Content-Typestring✓Must be application/json

Request Body

{
  "input": {
    "url": "https://example.com",
    "commands": [],
    "box": {
      "x": 0,
      "y": 0,
      "width": 1200,
      "height": 800
    }
  }
}

Parameters

NameTypeRequiredDescription
urlstring✓The URL of the page to screenshot
commandsarray✗Array of automation commands to execute before taking the screenshot (e.g., click, scroll, wait, type)
boxobject✗Bounding box coordinates for partial screenshots (only applied if width > 0 and height > 0)
box.xnumber✗X-coordinate of the top-left corner
box.ynumber✗Y-coordinate of the top-left corner
box.widthnumber✗Width of the screenshot area
box.heightnumber✗Height of the screenshot area

Example Request

Full Page Screenshot:

curl -X POST 'https://e.customjs.io/screenshot' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "input": {
      "url": "https://example.com",
      "commands": []
    }
  }' \
  > output.png

With Automation Commands:

curl -X POST 'https://e.customjs.io/screenshot' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "input": {
      "url": "https://example.com",
      "commands": [
        {"action": "click", "selector": "#accept-cookies"},
        {"action": "wait", "value": 1000},
        {"action": "scroll", "value": 500}
      ]
    }
  }' \
  > output.png

Custom Viewport Screenshot:

curl -X POST 'https://e.customjs.io/screenshot' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "input": {
      "url": "https://example.com",
      "commands": [],
      "box": {
        "x": 0,
        "y": 0,
        "width": 1200,
        "height": 800
      }
    }
  }' \
  > output.png

Response

Content-Type: image/png

Returns binary PNG image data.


HTML Scraper API

POST /scraper

https://e.customjs.io/scraper

Scrapes HTML content from a web page with optional automation commands.

Headers

NameTypeRequiredDescription
x-api-keystring✓Your API key
Content-Typestring✓Must be application/json

Request Body

{
  "input": {
    "url": "https://example.com",
    "commands": []
  }
}

Parameters

NameTypeRequiredDescription
urlstring✓The URL of the page to scrape
commandsarray✗Array of automation commands to execute before scraping (e.g., click, scroll, wait, type)

Example Request

Simple Scraping:

curl -X POST 'https://e.customjs.io/scraper' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "input": {
      "url": "https://example.com",
      "commands": []
    }
  }' \
  > output.html

With Automation Commands:

curl -X POST 'https://e.customjs.io/scraper' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "input": {
      "url": "https://example.com",
      "commands": [
        {"action": "click", "selector": "button.load-more"},
        {"action": "wait", "value": 2000},
        {"action": "type", "selector": "input#search", "value": "CustomJS"}
      ]
    }
  }' \
  > output.html

Response

Content-Type: text/html

Returns HTML content as text.


Automation Commands

The commands parameter accepts an array of automation actions that are executed before taking a screenshot or scraping HTML. Each command is an object with the following structure:

Available Commands

ActionParametersDescriptionExample
clickselectorClick on an element{"action": "click", "selector": "#button"}
typeselector, valueType text into an input field{"action": "type", "selector": "#search", "value": "text"}
scrollvalueScroll down by pixels{"action": "scroll", "value": 500}
waitvalueWait for milliseconds{"action": "wait", "value": 1000}
waitForSelectorselectorWait for element to appear{"action": "waitForSelector", "selector": ".content"}
hoverselectorHover over an element{"action": "hover", "selector": ".menu-item"}

Example Command Sequence

{
  "commands": [
    {"action": "waitForSelector", "selector": "#content"},
    {"action": "click", "selector": "#accept-cookies"},
    {"action": "wait", "value": 1000},
    {"action": "type", "selector": "input#search", "value": "CustomJS"},
    {"action": "click", "selector": "button[type='submit']"},
    {"action": "wait", "value": 2000},
    {"action": "scroll", "value": 500}
  ]
}

JavaScript Execution API

POST /__js1-

https://e.customjs.io/__js1-

Execute custom JavaScript code with input data and access to available NPM modules.

Headers

NameTypeRequiredDescription
x-api-keystring✓Your API key
Content-Typestring✓Must be application/json

Request Body

{
  "input": "{\"name\":\"Jon Doe\"}",
  "code": "return input.name"
}

Parameters

NameTypeRequiredDescription
inputstring✓Input data for your code. Can be a simple value (e.g., "34324") or an escaped JSON string (e.g., "{\"name\":\"Jon Doe\"}")
codestring✓JavaScript code to execute. Use input to access the parsed input data

Example Request

curl -X POST 'https://e.customjs.io/__js1-' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "input": "{\"name\":\"Jon Doe\"}",
    "code": "return input.name"
  }'

Response

Returns the result of the executed JavaScript code.


Available NPM Modules

The following NPM modules are available for use in CustomJS. Contact us if you would like to use another NPM module.

const cheerio = require('cheerio');
const { v4: uuidv4 } = require('uuid');
const axios = require('axios').default;
const AWS = require('@aws-sdk/client-s3'); // Typically you import specific AWS services
const jsrsasign = require('jsrsasign');
const forge = require('node-forge'); // Package is typically called 'node-forge'
const { piexif } = require('piexifjs');
const jsrsasignUtil = require('jsrsasign-util');
const jsonwebtoken = require('jsonwebtoken');
const crypto = require('crypto');
const { Configuration, OpenAIApi } = require('openai');
const JavaScriptObfuscator = require('javascript-obfuscator');
const { AuthRocket } = require('@authrocket/authrocket-node');
const firebaseAdmin = require('firebase-admin');
const { PDFDocument, StandardFonts, rgb } = require('pdf-lib');
const mysql2 = require('mysql2');
const cryptoJs = require('crypto-js');
const nodemailer = require('nodemailer');
const converter = require('json-2-csv');
const htmlToText = require('html-to-text');
const moment = require('moment');
const Alexa = require('ask-sdk-core');
const jose = require('jose');
const { nanoid } = require('nanoid');
const { getJson } = require('serpapi');
const { Storage } = require('@google-cloud/storage');

HTML Pages API

The HTML Pages API allows you to host, deploy, and manage HTML pages. You can create, update, retrieve, and delete HTML pages using a different base domain.

Base URL: https://api.app.customjs.io

POST /pages/page/upsert-html

https://api.app.customjs.io/pages/page/upsert-html

Create or update an HTML page. If a page with the specified name already exists, it will be updated; otherwise, a new page will be created.

Headers

NameTypeRequiredDescription
x-api-keystring✓Your API key

Request Body

{
  "name": "my-landing-page",
  "htmlContent": "<!DOCTYPE html><html><head><title>My Page</title></head><body><h1>Hello World</h1></body></html>",
  "slug": "custom-url-slug"
}

Parameters

NameTypeRequiredDescription
namestring✓Unique identifier for the HTML page. If a page with this name already exists, it will be updated; otherwise a new page will be created
htmlContentstring✓HTML content to host (max 10MB)
slugstring✗Custom URL slug (lowercase letters, numbers, and hyphens only, 3-100 characters)

Example Request

curl -X POST 'https://api.app.customjs.io/pages/page/upsert-html' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "my-landing-page",
    "htmlContent": "<!DOCTYPE html><html><head><title>My Page</title></head><body><h1>Hello World</h1></body></html>",
    "slug": "my-custom-page"
  }'

Response

Content-Type: application/json

{
  "pageId": "abc123",
  "htmlFileUrl": "https://...",
  "name": "my-landing-page",
  "message": "Page created successfully",
  "created": true
}
FieldTypeDescription
pageIdstringUnique identifier for the page
htmlFileUrlstringURL where the HTML page is hosted
namestringName of the page
messagestringSuccess message
createdbooleantrue if a new page was created, false if an existing page was updated

GET /pages/api/page

https://api.app.customjs.io/pages/api/page

Retrieve all HTML pages for your workspace.

Headers

NameTypeRequiredDescription
x-api-keystring✓Your API key

Example Request

curl -X GET 'https://api.app.customjs.io/pages/api/page' \
  -H 'x-api-key: YOUR_API_KEY'

Response

Content-Type: application/json

Returns an array of page objects.


GET /pages/api/page/id/{pageId}

https://api.app.customjs.io/pages/api/page/id/{pageId}

Retrieve a specific HTML page by its ID.

Headers

NameTypeRequiredDescription
x-api-keystring✓Your API key

Path Parameters

NameTypeRequiredDescription
pageIdstring✓The unique identifier of the page

Example Request

curl -X GET 'https://api.app.customjs.io/pages/api/page/id/abc123' \
  -H 'x-api-key: YOUR_API_KEY'

Response

Content-Type: application/json

Returns the page object with full details.


DELETE /pages/api/page/id/{pageId}

https://api.app.customjs.io/pages/api/page/id/{pageId}

Delete a specific HTML page by its ID.

Headers

NameTypeRequiredDescription
x-api-keystring✓Your API key

Path Parameters

NameTypeRequiredDescription
pageIdstring✓The unique identifier of the page to delete

Example Request

curl -X DELETE 'https://api.app.customjs.io/pages/api/page/id/abc123' \
  -H 'x-api-key: YOUR_API_KEY'

Response

Content-Type: application/json

Returns a success message confirming the deletion.


Rate Limiting

All API endpoints include rate limit information in the response headers:

HeaderDescription
x-ratelimit-limitMaximum number of requests allowed per time window (e.g., 500)
x-ratelimit-usedNumber of requests used in the current time window
x-ratelimit-remainingNumber of requests remaining in the current time window

Example Response Headers:

x-ratelimit-used: 294
x-ratelimit-remaining: 206
x-ratelimit-limit: 500

Error Responses

All APIs return standard HTTP status codes:

Status CodeDescription
200✓ Success
400✗ Bad Request - Invalid parameters
401✗ Unauthorized - Invalid API key
500✗ Internal Server Error