If you issue credentials, sooner or later someone asks: "how do I know this badge is real?" The honest answer should never be "trust the PNG." Open Badge v2.0 solves this with a public, machine-readable verification endpoint, and putting a "Verified" widget on your own site takes about ten lines of code. No iframe, no third-party embed script, no SDK.
This post shows how to call the endpoint and render the result in vanilla JavaScript, Node, and Python. It also covers what "verification" actually checks, and the mistakes that make a widget look done while proving nothing.
What "verified" actually means
An Open Badge v2.0 assertion is a JSON-LD document with a fixed shape: the assertion itself (who received it, when), a reference to the BadgeClass (what it is, who defines the criteria), and a reference to the issuer profile (who is vouching for it). Verifying a badge means checking three separate things:
- Does the assertion exist and resolve. The award ID is real, not guessed or tampered with.
- Has it been revoked. An issuer can revoke a badge after the fact (issued in error, policy violation, lapsed certification). A correct verifier must surface that, not just confirm the record exists.
- Does the chain hold together. The assertion's badge and issuer references resolve to real, matching records.
A widget that only checks for a 200 status misses point 2 entirely. A revoked assertion still resolves fine; it just carries a revocation flag in the payload. If your widget only checks "did the request succeed," a revoked credential renders as verified, which is worse than having no widget at all.
The public human page vs. the API endpoint
Every award issued on badges.ninja gets a public URL recipients can share, with no signup needed to view it:
That page is what most recipients link from LinkedIn, a resume, or an email signature. It shows the badge image, the issuer, and the issue date. The API endpoint below returns the same underlying assertion as structured JSON-LD, which is what you want when you're building your own UI.
The endpoint
GET https://api.badges.ninja/certify-badge/award/{guid}
No auth header required. This is intentionally public, because the point of Open Badges is that anyone (an employer, a recruiter, a licensing board) can verify a credential without an account. Field-level details are in the verification docs.
Pass the award's GUID, from your own issuance records or parsed out of a badges.ninja/awards/<guid> link a recipient shared.
Vanilla JS: fetch and render
This is the whole widget. No build step, no npm package:
<div id="badge-verify"></div>
<script>
async function renderBadgeVerification(awardId, mountId) {
const el = document.getElementById(mountId);
el.textContent = "Checking badge status";
try {
const res = await fetch(
`https://api.badges.ninja/certify-badge/award/${awardId}`
);
if (!res.ok) {
el.textContent = "Credential not found.";
return;
}
const assertion = await res.json();
// —— revocation check first, a resolvable assertion isn't enough on its own
if (assertion.revoked) {
el.textContent = `Revoked: ${assertion.revocationReason || "no reason given"}`;
return;
}
el.textContent = `Verified, issued ${new Date(assertion.issuedOn).toLocaleDateString()}`;
} catch (err) {
el.textContent = "Verification check failed.";
}
}
renderBadgeVerification("REPLACE_WITH_AWARD_ID", "badge-verify");
</script>
Swap REPLACE_WITH_AWARD_ID for a real award GUID. There's no iframe boundary to fight with CSS, and no third-party script bringing its own analytics along.
Server-side: Node
To verify on your backend, say before showing a "Verified Partner" badge on a profile page or accepting a credential in an onboarding flow, the fetch is the same minus the DOM:
async function verifyAward(awardId) {
const res = await fetch(
`https://api.badges.ninja/certify-badge/award/${awardId}`
);
if (!res.ok) return { verified: false, reason: "not_found" };
const assertion = await res.json();
if (assertion.revoked) {
return { verified: false, reason: assertion.revocationReason || "revoked" };
}
return { verified: true, issuedOn: assertion.issuedOn, badge: assertion.badge };
}
Server-side: Python
import requests
# —— resolve the assertion, then check revocation before trusting it
def verify_award(award_id):
res = requests.get(f"https://api.badges.ninja/certify-badge/award/{award_id}")
if res.status_code != 200:
return {"verified": False, "reason": "not_found"}
assertion = res.json()
if assertion.get("revoked"):
return {"verified": False, "reason": assertion.get("revocationReason", "revoked")}
return {"verified": True, "issued_on": assertion.get("issuedOn"), "badge": assertion.get("badge")}
Both examples treat a non-200 response as "not found" rather than throwing. A broken or guessed award ID is an expected input for a public endpoint, so handle it as a normal branch.
Style the result yourself
Because the widget is just a fetch into your own DOM, you own every pixel. A common pattern is three visual states:
- Verified: a green check plus the issue date, styled like your site's other tags.
- Revoked: a muted or red state that shows the revocation reason instead of hiding it.
- Not found: never a fake success state, but different copy from "revoked," since a bad ID and a deliberate revocation mean different things to the reader.
A switch on verified / revoked / not_found and three CSS classes covers it.
Cache it
The endpoint is public, but calling it client-side on every page load is still a network round trip. For a page that shows the same badge to every visitor, cache the result server-side with a short TTL. Five to fifteen minutes is plenty, since revocations aren't fast-moving:
const cache = new Map();
async function verifyAwardCached(awardId, ttlMs = 10 * 60 * 1000) {
const hit = cache.get(awardId);
if (hit && Date.now() - hit.at < ttlMs) return hit.result;
const result = await verifyAward(awardId);
cache.set(awardId, { result, at: Date.now() });
return result;
}
For a per-visitor widget, such as a recipient embedding their own credential on a personal site, skip the cache and call it fresh.
When to link out instead
Before building a custom embed, know what recipients already get. Every award's public page includes share and embed snippets they can copy without code:
If the goal is "let a recipient show their badge is real," linking to their badges.ninja/awards/<guid> page is often simpler. Build the custom widget when you need verification status inside your own product's UI: a partner directory, an internal audit dashboard, a hiring tool checking claimed certifications.
Why not an iframe or a vendor widget?
Some platforms hand you an <iframe src="https://vendor.example.com/verify-widget">. It works, but you can't restyle the contents, it adds a cross-origin document your Content-Security-Policy must allow, and every page load calls a third party whether or not the visitor cares about verification. A fetch widget is your DOM, your styling, and it runs only when you call it.
Walking the full chain
For something more thorough than a status widget, like an audit tool or compliance report, walk the whole chain. The assertion references a badge URL (the BadgeClass: name, description, criteria), and the BadgeClass references an issuer URL (the org profile). A rigorous verifier resolves all three and confirms they're consistent: the badge belongs to the issuer it claims, and the assertion references the badge it claims.
Common mistakes
-
Checking only the HTTP status. A revoked assertion still resolves. Read
assertion.revoked. - Hardcoding the award ID in a shared component. Take it as a parameter (data attribute, query string, prop).
- Swallowing network errors silently. Distinguish "the network call failed" from "the API said no," at least in logs.
- Re-verifying on every render. In React or Vue, verify once per mount or per cache window, not on every re-render.
Does it need an account or an API key?
No. The verification endpoint is public: the caller needs no account, no API key, and no plan. Checking whether a badge is valid is a read of the credential itself, not a feature gated by the issuer's subscription.
Ready to issue your first verifiable credential?
Start free at badges.ninja: visual designer, public verification page, PDF certificate, Open Badge v2.0 output. The free plan includes every feature, with limits on volume (5 badges, 1,200 credentials per year). For the full field structure of an assertion, see the JSON-LD field reference. If you're issuing programmatically, the API quickstart covers authentication and the award-creation call.


Top comments (0)