SDKs & REFERENCE

Code Examples

Copy-paste renders in curl, Node.js, Python, and PHP.

Same job in four clients. Replace <design-id> and set JSONTOIMG_BASE_URL + JSONTOIMG_API_KEY. Base URL: https://app.jsontoimg.com.

curl

curl -X POST "$JSONTOIMG_BASE_URL/api/v1/render?wait=60" \
  -H "Authorization: Bearer $JSONTOIMG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"template":"<design-id>","format":"png","layers":{"headline":{"text":"Hello"}}}'

Node.js

import { createClient } from "@j2i/sdk";

const client = createClient({ apiKey: process.env.JSONTOIMG_API_KEY! });
const job = await client.renderAndWait({
  template: "<design-id>",
  format: "png",
  layers: { headline: { text: "Hello" } },
});

Full client: Node.js SDK. Shell: CLI.

Python

import os, requests

r = requests.post(
    f"{os.environ['JSONTOIMG_BASE_URL']}/api/v1/render",
    params={"wait": 60},
    headers={"Authorization": f"Bearer {os.environ['JSONTOIMG_API_KEY']}"},
    json={"template": "<design-id>", "format": "png"},
    timeout=90,
)
print(r.json())

See Python.

PHP

$ch = curl_init(getenv('JSONTOIMG_BASE_URL') . '/api/v1/render?wait=60');
curl_setopt_array($ch, [
  CURLOPT_POST => true,
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . getenv('JSONTOIMG_API_KEY'),
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => json_encode([
    'template' => '<design-id>',
    'format' => 'png',
  ]),
  CURLOPT_RETURNTRANSFER => true,
]);
echo curl_exec($ch);

See PHP.

Interactive Try it lives on the API reference.

On this page