API Documentation

Public endpoints for accessing Mapping Violence data programmatically. All endpoints are read-only and require no authentication.

Endpoints

GET /api/locations.geojson

Returns a GeoJSON FeatureCollection of locations with embedded crime data. Each Feature represents a location with one or more associated crime records.

Query Parameters

All parameters are optional. When omitted, all records are returned.

Parameter Type Description
country string Filter by country name
city integer Filter by City primary key
location integer Filter by Location primary key
crime_type string Exact match on crime type (e.g., assault, homicide)
year_from integer Minimum year (inclusive)
year_to integer Maximum year (inclusive)
weapon_category string One of: firearm, blade, blunt_instrument, no_weapon, other
weapon_subcategory string Weapon subcategory (e.g., sword, dagger)
urban_rural string One of: urban, rural, unknown
person string Comma-separated Person IDs, or a text search on person names

Response Format

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [12.3155, 45.4408]
      },
      "properties": {
        "id": 1,
        "name": "Venice - Piazza San Marco",
        "city": "Venice",
        "category": "public",
        "crime_count": 3,
        "crimes": [
          {
            "id": 42,
            "crime": "assault",
            "number": "ABC-001",
            "date": "1542-03-15",
            "year": "1542",
            "fatality": false,
            "victim_gender": "M",
            "perpetrator_gender": "U"
          }
        ]
      }
    }
  ]
}
GET /data/export.csv

Downloads a CSV file of crime records. Supports the same filter parameters as the data table. Exports human-readable values (person names, city names, weapon names) rather than database IDs.

Query Parameters

All parameters are optional. When omitted, all records are exported.

Parameter Type Description
country string Filter by country name
city integer Filter by City primary key
crime_type string Filter by crime type
year_from integer Minimum year (inclusive)
year_to integer Maximum year (inclusive)
fatality boolean true to show only fatal cases
weapon_category string One of: firearm, blade, blunt_instrument, no_weapon, other

CSV Columns

Case Number, Crime, Date, Year, Month, Day, City, Location, Victim(s), Victim Gender, Perpetrator(s), Perpetrator Gender, Weapon, Motive, Fatality, Convicted, Sentence, Description, Connected Event, Archival Location, Reference

Database Schema

An interactive visualization of the database schema is available at /schema-viewer/.

Usage Notes