ePrinter

API Documentation

Use these endpoints to register the client, create print jobs (upload or URL), poll and update jobs, and query history. All responses are JSON. By default, each API key has a daily creation limit of 10 jobs (resets daily).

Quick Start: run server → run client (get apiKey) → open /dashboard/YOUR_API_KEY. Deploy to Vercel when ready.

1. Get Apikey From Apps Desktop

Description: Used by the ePrinter_client application to register itself with the server, providing its unique API key and a list of available printers.


2. Get Client Data (Web Dashboard)

Endpoint: GET /api/client/:apiKey

Description: Retrieves information about a specific client, including its status (online/offline) and registered printers. Used by the web dashboard.

cURL Example:

curl -X GET https://eprinter.fadel.web.id/api/client/your_client_api_key

URL Parameters:

  • apiKey: The unique API key of the client.

Response (JSON):

Success (200 OK):

{
    "apiKey": "string",
    "printers": ["string"],
    "lastSeen": "ISO 8601 datetime string",
    "status": "online" | "offline"
}

Error (404 Not Found):

{
    "message": "Client not found"
}

3. Create Print Job (via Web Dashboard)

Endpoint: POST /api/print

Description: Creates a new print job by uploading a PDF or image. Image files (JPG/PNG) are converted to PDF server-side before being sent to the client.

cURL Example:

curl -X POST https://eprinter.fadel.web.id/api/print \
     -H "Content-Type: multipart/form-data" \
     -F "apiKey=your_client_api_key" \
     -F "printer=Your Printer Name" \
     -F "document=@/path/to/your/file.pdf" \  # or image: .jpg/.png
     -F "paperSize=A4" \
     -F "orientation=Portrait" \
     -F "colorMode=Color"

Request Body (multipart/form-data):

  • apiKey: string (Unique API key)
  • printer: string (Name of the target printer)
  • document: file (PDF or image; images are auto-converted to PDF)
  • paperSize: string (e.g., "A4", "Letter", "Legal")
  • orientation: string (e.g., "Portrait", "Landscape")
  • colorMode: string (e.g., "Color", "Grayscale")

Response (JSON):

Success (201 Created):

{
    "message": "Print job created."
}

Error (400 Bad Request):

{
    "message": "Document file is required."
}

Error (429 Too Many Requests): daily limit reached

{
    "message": "Daily limit reached (10 jobs). Try again tomorrow."
}

4. Create Print Job (via REST API)

Endpoint: POST /api/print-raw

Description: Creates a new print job by providing a URL to a file. PDF is used as-is; supported images (JPG/PNG) are converted to PDF server-side before sending to the client.

cURL Example:

curl -X POST https://eprinter.fadel.web.id/api/print-raw \
     -H "Content-Type: application/json" \
     -d '{ 
           "apiKey": "your_client_api_key",
           "printer": "Your Printer Name",
           "documentUrl": "http://example.com/file.pdf"   # or image URL
           "paperSize": "A4",
           "orientation": "Portrait",
           "colorMode": "Color"
         }'

Request Body (JSON):

{
    "apiKey": "string",      // Unique API key of the target client
    "printer": "string",     // Name of the target printer on the client machine
    "documentUrl": "string", // URL to the PDF document (e.g., "http://example.com/document.pdf")
    "paperSize": "string",   // Optional: "A4", "Letter", "Legal" (default: "A4")
    "orientation": "string", // Optional: "Portrait", "Landscape" (default: "Portrait")
    "colorMode": "string"    // Optional: "Color", "Grayscale" (default: "Color")
}

Response (JSON):

Success (201 Created):

{
    "message": "Print job created via API.",
    "jobId": "string" // The ID of the newly created job
}

Error (400 Bad Request):

{
    "message": "apiKey, printer, and documentUrl are required."
}

or

{
    "message": "Failed to download document from [URL]"
}

Error (500 Internal Server Error):

{
    "message": "Failed to create print job via API.",
    "error": "string"
}

5. Poll for New Jobs (Client-side)

Endpoint: GET /api/jobs/:apiKey

Description: Used by the ePrinter_client to check for any pending print jobs assigned to its API key.

cURL Example:

curl -X GET https://eprinter.fadel.web.id/api/jobs/your_client_api_key

URL Parameters:

  • apiKey: The unique API key of the client.

Response (JSON):

Success (200 OK):

If a pending job is found:

{
    "jobId": "string",
    "apiKey": "string",
    "printer": "string",
    "paperSize": "string",
    "orientation": "string",
    "colorMode": "string",
    "documentName": "string", // Original filename
    "documentBase64": "string", // Base64 PDF content (delivered to client only; not persisted)
    "createdAt": "ISO 8601 datetime string",
    "status": "processing"    // Status is immediately set to 'processing' by the server
}

If no pending job is found:

null

6. Update Job Status (Client-side)

Endpoint: POST /api/jobs/:jobId/status

Description: Used by the ePrinter_client to update the status of a print job after it has been processed (printed successfully or failed).

cURL Example:

curl -X POST https://eprinter.fadel.web.id/api/jobs/your_job_id/status \
     -H "Content-Type: application/json" \
     -d '{ "status": "success", "message": "Printed successfully." }'

URL Parameters:

  • jobId: The ID of the job to update.

Request Body (JSON):

{
    "status": "success" | "failed", // The new status of the job
    "message": "string"             // Optional: A message describing the outcome (e.g., error message)
}

Response (JSON):

Success (200 OK):

{
    "message": "Job status updated."
}

Error (404 Not Found):

{
    "message": "Job not found."
}

7. Get Print History / Check Job Status (Web Dashboard & API)

Endpoint: GET /api/history/:apiKey

Description: Retrieves the print history for a specific API key. Can also be used to check the status of a single job by providing a jobId query parameter.

cURL Example (Get all history):

curl -X GET https://eprinter.fadel.web.id/api/history/your_client_api_key

cURL Example (Get specific job status):

curl -X GET https://eprinter.fadel.web.id/api/history/your_client_api_key?jobId=your_job_id

URL Parameters:

  • apiKey: The unique API key of the client.

Query Parameters:

  • jobId: string (Optional) - If provided, returns details for this specific job.

Response (JSON):

If jobId query parameter is provided and found (200 OK):

{
    "jobId": "string",
    "apiKey": "string",
    "printer": "string",
    "paperSize": "string",
    "orientation": "string",
    "colorMode": "string",
    "documentName": "string",
        "createdAt": "ISO 8601 datetime string",
    "status": "pending" | "processing" | "success" | "failed",
    "completedAt": "ISO 8601 datetime string", // Present if job is completed
    "message": "string"                       // Present if job is completed
}

If jobId query parameter is provided but not found (404 Not Found):

{
    "message": "Job not found for this API Key."
}

If no jobId query parameter is provided (200 OK):

[
    {
        "jobId": "string",
        "apiKey": "string",
        "printer": "string",
        "paperSize": "string",
        "orientation": "string",
        "colorMode": "string",
        "documentName": "string",
                "createdAt": "ISO 8601 datetime string",
        "status": "pending" | "processing" | "success" | "failed",
        "completedAt": "ISO 8601 datetime string",
        "message": "string"
    },
    // ... more job objects
]

8. Reprint Job (Web Dashboard)

Endpoint: POST /api/reprint/:jobId

Description: Creates a new print job referencing the same document as an existing job. Reprints count toward the daily limit.

Response:

{ "message": "Job queued for reprint." }

Error: 404 if job not found; 429 if daily limit reached.


ePrinter Server • API v1