Skip to content

Conversation

@ppfenning
Copy link

Though the API response was returning field params, the Geocodio client was not parsing them correctly. Changes of note in this PR:

  • acs and census fields return as a dictionary and are now parsed as such
  • zip4 and ffiec are now parsed correctly
  • CensusData, ZIP4Data and FFIECData now have keys matching their response
  • GeocodioFields to include extras as not to lose response information from API call

pfenningp added 3 commits October 27, 2025 13:46
- `Zip4Data` proper keys
- `FFIECData` proper keys
- add `extras`to `GeocodioFields` to avoid missing response info
- inline `census` and `acs` parse from dictionary in api response
- filter dictionaries `valid_field_names`,
- `ffiec` and `zip4` missing
- `extras` for unparsed API responses
@ppfenning
Copy link
Author

This also mitigates problems raised in #12

@ppfenning
Copy link
Author

ppfenning commented Oct 27, 2025

Attaching an example result using the below:

from geocodio import Geocodio
from dotenv import load_dotenv
import os
import json
from dataclasses import asdict

# Load environment variables from .env file
load_dotenv()

client = Geocodio(os.getenv("GEOCODIO_API_KEY"), hostname=os.getenv("GEOCODIO_HOST"))

data = client.geocode(
    "3730 N Clark St, Chicago, IL",
    fields=[
        "cd",
        "timezone",
        "ffiec",
        "zip4",
        "acs-demographics",
        "acs-economic",
        "acs-housing", 
        "acs-social", 
        "acs-families", 
        "census2024"
    ]
)

with open('output.json', 'w') as f:
    f.write(json.dumps(asdict(data), indent=2))

output.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant