---
title: "Code as an image"
method: POST
path: "/v1/code-image"
tags: ["Generated images"]
---

# Code as an image

`POST /v1/code-image`

## Request

- Base URL: `https://api.dharun.dev`
- URL: `https://api.dharun.dev/v1/code-image`
- Auth: none declared

A code snippet as a window with syntax colouring. Up to 150 lines of 140 characters. PNGs are drawn at twice the pixel density for sharp text (very large ones at single). The language is guessed from the title's file extension or the code when not given, and reported in the X-Code-Language header.

## Query parameters

- `code` string
- `language` string
- `title` string
- `theme` 'dark' | 'light'
- `lineNumbers` 'true'
- `format` 'png' | 'svg'

## Request body

- object
  - `code` string: The code (or POST it).
  - `format` 'png' | 'svg': Default png.
  - `language` string: Language name or file extension, such as go, python, js, sql.
  - `lineNumbers` 'true': Show line numbers.
  - `text` string, required: The code.
  - `theme` 'dark' | 'light': Default dark.
  - `title` string: File name shown in the title bar.

## Response `200`

Success

## Other responses

- `400`: Error
- `404`: Error
- `429`: Error

---

[API](https://skmtc.dev/dharun/apis/india-api-free-open-source-apis-for-indian-data.md) · [All operations](https://skmtc.dev/dharun/apis/india-api-free-open-source-apis-for-indian-data/llms.txt) · [OpenAPI document](https://skmtc.dev/dharun/apis/india-api-free-open-source-apis-for-indian-data/revisions/ecd8b0ec7863?raw)
