You need to programmatically score risk by ZIP code for a quoting form, a logistics dashboard, or a location-based app—and you need it live this week. By the end of this guide you’ll make authenticated requests to the Crime Insights By Zip Code API from Zyla API Hub, parse the crime grades and breakdown, and ship a PHP integration you can drop into production.
What this API delivers
The Crime Insights By Zip Code API returns a JSON object for a given U.S. ZIP code that includes:
- Overall Crime Grade, plus Violent, Property, and Other crime grades.
- Detailed breakdown of rates for Assault, Robbery, Rape, Murder, Theft, Vehicle Theft, Burglary, Arson, and more.
- Comparatives: nearby ZIPs and similar-population ZIPs with their aggregate grades.
Typical users include insurance quoting flows, rental and real-estate search, delivery/logistics risk routing, safety overlays on maps, and due diligence dashboards.
Everything runs through Zyla API Hub: one account, one API key, one subscription model across a catalog of more than 10,000 public APIs on Zyla API Hub.
Getting started on Zyla API Hub
- Open the API page: Crime Insights By Zip Code API.
- Click Subscribe (or Start Free Trial if available). The Hub uses a subscription + quota model (not pay-per-call). For this API, the first subscription typically includes a 7-day trial or 50 requests—check the API page for current access options and pricing. There is no Free Plan.
- Copy your API key from your dashboard.
All requests on the Hub require an Authorization header: Authorization: Bearer YOUR_API_KEY.
Endpoint overview
This API exposes a single, simple GET endpoint through the Hub:
-
Get Crime Rates by ZIP
Method: GET
URL: https://zylalabs.com/api/7225/crime-insights-by-zip-code-api/11398/get-crime-rates-by-zip
Required query parameter:- zip (string): the ZIP code to analyze (e.g., 90001).
Quick test with curl
Copy-paste this exact request. Replace YOUR_API_KEY with the key from your Zyla dashboard.
curl -s -X GET "https://zylalabs.com/api/7225/crime-insights-by-zip-code-api/11398/get-crime-rates-by-zip?zip=90001" \
-H "Authorization: Bearer YOUR_API_KEY"
Official sample response
This is the official example payload from the listing. Use it to wire your parsing and unit tests.
{"Overall":{"Zipcode":"90001","Overall Crime Grade":"D+","Violent Crime Grade":"D-","Property Crime Grade":"D","Other Crime Grade":"B"},"Crime BreakDown":[{"Violent Crime Rates":{"Assault":"4.240","Robbery":"1.268","Rape":"0.4587","Murder":"0.1180"},"0":{"Total Violent Crime":"6.084","Total Violent Crime Score":"(D-)"}},{"Property Crime Rates":{"Theft":"14.07","Vehicle Theft":"6.104","Burglary":"3.308","Arson":"0.1368"},"0":{"Total Property Crime":"23.62","Total Property Crime Score":"(D)"}},{"Other Crime Rates":{"Kidnapping":"0.1141","Drug Crimes":"2.666","Vandalism":"3.135","Identity Theft":"0.3353","Animal Cruelty":"0.0200"},"0":{"Total \"Other\" Rate":"6.270","Total \"Other\" Score":"(B)"}}],"Crime Rates Nearby":[{"Nearby Zip":"90003, CA","Overall Crime Grade":"D","Violent Crime Grade":"D-","Property Crime Grade":"D"},{"Nearby Zip":"90002, CA","Overall Crime Grade":"C-","Violent Crime Grade":"D","Property Crime Grade":"D+"},{"Nearby Zip":"90058, CA","Overall Crime Grade":"F","Violent Crime Grade":"F","Property Crime Grade":"F"},{"Nearby Zip":"90255, CA","Overall Crime Grade":"D","Violent Crime Grade":"D-","Property Crime Grade":"D-"},{"Nearby Zip":"90011, CA","Overall Crime Grade":"D","Violent Crime Grade":"F","Property Crime Grade":"D"},{"Nearby Zip":"90044, CA","Overall Crime Grade":"D+","Violent Crime Grade":"D-","Property Crime Grade":"D"},{"Nearby Zip":"90059, CA","Overall Crime Grade":"D+","Violent Crime Grade":"D","Property Crime Grade":"D"},{"Nearby Zip":"90037, CA","Overall Crime Grade":"D+","Violent Crime Grade":"D-","Property Crime Grade":"D"},{"Nearby Zip":"90280, CA","Overall Crime Grade":"C-","Violent Crime Grade":"D","Property Crime Grade":"D+"},{"Nearby Zip":"90047, CA","Overall Crime Grade":"D","Violent Crime Grade":"D-","Property Crime Grade":"D-"}],"Similar Population Crime Rates":[{"Similar Zip":"07728, NJ","Overall Crime Grade":"A-","Violent Crime Grade":"A+","Property Crime Grade":"A+"},{"Similar Zip":"08901, NJ","Overall Crime Grade":"B","Violent Crime Grade":"B","Property Crime Grade":"B"},{"Similar Zip":"76549, TX","Overall Crime Grade":"C+","Violent Crime Grade":"C-","Property Crime Grade":"C-"},{"Similar Zip":"84074, UT","Overall Crime Grade":"C","Violent Crime Grade":"B","Property Crime Grade":"B"},{"Similar Zip":"84041, UT","Overall Crime Grade":"C-","Violent Crime Grade":"B","Property Crime Grade":"B"},{"Similar Zip":"83686, ID","Overall Crime Grade":"B+","Violent Crime Grade":"A","Property Crime Grade":"A"},{"Similar Zip"…
Key fields you will actually use:
- Overall.Zipcode: the ZIP you requested.
- Overall Crime Grade, Violent Crime Grade, Property Crime Grade, Other Crime Grade: letter grades for simple UI display and filters.
- Crime BreakDown: arrays that include per-category rates and totals (as strings).
- Crime Rates Nearby and Similar Population Crime Rates: arrays of comparative ZIP-level grades.
Units for rate values are not specified in the hub listing. If you display raw numbers, label them as “Rates” and provide your own explanatory tooltip. When in doubt, surface the letter grades, which are designed for end-user interpretation.
PHP integration (cURL)
This is a minimal, production-ready PHP snippet to hit the endpoint, handle non-2xx responses, and map the core grades for your UI.
<?php
$zip = '90001';
$endpoint = 'https://zylalabs.com/api/7225/crime-insights-by-zip-code-api/11398/get-crime-rates-by-zip?zip=' . urlencode($zip);
$ch = curl_init($endpoint);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_KEY',
'Accept: application/json'
],
CURLOPT_TIMEOUT => 15,
]);
$body = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$err = curl_error($ch);
curl_close($ch);
if ($err) {
http_response_code(502);
echo json_encode(['error' => 'transport_error', 'detail' => $err]);
exit;
}
if ($httpCode < 200 || $httpCode >= 300) {
// The hub returns a non-2xx for errors; forward status + body to aid debugging
http_response_code($httpCode);
echo $body;
exit;
}
$data = json_decode($body, true);
if (!is_array($data) || !isset($data['Overall'])) {
http_response_code(500);
echo json_encode(['error' => 'unexpected_response']);
exit;
}
// Extract grades safely
$overall = $data['Overall'];
$result = [
'zip' => $overall['Zipcode'] ?? $zip,
'overall_grade' => $overall['Overall Crime Grade'] ?? null,
'violent_grade' => $overall['Violent Crime Grade'] ?? null,
'property_grade' => $overall['Property Crime Grade'] ?? null,
'other_grade' => $overall['Other Crime Grade'] ?? null,
];
// Optional: totals if present (index 0 inside each breakdown element)
$totals = [
'violent_total' => null,
'property_total' => null,
'other_total' => null,
];
if (isset($data['Crime BreakDown']) && is_array($data['Crime BreakDown'])) {
foreach ($data['Crime BreakDown'] as $entry) {
if (isset($entry['Violent Crime Rates'], $entry['0']['Total Violent Crime'])) {
$totals['violent_total'] = $entry['0']['Total Violent Crime'];
}
if (isset($entry['Property Crime Rates'], $entry['0']['Total Property Crime'])) {
$totals['property_total'] = $entry['0']['Total Property Crime'];
}
if (isset($entry['Other Crime Rates'], $entry['0']['Total "Other" Rate'])) {
$totals['other_total'] = $entry['0']['Total "Other" Rate'];
}
}
}
header('Content-Type: application/json');
echo json_encode(['grades' => $result, 'totals' => $totals], JSON_PRETTY_PRINT);
JavaScript example (Node.js fetch)
If you prefer Node.js, here’s a compact script using native fetch (Node 18+). It reads the same fields as the PHP example.
import fetch from 'node-fetch';
const ZIP = '90001';
const url = `https://zylalabs.com/api/7225/crime-insights-by-zip-code-api/11398/get-crime-rates-by-zip?zip=${encodeURIComponent(ZIP)}`;
const res = await fetch(url, {
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Accept': 'application/json'
}
});
if (!res.ok) {
const text = await res.text();
throw new Error(`Hub error ${res.status}: ${text}`);
}
const json = await res.json();
// Pull top-level grades
const overall = json?.Overall ?? {};
const summary = {
zip: overall['Zipcode'],
overall: overall['Overall Crime Grade'],
violent: overall['Violent Crime Grade'],
property: overall['Property Crime Grade'],
other: overall['Other Crime Grade']
};
// Optional: totals from breakdown if present
let violentTotal, propertyTotal, otherTotal;
for (const section of (json['Crime BreakDown'] || [])) {
if (section['Violent Crime Rates'] && section['0']?.['Total Violent Crime']) {
violentTotal = section['0']['Total Violent Crime'];
}
if (section['Property Crime Rates'] && section['0']?.['Total Property Crime']) {
propertyTotal = section['0']['Total Property Crime'];
}
if (section['Other Crime Rates'] && section['0']?.['Total "Other" Rate']) {
otherTotal = section['0']['Total "Other" Rate'];
}
}
console.log({ summary, totals: { violentTotal, propertyTotal, otherTotal } });
Practical implementation notes
- Authentication: Always send Authorization: Bearer YOUR_API_KEY. Do not add other keys or query params beyond the documented ones.
- Parameter validation: The only required parameter is zip. Validate it as a 5-digit string before calling to avoid unnecessary requests.
- Caching: Crime grades by ZIP are relatively stable. Cache results per ZIP for hours or days depending on your product needs to reduce latency and quota usage.
- Timeouts/retries: Network conditions vary; use a 10–15s timeout and at-most-once retries for idempotent GETs.
- Parsing: Many numeric “rate” values arrive as strings. If you need math, coerce with care and handle missing fields defensively.
- UI: Lead with letter grades for instant comprehension; expose the breakdown rows as advanced detail.
Common use cases you can ship now
- Insurance quoting: accept an address/ZIP, fetch grades, and adjust risk tiers or underwriting rules.
- Real estate portals: display per-ZIP letter grades on listing pages and map clusters.
- Delivery/logistics: pre-screen routes by ZIP, flag higher-risk areas for after-dark shipments.
- Background research: add nearby and similar-population comparatives for context in reports.
- Property management: evaluate potential acquisitions with quick ZIP-level snapshots.
Calling through MCP from AI agents
Every API on Zyla can also be called from AI agents via the MCP endpoint at MCP. Tools like Claude Code, Cursor, and Windsurf can fetch the Crime Insights By Zip Code API by referencing its listing and endpoint numerics inside their MCP tooling (e.g., get_api_info for listing 7225, then call_api for endpoint 11398). Pass your Zyla API key to MCP (e.g., apikey=YOUR_API_KEY on the MCP endpoint) and the agent will execute the same Hub request on your behalf. Refer to your MCP client’s documentation for the exact tool invocation format.
Error handling and observability
- HTTP status: Treat non-2xx as errors and bubble the message to logs. Keep the response text for debugging.
- Input edge cases: If a ZIP is malformed, short-circuit on your side to preserve quota.
- Monitoring: Track success/error counts by ZIP to reveal data gaps or hot paths for caching.
- Quotas: The Hub uses subscription + quota. If you expect spikes, size the plan accordingly; check the API page for current options.
Security
- Keep YOUR_API_KEY server-side. Do not expose it in client-side JavaScript.
- If you must call from the browser, proxy the request through your backend to inject the Authorization header.
- Rotate keys on a schedule and audit logs for unexpected usage patterns.
Link your flow end-to-end
For fast feedback loops during development:
- Seed your tests with the official 90001 response above.
- Write a zip->grades function and a small in-memory cache keyed by ZIP.
- Render letter grades first; format rates with clear labels like “Assault rate”, “Theft rate”.
- Log the full JSON for the first N calls per environment to confirm structure before trimming logs.
Explore more on Zyla API Hub
The Crime Insights By Zip Code API is part of a large marketplace of location, finance, enrichment, AI, and utility APIs. You can subscribe and use all of them with the same key and billing model. Browse categories on Zyla API Hub and wire adjacent data sources (geocoding, property, or mapping) into the same workflow.
FAQ
What’s the base URL and method?
Use GET on https://zylalabs.com/api/7225/crime-insights-by-zip-code-api/11398/get-crime-rates-by-zip with the zip query parameter.
How do I authenticate?
Add the header Authorization: Bearer YOUR_API_KEY to every request.
Which parameters are required?
zip is required (e.g., 90001). Do not add other parameters.
What about quotas or trials?
Zyla uses subscription + quota (not pay-per-call). For this API, the first subscription typically includes a 7-day trial or 50 requests. Check the API page for current access options and pricing.
Can I call it from an AI agent via MCP?
Yes. Use the MCP endpoint at MCP with your Zyla API key; tools like get_api_info and call_api can target the listing and endpoint numerics directly within MCP-compatible clients.
Ready to implement? Create your account and get your API key now: Register, open the Crime Insights By Zip Code API, and ship your ZIP-based risk scoring today.
Official API response
{"Overall":{"Zipcode":"90001","Overall Crime Grade":"D+","Violent Crime Grade":"D-","Property Crime Grade":"D","Other Crime Grade":"B"},"Crime BreakDown":[{"Violent Crime Rates":{"Assault":"4.240","Robbery":"1.268","Rape":"0.4587","Murder":"0.1180"},"0":{"Total Violent Crime":"6.084","Total Violent Crime Score":"(D-)"}},{"Property Crime Rates":{"Theft":"14.07","Vehicle Theft":"6.104","Burglary":"3.308","Arson":"0.1368"},"0":{"Total Property Crime":"23.62","Total Property Crime Score":"(D)"}},{"Other Crime Rates":{"Kidnapping":"0.1141","Drug Crimes":"2.666","Vandalism":"3.135","Identity Theft":"0.3353","Animal Cruelty":"0.0200"},"0":{"Total \"Other\" Rate":"6.270","Total \"Other\" Score":"(B)"}}],"Crime Rates Nearby":[{"Nearby Zip":"90003, CA","Overall Crime Grade":"D","Violent Crime Grade":"D-","Property Crime Grade":"D"},{"Nearby Zip":"90002, CA","Overall Crime Grade":"C-","Violent Crime Grade":"D","Property Crime Grade":"D+"},{"Nearby Zip":"90058, CA","Overall Crime Grade":"F","Violent Crime Grade":"F","Property Crime Grade":"F"},{"Nearby Zip":"90255, CA","Overall Crime Grade":"D","Violent Crime Grade":"D-","Property Crime Grade":"D-"},{"Nearby Zip":"90011, CA","Overall Crime Grade":"D","Violent Crime Grade":"F","Property Crime Grade":"D"},{"Nearby Zip":"90044, CA","Overall Crime Grade":"D+","Violent Crime Grade":"D-","Property Crime Grade":"D"},{"Nearby Zip":"90059, CA","Overall Crime Grade":"D+","Violent Crime Grade":"D","Property Crime Grade":"D"},{"Nearby Zip":"90037, CA","Overall Crime Grade":"D+","Violent Crime Grade":"D-","Property Crime Grade":"D"},{"Nearby Zip":"90280, CA","Overall Crime Grade":"C-","Violent Crime Grade":"D","Property Crime Grade":"D+"},{"Nearby Zip":"90047, CA","Overall Crime Grade":"D","Violent Crime Grade":"D-","Property Crime Grade":"D-"}],"Similar Population Crime Rates":[{"Similar Zip":"07728, NJ","Overall Crime Grade":"A-","Violent Crime Grade":"A+","Property Crime Grade":"A+"},{"Similar Zip":"08901, NJ","Overall Crime Grade":"B","Violent Crime Grade":"B","Property Crime Grade":"B"},{"Similar Zip":"76549, TX","Overall Crime Grade":"C+","Violent Crime Grade":"C-","Property Crime Grade":"C-"},{"Similar Zip":"84074, UT","Overall Crime Grade":"C","Violent Crime Grade":"B","Property Crime Grade":"B"},{"Similar Zip":"84041, UT","Overall Crime Grade":"C-","Violent Crime Grade":"B","Property Crime Grade":"B"},{"Similar Zip":"83686, ID","Overall Crime Grade":"B+","Violent Crime Grade":"A","Property Crime Grade":"A"},{"Similar Zip"…
Official API response
{"Overall":{"Zipcode":"90001","Overall Crime Grade":"D+","Violent Crime Grade":"D-","Property Crime Grade":"D","Other Crime Grade":"B"},"Crime BreakDown":[{"Violent Crime Rates":{"Assault":"4.240","Robbery":"1.268","Rape":"0.4587","Murder":"0.1180"},"0":{"Total Violent Crime":"6.084","Total Violent Crime Score":"(D-)"}},{"Property Crime Rates":{"Theft":"14.07","Vehicle Theft":"6.104","Burglary":"3.308","Arson":"0.1368"},"0":{"Total Property Crime":"23.62","Total Property Crime Score":"(D)"}},{"Other Crime Rates":{"Kidnapping":"0.1141","Drug Crimes":"2.666","Vandalism":"3.135","Identity Theft":"0.3353","Animal Cruelty":"0.0200"},"0":{"Total \"Other\" Rate":"6.270","Total \"Other\" Score":"(B)"}}],"Crime Rates Nearby":[{"Nearby Zip":"90003, CA","Overall Crime Grade":"D","Violent Crime Grade":"D-","Property Crime Grade":"D"},{"Nearby Zip":"90002, CA","Overall Crime Grade":"C-","Violent Crime Grade":"D","Property Crime Grade":"D+"},{"Nearby Zip":"90058, CA","Overall Crime Grade":"F","Violent Crime Grade":"F","Property Crime Grade":"F"},{"Nearby Zip":"90255, CA","Overall Crime Grade":"D","Violent Crime Grade":"D-","Property Crime Grade":"D-"},{"Nearby Zip":"90011, CA","Overall Crime Grade":"D","Violent Crime Grade":"F","Property Crime Grade":"D"},{"Nearby Zip":"90044, CA","Overall Crime Grade":"D+","Violent Crime Grade":"D-","Property Crime Grade":"D"},{"Nearby Zip":"90059, CA","Overall Crime Grade":"D+","Violent Crime Grade":"D","Property Crime Grade":"D"},{"Nearby Zip":"90037, CA","Overall Crime Grade":"D+","Violent Crime Grade":"D-","Property Crime Grade":"D"},{"Nearby Zip":"90280, CA","Overall Crime Grade":"C-","Violent Crime Grade":"D","Property Crime Grade":"D+"},{"Nearby Zip":"90047, CA","Overall Crime Grade":"D","Violent Crime Grade":"D-","Property Crime Grade":"D-"}],"Similar Population Crime Rates":[{"Similar Zip":"07728, NJ","Overall Crime Grade":"A-","Violent Crime Grade":"A+","Property Crime Grade":"A+"},{"Similar Zip":"08901, NJ","Overall Crime Grade":"B","Violent Crime Grade":"B","Property Crime Grade":"B"},{"Similar Zip":"76549, TX","Overall Crime Grade":"C+","Violent Crime Grade":"C-","Property Crime Grade":"C-"},{"Similar Zip":"84074, UT","Overall Crime Grade":"C","Violent Crime Grade":"B","Property Crime Grade":"B"},{"Similar Zip":"84041, UT","Overall Crime Grade":"C-","Violent Crime Grade":"B","Property Crime Grade":"B"},{"Similar Zip":"83686, ID","Overall Crime Grade":"B+","Violent Crime Grade":"A","Property Crime Grade":"A"},{"Similar Zip"…