Can I embed or programmatically access Opengist snippets?
Updated
Yes. Opengist provides two integration paths: an embed widget that drops a snippet into any webpage, and JSON/API access for fetching and managing snippets programmatically. Both are listed features of the self-hosted, Git-powered pastebin, so you can use them without leaving your own instance.
Embedding a snippet in a webpage
The embed widget is the low-effort option when you want a snippet to appear inside a blog post, documentation page, or internal dashboard.
- Input: a snippet on your Opengist instance.
- Action: use the embed widget to place that snippet into the target page.
- Expected result: the snippet renders in the page rather than requiring visitors to click through to Opengist.
Because rendering is a first-class feature, embedded content benefits from the same presentation as the main site: syntax highlighting for hundreds of languages, plus Markdown with Mermaid, LaTeX, CSV, and media files. If your snippet is a diagram or a formatted document rather than plain code, that formatting carries into the embed.
A practical caveat: visibility settings still apply. A snippet marked private is not something you should expect to surface publicly through an embed, so check the visibility (public, unlisted, or private) before wiring it into a page.
Fetching snippets as JSON
For programmatic reads, Opengist can return a snippet as JSON. This is the right choice when you want to process snippet content in another application instead of displaying it as-is — for example, pulling a configuration snippet into a build script, or aggregating snippets into an internal index.
The same visibility rules govern access, so plan around whether the consuming system can authenticate to your instance.
Managing snippets via the API and Git
Opengist exposes an API for managing snippets, and every snippet is itself a Git repository. That gives you two distinct automation styles:
| Approach | Best for | How it works |
|---|---|---|
| API | Creating, updating, and organizing snippets from scripts or services | Call the API to manage snippets directly |
| Git CLI | Workflows already built around version control | Clone and push over HTTP or SSH, or create a snippet with a plain git push |
The Git route is worth highlighting: because each snippet is a repository, you can create one by pushing to it, and you get the full revision history with diffs between every revision. If your team already treats snippets like code, this keeps them in the same toolchain.
Finding snippets to embed or fetch
Integration is only useful if you can locate the right snippet. Opengist supports full-text and code search across snippets via code or metadata, so you can search by content or by descriptive information such as topics. Topics also help with discovery when snippets are organized rather than dumped into a single list.
What to check before you build on this
- Instance access: if your instance requires login, anonymous access to embeds or JSON endpoints may not be available. Opengist supports requiring login for a private instance and optionally allowing anonymous snippets, so the behavior depends on how your admin configured it.
- Authentication options: for programmatic access, the instance supports OAuth (GitHub, GitLab, Gitea, OIDC), LDAP, and account security via TOTP or WebAuthn — relevant if your integration needs to authenticate as a user.
- Storage backend: snippets live in SQLite, PostgreSQL, or MySQL depending on deployment, which matters for backup and migration planning rather than for the integration itself.
If you want to try the interface before committing, the project offers a live demo, and the documented quick start is a single Docker command:
docker run -p 6157:6157 -v "$HOME/.opengist:/opengist" ghcr.io/thomiceli/opengist:1.15
That gives you a running instance to test embedding and JSON retrieval against your own snippets before rolling it out to a wider audience.