Interactive code examples

for all types of technical writing

Embed executable code snippets directly into your product documentation, online course or blog post.

def greet(name):
  print(f"Hello, {name}!")

greet("World")
const greet = (name: string) => {
  console.log(`Hello, ${name}!`)
}

greet("World")
create table data(message text);
insert into data values ('Hello, World!');
select * from data;
greet() {
  echo "Hello, $1!"
}

greet "World"
#include <stdio.h>

void greet(const char* name) {
    printf("Hello, %s!\n", name);
}

int main() {
    greet("World");
}
and many more!

Document, teach, engage

Increase product adoption — allow developers to interact with your software in tutorials and how-tos.
Make education more effective — add interactive exercises to your courses.
Engage readers — embed live code examples in your articles and blog posts.
Learn how Codapi is different

Playground

Try everything

Supports 30 playgrounds out of the box, plus custom sandboxes if you need them.

programming languages
JavaScript TypeScript Python Bash Java C# C++ PHP C Go Rust Kotlin Ruby Dart Lua Swift R Elixir Zig Haskell Julia F# Clojure OCaml Nim Odin V

databases
PostgreSQL MySQL SQLite MongoDB Redis MariaDB FerretDB ClickHouse chDB DuckDB

network
Fetch API HTTP Network tools Caddy curl

tools
Git grep ripgrep Mermaid

And more to come! Just ask

Bring your own environment

Codapi is not limited to the boring run command. You can lint, test and benchmark code, or run custom commands.

Codapi goes beyond a fixed set of programming languages and tools. Build your own playgrounds with custom packages and software, and use them for fun and profit.

FROM python:3.12-slim

COPY requirements.txt /tmp
RUN pip install -r /tmp/requirements.txt
COPY *.py /opt

RUN adduser --home /sandbox sandbox

USER sandbox
WORKDIR /sandbox

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

Use templates and multi-file playgrounds to focus on the important parts of the code and hide the rest behind the scenes.

Visualize data and model code dependencies to give readers a rich, Jupyter notebook-like experience.

Sample chart

Integrate in minutes

Codapi is specifically designed for embedding in articles, product documentation, online courses, mobile apps, etc. — so it's very lightweight.

Integrate via JavaScript widget

<!-- code snippet -->
<pre>print("Hello, World!")</pre>

<!-- playground widget attaches to the previous snippet -->
<codapi-snippet sandbox="python" editor="basic">
</codapi-snippet>

<!-- playground script -->
<script src="https://unpkg.com/@antonz/codapi/dist/snippet.js">
</script>
print("Hello, World!")

Use a platform guide

We have tutorials for the most common documentation tools, with more on the way.

HTML/Markdown Docusaurus Docsify Notion WordPress Dev.to Medium Substack

Call the API

POST https://api.codapi.org/v1/exec
authorization: bearer ***
content-type: application/json

{
    "sandbox": "python",
    "command": "run",
    "files": {
        "": "print(\"hello world\")"
    }
}

Get started

Some playgrounds work entirely in the browser. Others require a Codapi server — available as a cloud service and as a self-hosted version.

Codeapi cloud is free to try, no sign up required. If you exceed 1000 code runs/month, buy a subscription to extend the limit.

To set up custom sandboxes, use the self-hosted version. It's free and open-source.

Buy for $5/month  or try for free

Showcase

Curious about real-world use cases? Here are a few:

Curl by example net-tools, shell

API tutorials beyond OpenAPI fetch, javascript, python

Compact objects in Python python

SQL join flavors postgres, sqlite

Go release notes go

and more →

Open source

Codapi is licensed under the permissive Apache-2.0 license and is committed to remaining open source forever.

There is also commercial support for enterprises and a cloud version for those who prefer not to self-host.

Source code