Graph API (Flowcharts)

Generate SVG flowcharts by sending nodes and links as JSON.

POST
POST /graph?apikey={key}
Content-Type: application/json
💡 Note: This endpoint accepts POST only. For GET requests, use the Chart API.

Request Body

FieldTypeDescription
nodesarrayArray of {"id":"...", "label":"..."} objects (max 50)
linksarrayArray of {"source":"...", "target":"..."} objects (max 100)
optionsobjectOptional: nodeColor, strokeColor, textColor, bgColor (hex strings, e.g., "#1e293b")

Options (Customization)

OptionTypeDescription
nodeColorstringNode fill color (hex, e.g., #1e293b)
strokeColorstringBorder color (hex)
textColorstringText color (hex)
bgColorstringBackground color (hex)

Code Examples

Copy and paste the code below to get started quickly in your preferred language.

JavaScript (Fetch)
JavaScript
const apiKey = 'YOUR_KEY';
const url = `https://api.divct.workers.dev/graph?apikey=${apiKey}`;

const body = {
  nodes: [
    { id: 'start', label: 'Submit' },
    { id: 'review', label: 'Review' },
    { id: 'done', label: 'Done' }
  ],
  links: [
    { source: 'start', target: 'review' },
    { source: 'review', target: 'done' }
  ]
};

fetch(url, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify(body)
})
  .then(res => res.text())
  .then(svg => {
    document.getElementById('graph-container').innerHTML = svg;
  })
  .catch(err => console.error(err));
Python (Requests)
Python
import requests

api_key = "YOUR_KEY"
url = f"https://api.divct.workers.dev/graph?apikey={api_key}"

body = {
    "nodes": [
        {"id": "start", "label": "Submit"},
        {"id": "review", "label": "Review"},
        {"id": "done", "label": "Done"}
    ],
    "links": [
        {"source": "start", "target": "review"},
        {"source": "review", "target": "done"}
    ]
}

response = requests.post(url, json=body)
if response.status_code == 200:
    with open("flowchart.svg", "wb") as f:
        f.write(response.content)
    print("Flowchart saved as flowchart.svg")
else:
    print("Error:", response.json())
cURL (Command Line)
cURL
curl -X POST "https://api.divct.workers.dev/graph?apikey=YOUR_KEY" \\
  -H "Content-Type: application/json" \\
  -d '{
    "nodes": [
      {"id": "start", "label": "Submit"},
      {"id": "review", "label": "Review"},
      {"id": "done", "label": "Done"}
    ],
    "links": [
      {"source": "start", "target": "review"},
      {"source": "review", "target": "done"}
    ]
  }' -o flowchart.svg
Node.js (Axios)
Node.js
const axios = require('axios');
const fs = require('fs');

const apiKey = 'YOUR_KEY';
const url = `https://api.divct.workers.dev/graph?apikey=${apiKey}`;

const body = {
  nodes: [
    { id: 'start', label: 'Submit' },
    { id: 'review', label: 'Review' },
    { id: 'done', label: 'Done' }
  ],
  links: [
    { source: 'start', target: 'review' },
    { source: 'review', target: 'done' }
  ]
};

axios.post(url, body, { responseType: 'text' })
  .then(res => {
    fs.writeFileSync('flowchart.svg', res.data);
    console.log('Flowchart saved as flowchart.svg');
  })
  .catch(err => console.error(err));

Error Codes

StatusCodeDescription
400INVALID_DATAInvalid nodes or links
401UNAUTHORIZEDMissing or invalid API key
403DOMAIN_NOT_ALLOWEDAPI key restricted to specific domains
403INVALID_SIGNATURERequest signature verification failed
403FORBIDDENRequest blocked (e.g., restricted key usage)
403ACCOUNT_SUSPENDEDAccount has been suspended
429RATE_LIMITEDToo many requests
429QUOTA_EXCEEDEDPoints quota exhausted (includes Retry-After header)
500INTERNAL_ERRORInternal server error
503SERVICE_UNAVAILABLEGraph generation service down

Example

POST
POST /graph?apikey=YOUR_KEY
Content-Type: application/json

{
  "nodes": [
    {"id":"start","label":"Submit"},
    {"id":"review","label":"Review"},
    {"id":"done","label":"Done"}
  ],
  "links": [
    {"source":"start","target":"review"},
    {"source":"review","target":"done"}
  ],
  "options": {
    "nodeColor": "#1e293b",
    "strokeColor": "#38bdf8",
    "textColor": "#f8fafc",
    "bgColor": "#0f172a"
  }
}

Example Result

Flowchart
Flowchart: Submit, Review, Done

Limits