FILE API

convert

Convert files between common formats. Supports PDF, DOCX, XLSX, JSON, CSV, XML, Markdown, HTML and more. See additional info for the full list of supported conversions.
Credits Required: 2.0

PARAMETERS

NAME TYPE REQUIRED DESCRIPTION ADDITIONAL CREDITS PER ITEM EXAMPLE
file string Yes Base64 encoded file content (max 10MB) None
base64_encoded_file_content_here
input_format string Yes Source file format (json, csv, xml, markdown, html, pdf, docx, xlsx) None
json
output_format string Yes Target file format (json, csv, xml, html, markdown, txt, pdf, jpg, png, xlsx) None
csv
csv_delimiter string No Delimiter character for CSV operations (default: ",") None
,
pdf_resolution int No DPI resolution for PDF to image conversion (72-600, default: 150) None
150
pdf_page int No Page number for PDF to image conversion. 0 = all pages (default: 0) None
0

RESPONSE EXAMPLE

{
    "status": "success",
    "message": "File converted successfully",
    "data":
    {
        "file": "base64_encoded_result_file",
        "output_format": "csv"
    }
}

ADDITIONAL INFO

Supported conversions:
- PDF -> JPG, PNG (image rendering), TXT (text extraction)
- DOCX -> TXT (text extraction), PDF, HTML
- XLSX -> CSV, JSON
- JSON -> CSV, XML, XLSX
- CSV -> JSON, XML, XLSX
- XML -> JSON, CSV
- Markdown -> HTML
- HTML -> Markdown, Plain Text (txt)

Notes:
- PDF to image: set pdf_resolution (72-600 DPI) and pdf_page (0 for all pages). Max 50 pages.
- For multi-page PDF to image, response contains "files" array and "pages_count" instead of "file"
- DOCX to PDF works best with simple text documents
- XLSX reads the first/active sheet
- JSON for XLSX/CSV operations must be an array of objects with consistent keys
- CSV files must include a header row

CODE EXAMPLES

<?php

// ================================================================
// Generic function - copy once, reuse for all APIs
// ================================================================
function processAPIRequest($endpoint, $PostFields)
{
    $token = 'YOUR_API_TOKEN_HERE'; // Configure your token here
    $base_url = 'https://apicentral.dev';

    $Curl = curl_init();

    curl_setopt_array(
        $Curl,
        [
            CURLOPT_URL => $base_url . '/' . $endpoint,
            CURLOPT_POST => true,
            CURLOPT_POSTFIELDS => http_build_query($PostFields),
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_TIMEOUT => 30,
            CURLOPT_HTTPHEADER =>
            [
                'Authorization: Bearer ' . $token,
                'Content-Type: application/x-www-form-urlencoded'
            ]
        ]
    );

    $Response = curl_exec($Curl);
    $Data = json_decode($Response, true);

    if (curl_errno($Curl))
        return ['error' => curl_error($Curl)];

    curl_close($Curl); // Omit in PHP 8 and above

    return $Data;
}

// ================================================================
// API-specific usage
// ================================================================
$endpoint = 'File/convert';
$PostFields = 
[
  'file' => 'base64_encoded_file_content_here',
  'input_format' => 'json',
  'output_format' => 'csv',
  'csv_delimiter' => ',',
  'pdf_resolution' => 150,
  'pdf_page' => 0,
];

$Data = processAPIRequest($endpoint, $PostFields);

$status = $Data['status'];
$message = $Data['message'];
$data = $Data['data'] ?? null;
?>

import requests
import json

# ================================================================
# Generic function - copy once, reuse for all APIs
# ================================================================
def process_api_request(endpoint, Data):
    token = 'YOUR_API_TOKEN_HERE'  # Configure your token here
    base_url = 'https://apicentral.dev'
    Headers = {'Authorization': 'Bearer ' + token}

    try:
        Response = requests.post(base_url + '/' + endpoint, json=Data, headers=Headers)
        return Response.json()
    except Exception as e:
        return {'error': str(e)}

# ================================================================
# API-specific usage
# ================================================================
endpoint = 'File/convert'
Data = 
{
  "file": "base64_encoded_file_content_here",
  "input_format": "json",
  "output_format": "csv",
  "csv_delimiter": ",",
  "pdf_resolution": 150,
  "pdf_page": 0
}

ResData = process_api_request(endpoint, Data)

status = ResData.get('status')
message = ResData.get('message')
data = ResData.get('data')

const axios = require('axios');

// ================================================================
// Generic function - copy once, reuse for all APIs
// ================================================================
function processAPIRequest(endpoint, Data)
{
    const token = 'YOUR_API_TOKEN_HERE'; // Configure your token here
    const base_url = 'https://apicentral.dev';

    return axios.post(
        base_url + '/' + endpoint,
        Data,
        {
            headers: {'Authorization': 'Bearer ' + token}
        }
    );
}

// ================================================================
// API-specific usage
// ================================================================
const Data = 
{
  "file": "base64_encoded_file_content_here",
  "input_format": "json",
  "output_format": "csv",
  "csv_delimiter": ",",
  "pdf_resolution": 150,
  "pdf_page": 0
};

processAPIRequest('File/convert', Data)
.then(Response =>
{
    const status = Response.data.status;
    const message = Response.data.message;
    const data = Response.data.data;
})
.catch(Error => { const error = Error.message; });

import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import java.time.Duration;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

public class ApiExample
{
    // ================================================================
    // Generic method - copy once, reuse for all APIs
    // ================================================================
    public static JsonObject processAPIRequest(String endpoint, String jsonPayload) throws Exception
    {
        String token = "YOUR_API_TOKEN_HERE"; // Configure your token here
        String base_url = "https://apicentral.dev";

        HttpClient Client = HttpClient.newBuilder()
            .connectTimeout(Duration.ofSeconds(30))
            .build();

        HttpRequest Request = HttpRequest.newBuilder()
            .uri(URI.create(base_url + "/" + endpoint))
            .header("Authorization", "Bearer " + token)
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
            .build();

        HttpResponse<String> Response = Client.send(Request, HttpResponse.BodyHandlers.ofString());

        return JsonParser.parseString(Response.body()).getAsJsonObject();
    }

    // ================================================================
    // API-specific usage
    // ================================================================
    public static void main(String[] args)
    {
        String endpoint = "File/convert";
        String JsonPayload = """
        
        {
          "file": "base64_encoded_file_content_here",
          "input_format": "json",
          "output_format": "csv",
          "csv_delimiter": ",",
          "pdf_resolution": 150,
          "pdf_page": 0
        }
        """;

        try
        {
            JsonObject ResData = processAPIRequest(endpoint, JsonPayload);
            String status = ResData.get("status").getAsString();
            String message = ResData.get("message").getAsString();
            Object data = ResData.has("data") ? ResData.get("data") : null;
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}

using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

public class ApiExample
{
    // ================================================================
    // Generic method - copy once, reuse for all APIs
    // ================================================================
    public static async Task<dynamic> ProcessAPIRequest(string endpoint, string jsonPayload)
    {
        string token = "YOUR_API_TOKEN_HERE"; // Configure your token here
        string base_url = "https://apicentral.dev";

        using var Client = new HttpClient();
        Client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);

        var content = new StringContent(jsonPayload, Encoding.UTF8, "application/json");

        var Response = await Client.PostAsync(base_url + "/" + endpoint, content);
        var Result = await Response.Content.ReadAsStringAsync();

        return JsonConvert.DeserializeObject(Result);
    }

    // ================================================================
    // API-specific usage
    // ================================================================
    public static async Task Main()
    {
        var endpoint = "File/convert";
        var json_payload = @"
        {
          "file": "base64_encoded_file_content_here",
          "input_format": "json",
          "output_format": "csv",
          "csv_delimiter": ",",
          "pdf_resolution": 150,
          "pdf_page": 0
        }";

        dynamic ResData = await ProcessAPIRequest(endpoint, json_payload);

        string status = ResData.status;
        string message = ResData.message;
        object data = ResData.data;
    }
}

package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
    "io"
)

// ================================================================
// Generic function - copy once, reuse for all APIs
// ================================================================
func processAPIRequest(endpoint string, jsonPayload []byte) (map[string]interface{}, error) {
    token := "YOUR_API_TOKEN_HERE" // Configure your token here
    base_url := "https://apicentral.dev"

    Client := &http.Client{}
    Request, err := http.NewRequest("POST", base_url+"/"+endpoint, bytes.NewBuffer(jsonPayload))

    if err != nil {
        return nil, err
    }

    Request.Header.Set("Authorization", "Bearer " + token)
    Request.Header.Set("Content-Type", "application/json")

    Response, err := Client.Do(Request)

    if err != nil {
        return nil, err
    }

    defer Response.Body.Close()

    Body, _ := io.ReadAll(Response.Body)

    var ResData map[string]interface{}
    json.Unmarshal(Body, &ResData)

    return ResData, nil
}

// ================================================================
// API-specific usage
// ================================================================
func main() {
    JsonPayload := []byte(`
    {
      "file": "base64_encoded_file_content_here",
      "input_format": "json",
      "output_format": "csv",
      "csv_delimiter": ",",
      "pdf_resolution": 150,
      "pdf_page": 0
    }`)

    ResData, err := processAPIRequest("File/convert", JsonPayload)

    if err != nil {
        fmt.Println("Error:", err)
        return
    }

    status := ResData["status"]
    message := ResData["message"]
    data := ResData["data"]

    fmt.Println(status, message, data)
}

require 'net/http'
require 'uri'
require 'json'

# ================================================================
# Generic function - copy once, reuse for all APIs
# ================================================================
def process_api_request(endpoint, data)
    token = 'YOUR_API_TOKEN_HERE'  # Configure your token here
    base_url = 'https://apicentral.dev'

    uri = URI(base_url + '/' + endpoint)
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true

    request = Net::HTTP::Post.new(uri)
    request['Authorization'] = 'Bearer ' + token
    request['Content-Type'] = 'application/json'
    request.body = data.to_json

    response = http.request(request)
    JSON.parse(response.body)
end

# ================================================================
# API-specific usage
# ================================================================
endpoint = 'File/convert'
data = 
{
  "file": "base64_encoded_file_content_here",
  "input_format": "json",
  "output_format": "csv",
  "csv_delimiter": ",",
  "pdf_resolution": 150,
  "pdf_page": 0
}

res_data = process_api_request(endpoint, data)

status = res_data['status']
message = res_data['message']
data = res_data['data']

import Foundation

// ================================================================
// Generic function - copy once, reuse for all APIs
// ================================================================
func processAPIRequest(endpoint: String, jsonPayload: Data, completion: @escaping ([String: Any]?) -> Void)
{
    let token = "YOUR_API_TOKEN_HERE" // Configure your token here
    let base_url = "https://apicentral.dev"

    let requestUrl = URL(string: base_url + "/" + endpoint)!
    var request = URLRequest(url: requestUrl)
    request.httpMethod = "POST"
    request.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
    request.setValue("application/json", forHTTPHeaderField: "Content-Type")
    request.httpBody = jsonPayload

    let task = URLSession.shared.dataTask(with: request) { data, response, error in
        if let error = error {
            print("Error: \(error)")
            completion(nil)
            return
        }

        guard let data = data else {
            completion(nil)
            return
        }

        let resData = try? JSONSerialization.jsonObject(with: data) as? [String: Any]
        completion(resData)
    }

    task.resume()
}

// ================================================================
// API-specific usage
// ================================================================
let endpoint = "File/convert"
let JsonPayload = """

    {
      "file": "base64_encoded_file_content_here",
      "input_format": "json",
      "output_format": "csv",
      "csv_delimiter": ",",
      "pdf_resolution": 150,
      "pdf_page": 0
    }
""".data(using: .utf8)!

processAPIRequest(endpoint: endpoint, jsonPayload: JsonPayload) { resData in
    let status = resData?["status"] as? String
    let message = resData?["message"] as? String
    let data = resData?["data"]
}

import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
import java.net.URI
import java.time.Duration
import com.google.gson.JsonObject
import com.google.gson.JsonParser

// ================================================================
// Generic function - copy once, reuse for all APIs
// ================================================================
fun processAPIRequest(endpoint: String, jsonPayload: String): JsonObject
{
    val token = "YOUR_API_TOKEN_HERE" // Configure your token here
    val base_url = "https://apicentral.dev"

    val client = HttpClient.newBuilder()
        .connectTimeout(Duration.ofSeconds(30))
        .build()

    val request = HttpRequest.newBuilder()
        .uri(URI.create(base_url + "/" + endpoint))
        .header("Authorization", "Bearer " + token)
        .header("Content-Type", "application/json")
        .POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
        .build()

    val response = client.send(request, HttpResponse.BodyHandlers.ofString())

    return JsonParser.parseString(response.body()).asJsonObject
}

// ================================================================
// API-specific usage
// ================================================================
fun main() {
    val endpoint = "File/convert"
    val jsonPayload = """
    
    {
      "file": "base64_encoded_file_content_here",
      "input_format": "json",
      "output_format": "csv",
      "csv_delimiter": ",",
      "pdf_resolution": 150,
      "pdf_page": 0
    }
    """.trimIndent()

    try {
        val resData = processAPIRequest(endpoint, jsonPayload)
        val status = resData.get("status").asString
        val message = resData.get("message").asString
        val data = if (resData.has("data")) resData.get("data") else null
    } catch (e: Exception) {
        e.printStackTrace()
    }
}

import 'dart:convert';
import 'package:http/http.dart' as http;

// ================================================================
// Generic function - copy once, reuse for all APIs
// ================================================================
Future<Map<String, dynamic>> processAPIRequest(String endpoint, Map<String, dynamic> data) async
{
    final token = 'YOUR_API_TOKEN_HERE'; // Configure your token here
    final base_url = 'https://apicentral.dev';
    final headers = {
        'Authorization': 'Bearer ' + token,
        'Content-Type': 'application/json'
    };

    final response = await http.post(Uri.parse(base_url + '/' + endpoint), headers: headers, body: jsonEncode(data));

    return jsonDecode(response.body);
}

// ================================================================
// API-specific usage
// ================================================================
void main() async {
    final endpoint = 'File/convert';
    final data = 
    {
      "file": "base64_encoded_file_content_here",
      "input_format": "json",
      "output_format": "csv",
      "csv_delimiter": ",",
      "pdf_resolution": 150,
      "pdf_page": 0
    };

    try {
        final resData = await processAPIRequest(endpoint, data);
        final status = resData['status'];
        final message = resData['message'];
        final data = resData['data'];
    } catch (e) {
        print('Error: $e');
    }
}

use reqwest::blocking::Client;
use serde_json::Value;

// ================================================================
// Generic function - copy once, reuse for all APIs
// ================================================================
fn process_api_request(endpoint: &str, json_payload: &str) -> Result<Value, Box<dyn std::error::Error>>
{
    let token = "YOUR_API_TOKEN_HERE"; // Configure your token here
    let base_url = "https://apicentral.dev";

    let client = Client::new();

    let response = client
        .post(format!("{}/{}", base_url, endpoint))
        .header("Authorization", format!("Bearer {}", token))
        .header("Content-Type", "application/json")
        .body(json_payload.to_string())
        .send()?;

    let res_data: Value = serde_json::from_str(&response.text()?)?;

    Ok(res_data)
}

// ================================================================
// API-specific usage
// ================================================================
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let endpoint = "File/convert";
    let json_payload = r#"
    
    {
      "file": "base64_encoded_file_content_here",
      "input_format": "json",
      "output_format": "csv",
      "csv_delimiter": ",",
      "pdf_resolution": 150,
      "pdf_page": 0
    }
    "#;

    let res_data = process_api_request(endpoint, json_payload)?;

    let status = &res_data["status"];
    let message = &res_data["message"];
    let data = &res_data["data"];

    println!("{} {} {:?}", status, message, data);

    Ok(())
}

curl -X POST 'https://apicentral.dev/File/convert' \
    -H 'Authorization: Bearer YOUR_API_TOKEN_HERE' \
    -H 'Content-Type: application/json' \
    -d '
    {
      "file": "base64_encoded_file_content_here",
      "input_format": "json",
      "output_format": "csv",
      "csv_delimiter": ",",
      "pdf_resolution": 150,
      "pdf_page": 0
    }'