var https = require("https"); var path = require("path"); var fs = require("fs"); // The authentication key (API Key). // Get your own by registering at https://app.pdf.co const API_KEY = "***********************************"; const jobId = "{your_job_id}"; let queryPath = `/v1/job/check`; // JSON payload for api request let jsonPayload = JSON.stringify({ jobid: jobId }); let reqOptions = { host: "api.pdf.co", path: queryPath, method: "POST", headers: { "x-api-key": API_KEY, "Content-Type": "application/json", "Content-Length": Buffer.byteLength(jsonPayload, 'utf8') } }; // Send request var postRequest = https.request(reqOptions, (response) => { response.on("data", (d) => { response.setEncoding("utf8"); // Parse JSON response let data = JSON.parse(d); console.log(`Checking Job #${jobId}, Status: ${data.status}, Time: ${new Date().toLocaleString()}`); if (data.status == "success") { console.log(`Job success!`); } else { console.log(`Operation ended with status: "${data.status}".`); } }) });
import osimport requests # pip install requests# The authentication key (API Key).# Get your own by registering at https://app.pdf.coAPI_KEY = "******************************************"jobId = "******************************************"# Base URL for PDF.co Web API requestsBASE_URL = "https://api.pdf.co/v1"url = f"{BASE_URL}/job/check?jobid={jobId}"response = requests.get(url, headers={ "x-api-key": API_KEY })if (response.status_code == 200): json = response.json() return json["status"]else: print(f"Request error: {response.status_code} {response.reason}")
package com.company;import com.google.gson.JsonObject;import com.google.gson.JsonParser;import com.google.gson.JsonPrimitive;import okhttp3.*;public class Main{ // The authentication key (API Key). // Get your own by registering at https://app.pdf.co final static String API_KEY = "***********************************"; public static void main(String[] args) throws IOException { // Prepare POST request body in JSON format JsonObject jsonBody = new JsonObject(); jsonBody.add("jobid", new JsonPrimitive(jobId)); RequestBody body = RequestBody.create(MediaType.parse("application/json"), jsonBody.toString()); // Prepare request to `Job Check` API Request request = new Request.Builder() .url("https://api.pdf.co/v1/job/check") .addHeader("x-api-key", API_KEY) // (!) Set API Key .addHeader("Content-Type", "application/json") .post(body) .build(); // Execute request Response response = webClient.newCall(request).execute(); }}