Documentation
GoGuard protects your API with 31 security checks — automatically, on every request. One line of code. Zero configuration. Works with Node.js, Python, and Go.
- A GoGuard API key — get one at dashboard.goguard.dev
- Node.js 18+, Python 3.8+, or Go 1.21+
export GOGUARD_API_KEY=sk_live_your_key_hereNode.js
@goguard/nodeInstall
npm install @goguard/nodeExpress
const express = require('express')
const { goguard } = require('@goguard/node')
const app = express()
app.use(express.json())
// One line — every route is now protected
app.use(goguard({ apiKey: process.env.GOGUARD_API_KEY }))
app.post('/api/signup', (req, res) => {
// GoGuard already blocked injection, disposable emails,
// mass assignment, SSRF, and more before this runs.
// Optional: use normalized email for duplicate checks
const email = req.goguard?.email?.normalized ?? req.body.email
res.json({ ok: true })
})
app.listen(3000)Fastify
const { GoGuardClient } = require('@goguard/node')
const client = new GoGuardClient({ apiKey: process.env.GOGUARD_API_KEY })
app.addHook('preHandler', async (req, reply) => {
const verdict = await client.decide({
ip: req.ip,
path: req.url,
method: req.method,
headers: req.headers,
})
if (verdict.action === 'block') reply.status(403).send({ blocked: true })
})Next.js Middleware
// middleware.ts
import { GoGuardClient } from '@goguard/node'
const client = new GoGuardClient({ apiKey: process.env.GOGUARD_API_KEY! })
export async function middleware(request: Request) {
const verdict = await client.decide({
ip: request.headers.get('x-forwarded-for') || 'unknown',
path: new URL(request.url).pathname,
method: request.method,
headers: Object.fromEntries(request.headers),
})
if (verdict.action === 'block')
return new Response('Blocked', { status: 403 })
}Python
goguardInstall
pip install goguardFlask
from flask import Flask
from goguard import GoGuard
import os
flask_app = Flask(__name__)
guard = GoGuard(api_key=os.environ["GOGUARD_API_KEY"])
@flask_app.post("/api/signup")
def signup():
# GoGuard already blocked attacks before this runs
return {"ok": True}
# One line — wrap your app
app = guard.protect(flask_app)
app.run(port=3000)FastAPI
from fastapi import FastAPI
from goguard import GoGuard
import os
app = FastAPI()
guard = GoGuard(api_key=os.environ["GOGUARD_API_KEY"])
@app.post("/api/signup")
async def signup():
return {"ok": True}
# Wrap the ASGI app
app = guard.protect(app)Django
# wsgi.py
from goguard import GoGuard
import os
guard = GoGuard(api_key=os.environ["GOGUARD_API_KEY"])
application = guard.protect(application)Go
github.com/goguard/sdk-goInstall
go get github.com/goguard/sdk-gonet/http
package main
import (
"net/http"
"os"
goguard "github.com/goguard/sdk-go"
)
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/api/signup", func(w http.ResponseWriter, r *http.Request) {
// GoGuard already blocked attacks before this runs
// Optional: access enrichment data
enrichment := goguard.GetEnrichment(r)
if enrichment != nil && enrichment.Email != nil {
normalizedEmail := enrichment.Email.Normalized
_ = normalizedEmail
}
w.Write([]byte("ok"))
})
// One line — wrap your handler
handler := goguard.Protect(mux, goguard.Config{
APIKey: os.Getenv("GOGUARD_API_KEY"),
})
http.ListenAndServe(":3000", handler)
}What Gets Protected
All checks run automatically. No configuration needed. The developer writes zero security code.
Configuration
Everything works out of the box. Customize only if you need to.
app.use(goguard({
apiKey: process.env.GOGUARD_API_KEY, // required
mode: 'block', // 'block' | 'monitor' (default: 'block')
excludePaths: ['/health', '/metrics'], // skip these paths
// Toggle individual protections (all true by default)
protect: {
email: true, // email fraud detection
phone: true, // phone fraud detection
login: true, // credential stuffing detection
injection: true, // SQL, XSS, NoSQL, command injection, path traversal
leaks: true, // response leak detection (keys, PII, passwords)
ssrf: true, // SSRF prevention
auth: true, // broken auth detection (monitor only, never blocks)
idor: true, // IDOR enumeration detection
bac: true, // broken access control / mass assignment
},
// Callbacks
onBlock: (req, reason) => console.log('Blocked:', reason),
onError: (err) => console.error('GoGuard error:', err.message),
}))If GoGuard services are unreachable or timeout (default 1500ms), every request is automatically allowed through. Your app is never impacted by GoGuard downtime.
Enrichment Data
GoGuard attaches analysis data to every request. You don't need it, but it's there if you want it.
Node.js — req.goguard
app.post('/api/signup', (req, res) => {
// Email enrichment
const email = req.goguard?.email?.normalized // "victim@gmail.com"
const isDisposable = req.goguard?.email?.is_disposable // false
const riskScore = req.goguard?.email?.risk_score // 0.1
// Phone enrichment
const country = req.goguard?.phone?.country_name // "United States"
const isVoip = req.goguard?.phone?.is_voip // false
const numberType = req.goguard?.phone?.number_type // "mobile"
// Vulnerability detections (if any were found but not blocked)
const vulns = req.goguard?.vulnerabilities // VulnerabilityEvent[]
})Python — environ / scope
@app.post("/api/signup")
def signup():
enrichment = request.environ.get("goguard") # WSGI
# or: scope["state"]["goguard"] # ASGI
if enrichment and enrichment.get("email"):
normalized = enrichment["email"]["normalized"]Go — goguard.GetEnrichment(r)
func signupHandler(w http.ResponseWriter, r *http.Request) {
enrichment := goguard.GetEnrichment(r)
if enrichment != nil && enrichment.Email != nil {
normalized := enrichment.Email.Normalized
_ = normalized
}
}Security Scanner
Static analysis for your source code. Finds hardcoded secrets, missing auth, data leaks, and insecure configs — before you push. Requires a GoGuard API key.
Run
# Scans current directory
npx @goguard/scan
# Scan a specific folder
npx @goguard/scan ./src
# Provide API key explicitly
npx @goguard/scan --api-key sk_live_your_key
# JSON output for CI
npx @goguard/scan --json
# Fail CI if high severity or above
npx @goguard/scan --fail-on highWhat It Checks
| Check | Severity |
|---|---|
| Hardcoded secrets | Critical |
| Committed .env files | Critical |
| Missing .gitignore | Critical |
| Missing auth middleware | Critical/High |
| SQL injection in code | High |
| Response data leaks | High |
| Insecure dependencies | High |
| Supabase misconfig | Critical/High |
| Firebase misconfig | Critical/High |
| Weak JWT secrets | High |
GitHub Action
Run the scanner in CI on every push. Block deploys if critical vulnerabilities are found.
# .github/workflows/security.yml
name: GoGuard Security Scan
on: [push, pull_request]
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: goguard/scan@v1
with:
api-key: ${{ secrets.GOGUARD_API_KEY }}
fail-on: highReady to protect your API?
One line of code. 31 security checks. Zero friction.