Writing OSINT Tools With Open City API's

Writing OSINT Tools With Open City API's

I love building simple tools using open API's, and this is an example of how to get started using a bash script to access interesting data contained within API's.

Building permits are a crucial part of the construction and development process in any city, as they ensure that structures are safe and compliant with local regulations. The Department of Building and Safety in Los Angeles makes this information available to the public through an API, or application programming interface. This allows developers and researchers to access and analyze the data in a programmatic way, making it easier to extract insights and make use of the information.

Open APIs like this one are a prime example of open-source intelligence (OSINT), which refers to the collection and analysis of information from publicly available sources. The availability of this data can be incredibly valuable for a wide range of use cases, from investigative research to real estate market analysis.

To make use of this API, you'll need a few things:

  1. A computer running Linux with a bash terminal
  2. An internet connection
  3. If desired, an API key which can be obtained by creating an account on https://dev.socrata.com/register
  4. jq, a command-line JSON processor. It can be installed by running: sudo apt-get install jq.
  5. A basic understanding of URLs and how to format them.

Now you're ready to start using the API to access building permit information in Los Angeles. Here is a basic bash script to get you started:

#!/bin/bash

# Inputs street name and address

echo "Enter street name: "

read street_name

echo "Enter address: "

read address

# Formats the input into the proper URL format and uses curl command to retrieve the JSON data

url="https://data.lacity.org/resource/nbyu-2ha9.json?street_name=$street_name&address_end=$address"

curl -X GET $url | jq

The script prompts the user for a street name and address, and then uses these values to construct a URL that makes a query to the API. The curl command is used to send a GET request to the specified URL, and the resulting JSON data is piped through jq, which formats it in a more readable way.

Here is a sample output for 242 N Hoover:

 

    "zip_code": "90744",

    "address_end": "222",

    "floor_area_l_a_building_code_definition": "0",

    "principal_first_name": "ALBERTO",

    "census_tract": "2946.10",

    "permit_category": "No Plan Check",

    "latest_status": "Permit Finaled",

    "initiating_office": "SANPEDRO",

    "assessor_parcel": "024",

    "applicant_first_name": "ALBERTO",

    "zone": "R1-1XL-O",

    "assessor_book": "7422",

    "contractor_state": "CA",

    "license_expiration_date": "2015-08-31T00:00:00.000",

    "license_type": "C36",

    "pcis_permit": "14042-40000-18879",

    "contractor_city": "WHITTIER",

    "address_start": "222",

    "street_name": "N",

    "street_suffix": "ST",

    "street_direction": "E",

    "status_date": "2014-10-09T00:00:00.000",

    "principal_last_name": "RAMIREZ",

    "license": "985827",

    "issue_date": "2014-09-29T00:00:00.000",

    "assessor_page": "008",

    "contractors_business_name": "FUTURA ENERGY INC",

    "tract": "TR 23790",

    "lot": "13",

    "permit_sub_type": "1 or 2 Family Dwelling",

    "location_1": {

      "latitude": "33.78959",

      "human_address": "{\"address\": \"\", \"city\": \"\", \"state\": \"\", \"zip\": \"\"}",

      "needs_recoding": false,

      "longitude": "-118.26068"

    },

    "contractor_address": "14462 PLACID DRIVE",

    "permit_type": "Plumbing"

You can see that spaces cannot be used in URLs, as they need to be encoded (%20) so the syntax and formatting is correct. The street_name and address_end filters are used as query parameters in the URL to filter the data by street name and address of the target property.

Once you run the script, you will receive a JSON data containing building permits information that matches the specified street name and address.

The data returned contains information about building permits in the city, including details such as the address of the building, the work being done, the names and addresses of the applicants and contractors, and the status of the permit. This information can be useful for researchers interested in understanding the construction activity in a specific area or investigating specific individuals or companies involved in building projects.

For example, a researcher could use the data to track the progress of a building project, identify patterns in construction activity, or investigate potential building code violations. It also shows the detailed information such as census_tract, parcel and book numbers, zone, permit_category, status and valuation which can be used for further intelligence or investigation.

A key point to mention is that, an API key is optional, but without one, the number of searches will be limited per time range.

To access the API website and learn more about all the fields and filters that can be used in the query, you can visit https://data.lacity.org/A-Prosperous-City/Building-Permits/nbyu-2ha9.

In summary, open APIs like the Los Angeles Department of Building and Safety's provide valuable data to the public, in this case building permit information, and a script like the one above makes it easy to access and analyze that data. This type of data can be useful for researchers, developers, and anyone interested in the construction and development of the city.