congressapi / districts.getDistrictFromLatLong

districts.getDistrictFromLatLong gets the district that a provided latitude/longitude pair falls within.

Parameters

There are two required parameters for getDistrictFromLatLong:

  • latitude: latitude of coordinate
  • longitude: longitude of coordinate
  • districts=2012: optional parameter indicating that you want the districts that are in effect for the 2012 election. If omitted (or anything other than 2012) the districts from the 2010 election (and in effect for purposes of representation until January 2013) will be returned.

Errors

Errors are indicated by setting the HTTP status code to 400 and returning a text string describing the error. The following errors may be encountered in districts.getZipsFromDistrict:

  • Missing Parameter: returned if latitude or longitude parameter is not provided
  • Point not within a congressional district: Point does not fall within a congressional district

Examples

districts.getDistrictFromLatLong.xml?latitude=35.778788&longitude=-78.787805

<pre> &lt;response&gt; &lt;districts&gt; &lt;district&gt; &lt;state&gt;NC&lt;/state&gt; &lt;number&gt;4&lt;/number&gt; &lt;/district&gt; &lt;/districts&gt; &lt;/response&gt; </pre>

districts.getDistrictFromLatLong.json?latitude=35.778788&longitude=-78.787805

<pre> {"response": {"districts": [{"district": {"state": "NC", "number": "4"}}] } } </pre>