API based replacement for carbon.now.sh

Overview

Inkify

Unfortunately Carbon has been without an API for too long, and I've run into a few cases where one would be useful for a project. So I present to you, Inkify, an API for generating beautiful pictures of your code.

Usage

Inkify relies on the silicon library for generating photos, and takes much the same arguments as the silicon CLI does. Arguments are passed as query parameters to the /generate route, and are as follows:

  • code: The code to generate an image from. Required.
  • language: The language to use for syntax highlighting. Optional, will attempt to guess if not provided.
  • theme: The theme to use for syntax highlighting. Optional, defaults to Dracula.
  • font: The font to use. Optional, defaults to Fira Code.
  • shadow_color: The color of the shadow. Optional, defaults to transparent.
  • background: The background color. Optional, defaults to transparent.
  • tab_width: The tab width. Optional, defaults to 4.
  • line_pad: The line padding. Optional, defaults to 2.
  • line_offset: The line offset. Optional, defaults to 1.
  • window_title: The window title. Optional, defaults to "Inkify".
  • no_line_number: Whether to hide the line numbers. Optional, defaults to false.
  • no_round_corner: Whether to round the corners. Optional, defaults to false.
  • no_window_controls: Whether to hide the window controls. Optional, defaults to false.
  • shadow_blur_radius: The shadow blur radius. Optional, defaults to 0.
  • shadow_offset_x: The shadow offset x. Optional, defaults to 0.
  • shadow_offset_y: The shadow offset y. Optional, defaults to 0.
  • pad_horiz: The horizontal padding. Optional, defaults to 80.
  • pad_vert: The vertical padding. Optional, defaults to 100.
  • highlight_lines: The lines to highlight. Optional, defaults to none.
  • background_image: The background image for the padding area as a URL. Optional, defaults to none.

Routes

GET /

The index route is used as a help/ping route. It will always return a 200 response if the API is live, and the body is a JSON object containing a message and a list of routes.

GET /generate

The generate route is used to generate images. It takes the arguments listed above as query parameters, and returns a PNG image.

GET /detect

The detect route is used to detect the language of a code snippet. It takes a single argument, code, which is the code to detect the language of. It returns a sorted list of languages, along with the confidence of the detection (as a number between 0 and 100).

GET /themes

The themes route is used to get a list of available themes. It takes no arguments, and returns a JSON object containing a list of themes.

GET /fonts

The fonts route is used to get a list of available fonts. It takes no arguments, and returns a JSON object containing a list of fonts.

GET /languages

The languages route is used to get a list of available languages. It takes no arguments, and returns a JSON object containing a list of languages supported by the syntect library (which is used by silicon under the hood).

Deployment

Inkify is written in Rust using the actix-web framework, and can be deployed as a standalone binary. It can also be deployed as a Docker container, and a Dockerfile is provided for this purpose. The Dockerfile also installs all nerd fonts by default, allowing you to use any of them as the font for your code.

Contributing

Contributions are welcome, and can be made by opening a pull request. Please make sure to lint your code using cargo clippy before submitting a pull request.

License

Inkify is licensed under the MIT license. See the LICENSE file for more information.

You might also like...
Conversion Tools API Rust client

ConversionTools Rust This Conversion Tools API Rust client allows you to use the site API and convert files faster and more conveniently. Site Convers

Public aircraft & flightroute api Built in Rust for Docker, using PostgreSQL & Redis

api.adsbdb.com public aircraft & flightroute api Built in Rust for Docker, using PostgreSQL & Redis See typescript branch for original typescript vers

Simple RESTful API in rust created with actix-web. (Routing, models, JWT auth).

rust-simple-api Simple RESTful API created with rust, actix-web, Diesel, JWT. Running application Manual Firstly generate a secret.key which will be u

A asynchronous implementation of the invidious innertube aka youtubei API wrapper

A asynchronous implementation of the invidious innertube aka youtubei API wrapper. Using tokio,reqwest, serde and serde_json

The second Rust implementation on GitHub of third-party REST API client for Bilibili.

Bilibili REST API The second Rust implementation on GitHub of third-party REST API client for Bilibili. Designed to be lightweight and efficient. It's

Simple Rust 🦀 api with Rocket 🚀

Car API Written in Rust & Rocket.rs 🦀 🚀 Running project Running by cargo You just need to run the following command: cargo run Running on docker Fi

Rust wrapper for the LeapC Ultraleap (Leap Motion) hand tracking device API.

LeapRS LeapRS is a safe wrapper for LeapC, the Leap Motion C API. It uses the generated binding provided by leap-sys. This is an API for accessing Lea

API and logger for GBFS endpoints, noticeably Velib' in Paris

GBFS Watcher A daemon which logs Velib' stations statuses and provides a REST endpoint to access data. Velib' API is built over GBFS v1, so this API c

The utility is designed to check the availability of peers and automatically update them in the Yggdrasil configuration file, as well as using the admin API - addPeer method.

Yggrasil network peers checker / updater The utility is designed to check the availability of peers and automatically update them in the Yggdrasil con

Owner
Chris Watson
Freelance web and software developer; lover of all things open source.
Chris Watson
Stardust XR Reference Server, now in Rust :D

Stardust XR Reference Server This project is a usable Linux display server that reinvents human-computer interaction for all kinds of XR, from putting

Stardust XR 9 Dec 20, 2022
Now, the Host is Mine! - Super Fast Sub-domain Takeover Detection!

NtH1M - Super Fast Sub-domain Takeover Detection Notice This is a sad notice that our Internet Hero (@TheBinitGhimire) had recent demise on 26th of Ju

Captain Nick Lucifer* 5 Nov 5, 2022
sodiumoxide clone, now with less chlorides and more oxides

sodiumoxide2 Less Chlorides, more Oxides! This package is a fork of sodiumoxide, using rust-native crypto. It's not intended to be easy to use or impl

Conrad Ludgate 3 Apr 16, 2023
List public items (public API) of Rust library crates. Enables diffing public API between releases.

cargo wrapper for this library You probably want the cargo wrapper to this library. See https://github.com/Enselic/cargo-public-items. public_items Li

Martin Nordholts 20 Dec 26, 2022
Uma lib para a API do Brasil API (para o Rust)

Uma lib para a API do BrasilAPI (para o Rust) Features CEP (Zip code) DDD Bank CNPJ IBGE Feriados Nacionais Tabela FIPE ISBN Registros de domínios br

Pedro Augusto 6 Dec 13, 2022
API for the creation character based games in Linux.

Console Game Engine for Linux. API for the creation of character based games in Linux. The inspiration came from the olcConsoleGameEngine. This is my

Arjob Mukherjee 4 Sep 27, 2022
Rust library for hardware accelerated drawing of 2D shapes, images, and text, with an easy to use API.

Speedy2D Hardware-accelerated drawing of shapes, images, and text, with an easy to use API. Speedy2D aims to be: The simplest Rust API for creating a

null 223 Dec 26, 2022
An API for getting questions from http://either.io implemented fully in Rust, using reqwest and some regex magic. Provides asynchronous and blocking clients respectively.

eithers_rust An API for getting questions from http://either.io implemented fully in Rust, using reqwest and some regex magic. Provides asynchronous a

null 2 Oct 24, 2021
Code to follow along the "Zero To Production" book on API development in Rust.

Zero To Production / Code (Chapter 10 - Part 1) Zero To Production In Rust is an opinionated introduction to backend development using Rust. This repo

Luca Palmieri 2.8k Dec 31, 2022
Interact with the crate's API

cargo-crate-api Interact with the crate's API Documentation Installation Getting Started Reference FAQ Contribute CHANGELOG Install Download a pre-bui

null 7 Aug 9, 2022