• Stars
    star
    1,436
  • Rank 32,788 (Top 0.7 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created 12 months ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Interactive code examples for documentation, education and fun

Interactive code examples

for documentation, education and fun ๐ŸŽ‰

Codapi is a platform for embedding interactive code snippets directly into your product documentation, online course or blog post.

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ def greet(name):              โ”‚
โ”‚   print(f"Hello, {name}!")    โ”‚
โ”‚                               โ”‚
โ”‚ greet("World")                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
  Run โ–บ  Edit  โœ“ Done
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Hello, World!                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Codapi manages sandboxes (isolated execution environments) and provides an API to execute code in these sandboxes. It also provides a JavaScript widget codapi-js for easier integration.

Highlights:

  • Automatically converts static code examples into mini-playgrounds.
  • Lightweight and easy to integrate.
  • Sandboxes for any programming language, database, or software.
  • Open source. Uses the permissive Apache-2.0 license.

For an introduction to Codapi, see this post: Interactive code examples for fun and profit.

Installation

See Installing Codapi for details.

Usage (API)

Call /v1/exec to run the code in a sandbox:

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

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

sandbox is the name of the pre-configured sandbox, and command is the name of a command supported by that sandbox. See Adding a sandbox for details on how to add a new sandbox.

files is a map, where the key is a filename and the value is its contents. When executing a single file, it should either be named as the command expects, or be an empty string (as in the example above).

Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "id": "python_run_9b7b1afd",
  "ok": true,
  "duration": 314,
  "stdout": "hello world\n",
  "stderr": ""
}
  • id is the unique execution identifier.
  • ok is true if the code executed without errors, or false otherwise.
  • duration is the execution time in milliseconds.
  • stdout is what the code printed to the standard output.
  • stderr is what the code printed to the standard error, or a compiler/os error (if any).

Usage (JavaScript)

See codapi-js to embed the JavaScript widget into a web page. The widget uses exactly the same API as described above.

Contributing

Contributions are welcome. For anything other than bugfixes, please first open an issue to discuss what you want to change.

Be sure to add or update tests as appropriate.

License

Copyright 2023 Anton Zhiyanov.

The software is available under the Apache-2.0 license.

Stay tuned

โ˜… Subscribe to stay on top of new features.

More Repositories

1

sqlean

The ultimate set of SQLite extensions
C
3,638
star
2

redka

Redis re-implemented with SQLite
Go
3,354
star
3

sqlime

Online SQLite playground
JavaScript
890
star
4

codapi-js

Interactive code examples for documentation, education and fun.
JavaScript
478
star
5

dataviz

Data visualization guide for presentations, reports, and dashboards
Python
436
star
6

pokitoki

Humble GPT Telegram Bot
Python
313
star
7

sqlpkg-cli

SQLite package manager
Go
199
star
8

zero

Zero Dependency Club
159
star
9

sqlpkg

SQLite extension registry
132
star
10

iuliia-py

Transliterate Cyrillic โ†’ Latin in every possible way
Python
112
star
11

sqlean.py

Python's sqlite3 + extensions
C
105
star
12

sqlean.js

Browser-based SQLite with extensions
Makefile
86
star
13

iuliia-js

Transliterate Cyrillic โ†’ Latin in every possible way
TypeScript
82
star
14

uuidv7

UUIDv7 in N languages
Racket
79
star
15

podsearch-py

Let's find some podcasts!
Python
72
star
16

iuliia

Transliterate Cyrillic โ†’ Latin in every possible way
69
star
17

sqlite

SQLite / Sqlean shell builds
Makefile
62
star
18

git-by-example

Step-by-step guide to Git operations
47
star
19

whatbrowser

ะ’ัะต, ั‡ั‚ะพ ะฝัƒะถะฝะพ ะทะฝะฐั‚ัŒ ะพ ะฑั€ะฐัƒะทะตั€ะต ะฟะพะปัŒะทะพะฒะฐั‚ะตะปั
JavaScript
43
star
20

tryxinyminutes

Live code tutorials in your browser
Shell
41
star
21

invoice

ะัƒ ะพั‡ะตะฝัŒ ะฟั€ะพัั‚ะพะต ะฒั‹ัั‚ะฐะฒะปะตะฝะธะต ัั‡ะตั‚ะพะฒ ะดะปั ัŽั€ะปะธั†
HTML
39
star
22

words

Word and phrase lists in CSV
Python
30
star
23

grep-by-example

Step-by-step guide to grep operations
28
star
24

metro

Metro lines and stations for cities in Belorussia, Kazakhstan, Russia and Ukraine
14
star
25

runno

Runno WASI runtime.
TypeScript
10
star
26

sqlite-stats

Statistical functions for SQLite
C
9
star
27

sqlite-wasi

SQLite WASI build.
C
9
star
28

metalsmith-typography

A Metalsmith plugin to enhance typography
JavaScript
9
star
29

python-wasi

Python WASI build.
JavaScript
8
star
30

php-wasi

PHP WASI build.
JavaScript
8
star
31

curl-by-example

Step-by-step guide to curl operations
8
star
32

sqliter

SQLite ะฝะฐ ะฟั€ะฐะบั‚ะธะบะต
JavaScript
6
star
33

lua-wasi

Lua WASI build.
C
5
star
34

nalgeon.github.io

Everything about SQLite, Python, open data and awesome software
JavaScript
3
star
35

sqlite-ext

All "miscellaneous" SQLite extensions from sqlite.org
Makefile
3
star
36

asylum

ยซะŸัะธั…ะฑะพะปัŒะฝะธั†ะฐยป ะšัƒะฟะตั€ะฐ 20 ะปะตั‚ ัะฟัƒัั‚ั
CSS
2
star
37

nalgeon

2
star
38

sql-window-functions

SQL Window Functions Explained
2
star
39

inline-css

A native CSS framework for rapid UI development.
HTML
1
star
40

wee

Toy WSGI-compatible web framework
Python
1
star
41

rosenc

HTML
1
star
42

ruby-wasi

Ruby WASI build.
JavaScript
1
star
43

actionist

GitHub Actions Playground
C
1
star