API Documentation

Authentication

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

Get your API key: API Key Documentation


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

Request Body

{
  "input": {
    "html": "<h1>Hello {{ name }}</h1>",
    "data": {
      "name": "World"
    }
  }
}

Parameters

NameTypeRequiredDescription
htmlstring✓HTML content to convert to PDF
dataobject✗Template data - when provided, HTML is automatically rendered using Nunjucks template engine

Example Request

Simple HTML:

curl -X POST 'https://e.customjs.io/html2pdf' \
  -H 'x-api-key: YOUR_API_KEY' \
  -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' \
  -d '{
    "input": {
      "html": "<h1>Hello {{ name }}</h1><p>Total: {{ total }}</p>",
      "data": {
        "name": "John",
        "total": 100
      }
    }
  }' \
  > 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

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' \
  -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

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' \
  -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' \
  -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' \
  -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

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' \
  -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' \
  -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}
  ]
}

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