canonical: https://jentic.com/apis/godbolt.org/godbolt

# Godbolt Compiler Explorer API

Jentic publishes the only available OpenAPI specification for Compiler Explorer API, keeping it validated and agent-ready. The Compiler Explorer (godbolt.org) API exposes the same compilation and code-formatting service that powers the popular interactive site at godbolt.org. It lists supported languages, compilers, libraries, and tools; compiles and CMake-builds source code against any registered compiler; formats source through configurable formatters; resolves shortlink IDs; and looks up documentation for individual assembly opcodes. The API is unauthenticated and ideal for AI agents that need to validate or analyse code against real compilers.

## For AI agents

Compile and analyse source code with real compilers, list available languages and compilers, format code, and look up assembly opcode documentation. Open and unauthenticated.

## Scope

Does not handle source-control hosting, package registry distribution, or end-to-end CI orchestration - use for ad-hoc compilation, formatting, and assembly inspection only.

## Capabilities

- List supported programming languages and the compilers available for each
- Compile a source file with a specific compiler version and inspect the generated assembly
- Run a CMake build with a chosen compiler and capture the output
- Format source code through one of the registered formatters with selectable styles
- Look up the documentation for a specific assembly opcode and instruction set
- Resolve a Compiler Explorer shortlink ID to its underlying source and configuration

## Use cases

### Code Review Assembly Inspection

Reviewers paste a hot-path function into the Compiler Explorer API and request the generated assembly to confirm whether a refactor preserved or improved code generation. POST `/compiler/{compilerId}/compile` takes the source plus compiler flags and returns assembly output, diagnostics, and timing.

Example prompt: Compile the provided C++ function with GCC 13 and -O2 and return the generated x86-64 assembly.

### Cross-Compiler Compatibility Check

Library maintainers test a small reproduction across many compilers to confirm a fix works under GCC, Clang, and MSVC. The /compilers and `/compilers/{languageId}` endpoints enumerate every available compiler and version, so an agent can iterate the same source file across the matrix.

Example prompt: Compile the test snippet against the latest 5 GCC versions and the latest 5 Clang versions and report which fail.

### Code Formatting at Scale

An agent normalises C, C++, or Rust source files to the team's house style by calling `/format/{formatter}.` The formatter is chosen from /formats and applied consistently across pull requests so reviewers focus on logic instead of whitespace.

Example prompt: Format every staged C++ file in the PR using clang-format with the LLVM style and write the results back.

### AI Agent Code Verification

An AI coding agent uses Jentic to compile and check its generated code before returning it to the user. The agent searches for the compile operation, loads the schema, posts the candidate source, and only proposes fixes that compile cleanly under the requested compiler.

Example prompt: Search Jentic for 'compile c++ with godbolt', load the schema, compile the agent's draft snippet with GCC 13, and refine until diagnostics are empty.

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| GET | `/languages` | List supported programming languages |
| GET | `/compilers` | List all available compilers |
| GET | `/compilers/{languageId}` | List compilers for a specific language |
| POST | `/compiler/{compilerId}/compile` | Compile source and return assembly |
| POST | `/compiler/{compilerId}/cmake` | Run a CMake build |
| GET | `/formats` | List available source formatters |
| POST | `/format/{formatter}` | Format a source body with a chosen formatter |
| GET | `/asm/{instructionSet}/{opcode}` | Look up an assembly opcode's documentation |

## Key resources

- **Languages** — List supported programming languages
- **Compilers** — Enumerate compilers available for each language
- **Libraries** — List libraries available per language
- **Tools** — List analysis and inspection tools per language
- **Compile** — Compile source and return assembly plus diagnostics
- **CMake** — Run a CMake build with a chosen compiler
- **Format** — Format source through registered formatters
- **Shortlink Info** — Resolve a Compiler Explorer shortlink to its source
- **Asm Documentation** — Look up an assembly opcode for a given instruction set

## Why Jentic

- **Setup:** Wiring Compiler Explorer by hand means calling godbolt.org/api directly, discovering which compilers back each language, and formatting compile and cmake request bodies yourself. Through Jentic you install once, import Compiler Explorer from the API Directory, and your agent calls it with unified logging alongside your authenticated APIs.
- **Permission scoping:** Compiler Explorer is unauthenticated and read or compute only, so scope the agent to the operations it needs, such as listing compilers or compiling a source snippet. You choose the operations it may call, so it can be limited to compilation and formatting without the assembly opcode lookup unless you add it.
- **Credential handling:** Compiler Explorer needs no credential, so your Jentic One instance stores none for it. Calls are proxied through Jentic for unified logging and rate-limit handling alongside your authenticated APIs.
- **Discovery method:** Agents search Jentic by intent such as 'compile c++ code' or 'list available compilers', and Jentic returns the matching Compiler Explorer operation with its input schema so the agent calls the right endpoint without reading the project's Markdown docs.

## Related APIs

- **GitHub REST API** — GitHub holds the source files that get compiled or formatted via Compiler Explorer.
- **CircleCI API** — CircleCI runs full CI pipelines including compilation but is heavier and authenticated.
- **GoCD API** — GoCD orchestrates pipelines but does not provide ad-hoc multi-compiler compilation.

## FAQ

### Why is there no official OpenAPI spec for Compiler Explorer API?

Compiler Explorer documents its endpoints in a Markdown file inside the GitHub repository but does not ship an OpenAPI specification. Jentic generates and maintains this spec so AI agents and developers can call Compiler Explorer API via structured tooling. It is validated against the live API and kept up to date. Get started with Jentic One, the self-hosted execution layer.

### What authentication does the Compiler Explorer API use?

The API is unauthenticated. There is no API key or bearer token required for any endpoint. Jentic still proxies the call so usage analytics and rate-limit handling stay consistent across APIs.

### Can I compile code with the Compiler Explorer API?

Yes. POST `/compiler/{compilerId}/compile` compiles a source body with the chosen compiler and flags and returns assembly output, diagnostics, and execution metadata. POST `/compiler/{compilerId}/cmake` performs a CMake build.

### What are the rate limits for the Compiler Explorer API?

The OpenAPI spec does not declare numeric rate limits. The hosted godbolt.org service applies fair-use throttling; in practice, batch compile requests sequentially and back off on HTTP 429 responses.

### How do I look up an assembly opcode through Jentic?

Run a Jentic search for 'godbolt opcode docs', load the schema for GET `/asm/{instructionSet}/{opcode}`, and execute it with the instruction set and opcode name. Install with pip install jentic and chain search, load, and execute.

### Does the Compiler Explorer API support code formatting?

Yes. GET /formats lists available formatters and POST `/format/{formatter}` applies the chosen formatter to a source body, with style options for tools like clang-format and rustfmt.

### Can I limit what my agent is allowed to do with the Compiler Explorer API?

Yes. Because you run Jentic One yourself, your own rules decide which Compiler Explorer operations the agent may call, and you can scope it down to just the ones it needs. For example, you can allow listing languages and compilers and compiling source through POST `/compiler/{compilerId}/compile`, while withholding the CMake build, the POST `/format/{formatter}` formatter, or the GET `/asm/{instructionSet}/{opcode}` opcode lookup. Since the API is unauthenticated and read or compute only, no credentials are involved, so scoping is purely about which endpoints you let the agent reach.
