Developers · Server
Server-to-server
Samples for back-end services. Every sample calls a live public endpoint; copy, run and adapt.
verify.php
<?php
// Verify a Global Ad Alliance certificate (PHP 8+)
function gaa_verify(string $certId): array {
$url = 'https://globaladalliance.com/api/v1/verify/' . rawurlencode($certId);
$ctx = stream_context_create(['http' => ['timeout' => 5, 'ignore_errors' => true]]);
$json = file_get_contents($url, false, $ctx);
return json_decode((string)$json, true) ?: ['valid' => false];
}
$r = gaa_verify('GAA-2026-871F28');
echo $r['valid'] ? "Verified: {$r['member']} ({$r['node_id']})\n" : "Not verified\n";main.go
package main
import (
"encoding/json"
"fmt"
"net/http"
"time"
)
type VerifyResult struct {
Valid bool `json:"valid"`
Status string `json:"status"`
Member string `json:"member"`
NodeID string `json:"node_id"`
}
func main() {
c := &http.Client{Timeout: 5 * time.Second}
resp, err := c.Get("https://globaladalliance.com/api/v1/verify/GAA-2026-871F28")
if err != nil {
panic(err)
}
defer resp.Body.Close()
var r VerifyResult
_ = json.NewDecoder(resp.Body).Decode(&r)
fmt.Println(r.Valid, r.Status, r.Member, r.NodeID)
}verify.py
# Python 3, standard library only
import json, urllib.request
def gaa_verify(cert_id: str) -> dict:
url = f"https://globaladalliance.com/api/v1/verify/{cert_id}"
try:
with urllib.request.urlopen(url, timeout=5) as r:
return json.load(r)
except urllib.error.HTTPError as e:
return json.load(e)
r = gaa_verify("GAA-2026-871F28")
print(r["valid"], r.get("member"), r.get("node_id"))verify.mjs
// Node.js 18+ (built-in fetch)
async function gaaVerify(certId) {
const res = await fetch(`https://globaladalliance.com/api/v1/verify/${encodeURIComponent(certId)}`);
return res.json();
}
gaaVerify('GAA-2026-871F28').then((r) => {
console.log(r.valid ? `Verified: ${r.member} (${r.node_id})` : 'Not verified');
});Check a supply chain against the registry
Implements step 1 of the buyer verification steps in GAA-SCT.
chain-check.mjs
// Node.js: check every hop of a GAA-SCT chain against the public registry
const reg = await (await fetch('https://globaladalliance.com/api/v1/registry/keys')).json();
const known = new Set(reg.keys.map((k) => k.node_id));
const chainOk = (chain) => chain.hops.every((h) => known.has(h.node));Validate a bid payload
curl
curl -s -X POST https://globaladalliance.com/api/v1/validate -H 'Content-Type: application/json' \
-d '{"kind":"bid_response","format":"json","payload":{}}'Validate GAA messages locally
Every GAA specification ships a JSON Schema (2020-12). Use any validator, for example in Python:
validate_bx.py
import json, urllib.request
from jsonschema import Draft202012Validator # pip install jsonschema
schema = json.load(urllib.request.urlopen('https://globaladalliance.com/standards/gaa-bx.schema.json'))
msg = json.load(open('bid_request.json'))
errors = list(Draft202012Validator(schema).iter_errors(msg))
print('valid' if not errors else errors[0].message)