Skip to content

Conversation

@brianfullerusa
Copy link

This pull request is scoped to fix the issue of the additional fields for "school" returning "None" when the code below is executed.

response = client.geocode(
    "some address,
    fields=["school"]
)

The root cause of the issue appears to be a mismatch of names between what the API returns and the expected values.

This pull request makes the following adjustments:

  • src/geocodio/client.py: since the api does not turn school but instead returns "school_districts" an elif was added to match some of the other fields in this file.
  • src/geocodio/models.py: added fields to match the return values from the api. Left existing fields as they are, but they currently always return None. lea_code is really the nces_id, but I left the field as lea_code since that is what the api returns instead of aliasing the return value to nces_id.
  • tests/e2e/test_api.py: added new fields from models.

References:
Geocod.io - Guide - School Districts
Geocod.io - API Reference

sylvesterdamgaard added a commit that referenced this pull request Nov 19, 2025
API changed response format from flat to nested structure for several fields:
- Census: census2010: {...} → census: {2010: {...}}
- ACS: acs-demographics: {...} → acs: {demographics: {...}}
- School districts: school: [...] → school_districts: {elementary: {...}}

Additionally, census field names changed (block → block_code, etc.) which
would break existing code accessing the old field names.

Changes:
- Add nested census parsing with dynamic year support (census2020-census2099+)
- Add nested ACS parsing supporting both simple and metric-specific formats
- Add nested school districts parsing (dict and list formats)
- Map new census field names to legacy names for backward compatibility
- Update ZIP4Data and FFIECData models with complete field definitions
- Remove hardcoded census year fields, use dynamic __getattr__ instead

Backward compatibility ensured:
- fields.census2020.block still works (maps to block_code)
- fields.census2020.blockgroup still works (maps to block_group)
- fields.census2020.tract still works (maps to tract_code)

Future-proof:
- census2031+ years work automatically without code changes
- cd120+ congressional districts work automatically
- Unknown API fields captured in extras dict

Fixes #15
Fixes #16
Closes #14
Closes #17
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