Skip to main content

# NYC Geoclient Python Bindings

Python bindings for the REST [NYC Geoclient API][api].

[api]: http://developer.cityofnewyork.us/api/geoclient-api-beta

### Usage

First, you will need to register an application with the [NYC Developer Portal][portal], and make sure that you check off access to the Geoclient API for the application. Take note of the Application’s ID and key. You will not be able to use the ID and key until [DoITT][] approves you – this could take several days, and you will receive an email when this happens. There isn’t any indication of your status on the dashboard, but all requests will return a 403.

[portal]: https://developer.cityofnewyork.us/ [DoITT]: http://www.nyc.gov/html/doitt/html/home/home.shtml

You can pip install nyc-geoclient. It depends upon the [requests][] library.

[requests]: http://docs.python-requests.org/en/latest/index.html

$ pip install nyc_geoclient

Once your app has been approved by DoITT, using the API is simple:

>>> from nyc_geoclient import Geoclient
>>> g = Geoclient('my app ID', 'my app key')

All of the REST endpoints are supported.

>>> g.address('1500', 'Madison Ave', 'Manhattan')
{u'assemblyDistrict': u'68',
 u'boardOfElectionsPreferredLgc': u'1',
 u'boePreferredStreetName': u'MADISON AVENUE',
 u'boePreferredstreetCode': u'12539001',
 u'boroughCode1In': u'1',
 u'censusBlock2000': u'2000',
 u'censusBlock2010': u'3003',
 u'censusTract1990': u' 168  ',
 u'censusTract2000': u' 168  ',
 u'censusTract2010': u' 168  ',
 u'cityCouncilDistrict': u'08',
 u'civilCourtDistrict': u'06',
 u'coincidentSegmentCount': u'1',
...
>>> g.intersection('atlantic ave', 'nevins st', 'Brooklyn')
{u'assemblyDistrict': u'52',
 u'boroughCode1In': u'3',
 u'censusTract1990': u'  39  ',
 u'censusTract2000': u'  39  ',
 u'censusTract2010': u'  39  ',
 u'cityCouncilDistrict': u'33',
 u'civilCourtDistrict': u'01',
 u'communityDistrict': u'302',
 u'communityDistrictBoroughCode': u'3',
 u'communityDistrictNumber': u'02',
 u'communitySchoolDistrict': u'15',
 u'congressionalDistrict': u'08',
 u'crossStreetNamesFlagIn': u'E',
 u'dcpPreferredLgcForStreet1': u'01',
 u'dcpPreferredLgcForStreet2': u'01',
 u'dotStreetLightContractorArea': u'3',
...

##### Errors

In cases where the geocoder does not work, it will still return a dict. You must look at the value for message to see what happened.

>>> g.intersection('atlantic ave', 'nevins st', 'manhattan')
{u'boroughCode1In': u'1',
u'censusTract1990': u'      ',
u'censusTract2000': u'      ',
u'censusTract2010': u'      ',
u'crossStreetNamesFlagIn': u'E',
u'firstBoroughName': u'MANHATTAN',
u'firstStreetNameNormalized': u'ATLANTIC AVENUE',
u'geosupportFunctionCode': u'2',
u'geosupportReturnCode': u'11',
u'message': u"'ATLANTIC AVE' NOT RECOGNIZED. THERE ARE NO SIMILAR NAMES",
u'secondStreetNameNormalized': u'NEVINS ST',
u'streetName1In': u'ATLANTIC AVE',
u'streetName2In': u'NEVINS ST',
u'workAreaFormatIndicatorIn': u'C'}

The messages are generally very helpful.

### Documentation

Take a look at the [Python documentation][] for details on using the bindings, which closely follows the [DoITT documentation][] (requires account/login).

[Python documentation]: https://nyc-geoclient.readthedocs.org/ [DoITT documentation]: http://developer.cityofnewyork.us/api/geoclient-api-beta

### License

BSD.

Metadata

Release files for nyc_geoclient 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nyc_geoclient 0.0.2
File Size Uploaded Provenance
nyc_geoclient-0.0.2.tar.gz 5.5 kB Without provenance Details

Release files / nyc_geoclient-0.0.2.tar.gz

Download URL nyc_geoclient-0.0.2.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d4c664908bc80e3b7a6dc49b3c96624eb25420734346e7d768fde97bf66738cf
BLAKE2b-256 checksum
How to use checksums
48bc26cf7e4a139f1b319a9328e0a769a680f248d8ee11ba018c47263fc2c8e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for nyc_geoclient 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page