LightBox Geocoding

View Raw

Jupyter Notebook that demonstrates Geocoding an address.

LightBox API - Geocoding

This notebook demonstrates basic features of the LightBox Geocoding API by walking through the following steps:

  1. Import Phthon packages
  2. Enter your API Key for authorication
  3. Create request objects and display the results both in the JSON form.

Additional Materials: LightBox Developer Portal

#1. Import the required python packages

1# Making REST calls
2import requests
3# Working with a JSON response
4import json

#2. Enter your LightBox Authorizition key

1lightBoxKey = input("LightBox Key?")

#3. Create a headers variable that will be used to authenticate your calls Get your key from the LightBox Developer Portal.

1headers = {
2    'x-api-key': lightBoxKey
3}

#4. LightBox Geododing API Details This notbook will create various requests and display the output in eiter JSON or a pandas data frame.

  1. Geocoding - https://api.lightboxre.com/addresses/search

For additional details regarding each endpoint's request parameters or response models, visit the LightBox Geocoding on the LightBox Developer Portal page.

Create a variable containing the base url for subsiquent calls.

  1. Geocoding Search endpoint
1# BASE URL
2baseUrl = 'https://api.lightboxre.com/v1'
3
4#Url
5url = baseUrl + '/addresses/search'
6
7#url Parameters
8params = {
9    'text': input("Please enter an address?")
10}
11
12r=requests.get(url, params=params, headers=headers)
13# JSON output
14r.json()
Please enter an address?25482 Buckwood Land Forest, Ca, 92630
1{'$ref': 'https://api.lightboxre.com/v1/addresses/search?text=25482%20Buckwood%20Land%20Forest%2C%20Ca%2C%2092630',
2 '$metadata': {'geogcs': {'epsg': '4326'}, 'recordSet': {'totalRecords': 1.0}},
3 'addresses': [{'$ref': 'https://api.lightboxre.com/v1/addresses/search?text=25482%20Buckwood%2C%20Lake%20Forest%2C%20CA%2092630-5433%2C%20USA',
4   'id': '06033UO1O5JI8WZTQ8O4SG',
5   'uuaid': None,
6   'uaid': None,
7   '$metadata': {'geocode': {'confidence': {'streetNumber': 1,
8      'streetName': 0.9230769230769231,
9      'locality': 1,
10      'postalCode': 1,
11      'score': 0.938},
12     'precisionCode': 10,
13     'changeFlag': {'streetName': 'Fuzzy', 'locality': 'Alias'},
14     'addressComponents': {'prefixType': None,
15      'prefixDirection': None,
16      'streetNumber': '25482',
17      'streetName': 'Buckwood',
18      'suffixType': None,
19      'suffixDirection': None,
20      'unit': None}}},
21   'label': '25482 BUCKWOOD, LAKE FOREST, CA 92630-5433, US',
22   'type': None,
23   'postalCodeDerived': None,
24   'corroborationIndex': None,
25   'location': {'streetAddress': '25482 BUCKWOOD',
26    'locality': 'LAKE FOREST',
27    'regionCode': 'CA',
28    'unit': None,
29    'county': 'ORANGE COUNTY',
30    'countryCode': 'US',
31    'postalCode': '92630',
32    'postalCodeExt': '5433',
33    'representativePoint': {'latitude': 33.627759,
34     'longitude': -117.685771,
35     'geometry': {'wkt': 'POINT(-117.685771 33.627759)'}}},
36   'parcels': [{'$ref': 'https://api.lightboxre.com/v1/parcels/us/02011302EQSMZB5I2YM3IV',
37     'id': '02011302EQSMZB5I2YM3IV'}],
38   'structures': [{'$ref': 'https://api.lightboxre.com/v1/structures/us/0503Z0KH336YKS3P609GRE',
39     'id': '0503Z0KH336YKS3P609GRE'}],
40   'assessments': [{'$ref': 'https://api.lightboxre.com/v1/assessments/us/0307LTEIHJOJRD1XGXP84X',
41     'id': '0307LTEIHJOJRD1XGXP84X'}]}]}