Code recipes
Short, copy-pasteable patterns for common integrations. Each example assumes a zyfy(path) helper that handles auth and rate limiting — see the client libraries page for that wrapper. For the full picture on any of these — persona framing, all relevant signals, why they matter — see the linked use case page.
Property risk screening
PostcodePull flood risk, crime, and a pre-computed composite score for mortgage underwriting or insurance pricing.
JavaScript
// Property risk screening — mortgage / insurance underwriting
const res = await zyfy('postcode/' + encodeURIComponent(postcode));
const risk = {
floodRisk: res.signals.flood.riversSea, // "very_low" | "low" | "medium" | "high"
crimeRateBand: res.signals.crime.rateBand, // "very_low" ... "very_high"
propertyRiskScore: res.scores.propertyRiskScore, // 0.0-1.0, higher = riskier
propertyRiskLevel: res.summary.propertyRiskLevel, // "low" | "medium" | "high"
insuranceRiskLevel: res.summary.insuranceRiskLevel, // "low" | "medium" | "high"
};
// insuranceRiskLevel is pre-computed from flood + crime percentiles —
// use it directly for a quick tier, or the raw percentiles for a continuous model
console.log(risk.insuranceRiskLevel);Used car purchase check
VehicleCheck odometer integrity, MOT risk, outstanding recalls, and ULEZ compliance before buying a used vehicle.
JavaScript
// Used car purchase check — odometer integrity + MOT risk
const res = await zyfy('vehicle/' + reg);
if (res.enrichmentPending) {
// New plate — retry after the Retry-After header's seconds
return { status: 'pending' };
}
const warnings = [];
if (res.signals.odometerTrend === 'possible_clocking') {
warnings.push('Odometer readings are inconsistent — possible clocking');
}
if (res.summary.buyRecommendation === 'avoid') {
warnings.push('High risk vehicle — avoid purchase');
}
if (res.signals.hasOutstandingRecall) {
warnings.push('Outstanding safety recall');
}
if (res.signals.motStatus === 'expired') {
warnings.push('MOT has expired');
}
return {
registration: res.registration,
make: res.make,
ulezCompliant: res.signals.ulezCompliant,
motRiskLevel: res.summary.motRiskLevel,
conditionBand: res.summary.conditionBand,
buyRecommendation: res.summary.buyRecommendation,
warnings,
};Location intelligence
PostcodeSurface liveability, air quality, green space, and local MP data for relocation tools or rental platforms.
JavaScript
// Location intelligence for relocation or lifestyle decisions
const res = await zyfy('postcode/' + encodeURIComponent(postcode));
return {
liveabilityScore: res.scores.liveabilityScore, // 0.0-1.0, higher = more liveable
liveabilityLevel: res.summary.liveabilityLevel, // "low" | "medium" | "high"
airQuality: res.signals.environment.airQualityBand, // "very_low" | "low" | "moderate" | "high"
greenSpace: res.signals.environment.greenSpaceProximityMetres,
crimeRateBand: res.signals.crime.rateBand,
mpName: res.signals.political.mpName,
mpParty: res.signals.political.mpParty,
epcRating: res.signals.housing.epcAverageRating, // typical energy efficiency of local homes
};Fleet compliance check
VehicleCheck MOT status and ULEZ compliance across a fleet in parallel. Surface vehicles with imminent or expired MOTs.
JavaScript
// Fleet compliance check — MOT and ULEZ status across multiple vehicles
const regs = ['AB12CDE', 'CD34EFG', 'EF56GHJ'];
const results = await Promise.all(
regs.map(reg => zyfy('vehicle/' + reg))
);
const issues = results.flatMap(v => {
const flags = [];
if (v.signals.motStatus === 'expired') flags.push({ reg: v.registration, issue: 'MOT expired' });
if (!v.signals.ulezCompliant) flags.push({ reg: v.registration, issue: 'Not ULEZ compliant' });
if (v.signals.imminentMot) flags.push({ reg: v.registration, issue: 'MOT due within 30 days' });
return flags;
});