[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"blog-\u002Fblog\u002Fbuilding-a-plss-legal-description-autocomplete-with-the-township-america-api":3},{"id":4,"title":5,"body":6,"cover":389,"date":390,"description":391,"draft":392,"extension":393,"meta":394,"navigation":73,"path":397,"seo":398,"stem":399,"tags":400,"__hash__":406},"blog\u002Fblog\u002Fbuilding-a-plss-legal-description-autocomplete-with-the-township-america-api.md","Building a PLSS Legal Description Autocomplete with the Township America API",{"type":7,"value":8,"toc":382},"minimark",[9,18,21,26,35,38,42,45,152,155,162,211,230,279,283,290,293,297,300,347,355,359,371,378],[10,11,12,13,17],"p",{},"Ask a user to type a PLSS legal description from memory and you will collect typos. A string like ",[14,15,16],"code",{},"T15N R2E Sec 22 NW, 6th Principal Meridian"," has four moving parts, each with its own notation, and one transposed character (R2E instead of R3E, for example) points the result at a different section a few miles away. If your app accepts legal descriptions as input, the text field itself is where most of the errors start.",[10,19,20],{},"A PLSS autocomplete fixes that at the source. As the user types, the field suggests valid legal descriptions and lets them pick one instead of finishing it by hand. In this post you will build that typeahead against the Township America API, handle the case where the same township and range exists under more than one principal meridian, and hand the chosen description to the lookup endpoint to get coordinates and a boundary back.",[22,23,25],"h2",{"id":24},"what-the-autocomplete-endpoint-does","What the autocomplete endpoint does",[10,27,28,29,34],{},"The Township America ",[30,31,33],"a",{"href":32},"\u002Fapi","REST API"," exposes single lookup, batch, autocomplete, and map tile endpoints, alongside the Python and TypeScript SDKs and an MCP server for AI agents. The autocomplete endpoint is the one built for input: you send a partial legal description and it returns suggestions that complete it.",[10,36,37],{},"Because PLSS resolution covers 30+ PLSS states and 37 principal meridians, a partial query is often ambiguous on its own. The endpoint returns each matching candidate with the principal meridian it resolves under, so the user can choose the correct one rather than guessing. Texas descriptions work in the same field: the Texas Abstract, Block, and Survey grid resolver means an Abstract reference autocompletes the same way a township-range-section string does.",[22,39,41],{"id":40},"build-the-typeahead","Build the typeahead",[10,43,44],{},"The pattern has three parts: debounce the keystrokes so you are not firing a request per character, call the endpoint, and render the suggestions. Here is a vanilla JavaScript version you can adapt to any framework.",[46,47,52],"pre",{"className":48,"code":49,"language":50,"meta":51,"style":51},"language-js shiki shiki-themes material-theme-lighter github-light github-dark","const input = document.querySelector(\"#legal-search\")\nconst list = document.querySelector(\"#suggestions\")\n\nlet timer\ninput.addEventListener(\"input\", () => {\n  clearTimeout(timer)\n  const query = input.value.trim()\n  if (query.length \u003C 3) return\n  timer = setTimeout(() => fetchSuggestions(query), 200)\n})\n\nasync function fetchSuggestions(query) {\n  const res = await fetch(`\u002Fapi\u002Fplss-autocomplete?q=${encodeURIComponent(query)}`)\n  const results = await res.json()\n  renderSuggestions(results)\n}\n","js","",[14,53,54,62,68,75,81,87,93,99,105,111,117,122,128,134,140,146],{"__ignoreMap":51},[55,56,59],"span",{"class":57,"line":58},"line",1,[55,60,61],{},"const input = document.querySelector(\"#legal-search\")\n",[55,63,65],{"class":57,"line":64},2,[55,66,67],{},"const list = document.querySelector(\"#suggestions\")\n",[55,69,71],{"class":57,"line":70},3,[55,72,74],{"emptyLinePlaceholder":73},true,"\n",[55,76,78],{"class":57,"line":77},4,[55,79,80],{},"let timer\n",[55,82,84],{"class":57,"line":83},5,[55,85,86],{},"input.addEventListener(\"input\", () => {\n",[55,88,90],{"class":57,"line":89},6,[55,91,92],{},"  clearTimeout(timer)\n",[55,94,96],{"class":57,"line":95},7,[55,97,98],{},"  const query = input.value.trim()\n",[55,100,102],{"class":57,"line":101},8,[55,103,104],{},"  if (query.length \u003C 3) return\n",[55,106,108],{"class":57,"line":107},9,[55,109,110],{},"  timer = setTimeout(() => fetchSuggestions(query), 200)\n",[55,112,114],{"class":57,"line":113},10,[55,115,116],{},"})\n",[55,118,120],{"class":57,"line":119},11,[55,121,74],{"emptyLinePlaceholder":73},[55,123,125],{"class":57,"line":124},12,[55,126,127],{},"async function fetchSuggestions(query) {\n",[55,129,131],{"class":57,"line":130},13,[55,132,133],{},"  const res = await fetch(`\u002Fapi\u002Fplss-autocomplete?q=${encodeURIComponent(query)}`)\n",[55,135,137],{"class":57,"line":136},14,[55,138,139],{},"  const results = await res.json()\n",[55,141,143],{"class":57,"line":142},15,[55,144,145],{},"  renderSuggestions(results)\n",[55,147,149],{"class":57,"line":148},16,[55,150,151],{},"}\n",[10,153,154],{},"Two choices here matter. The minimum query length (three characters) keeps you from sending requests for input too short to match anything useful. The 200 millisecond debounce waits for a short pause in typing before it calls out, which collapses a burst of keystrokes into a single request. Both reduce the request volume you send, and request volume is what the API meters.",[10,156,157,158,161],{},"Notice that the fetch above calls ",[14,159,160],{},"\u002Fapi\u002Fplss-autocomplete",", a route on your own backend, not the Township America endpoint directly. That is deliberate. A typeahead runs in the browser, and a request from the browser would expose your API key to anyone who opens the network tab. Keep the key on the server and let a thin proxy forward the query:",[46,163,165],{"className":48,"code":164,"language":50,"meta":51,"style":51},"\u002F\u002F server route: \u002Fapi\u002Fplss-autocomplete\nexport default async function handler(req, res) {\n  const q = req.query.q\n  const upstream = await fetch(\n    `https:\u002F\u002Fdeveloper.townshipamerica.com\u002Fautocomplete\u002Flegal-location?location=${encodeURIComponent(q)}&limit=5`,\n    { headers: { \"x-api-key\": process.env.TOWNSHIP_API_KEY } },\n  )\n  res.json(await upstream.json())\n}\n",[14,166,167,172,177,182,187,192,197,202,207],{"__ignoreMap":51},[55,168,169],{"class":57,"line":58},[55,170,171],{},"\u002F\u002F server route: \u002Fapi\u002Fplss-autocomplete\n",[55,173,174],{"class":57,"line":64},[55,175,176],{},"export default async function handler(req, res) {\n",[55,178,179],{"class":57,"line":70},[55,180,181],{},"  const q = req.query.q\n",[55,183,184],{"class":57,"line":77},[55,185,186],{},"  const upstream = await fetch(\n",[55,188,189],{"class":57,"line":83},[55,190,191],{},"    `https:\u002F\u002Fdeveloper.townshipamerica.com\u002Fautocomplete\u002Flegal-location?location=${encodeURIComponent(q)}&limit=5`,\n",[55,193,194],{"class":57,"line":89},[55,195,196],{},"    { headers: { \"x-api-key\": process.env.TOWNSHIP_API_KEY } },\n",[55,198,199],{"class":57,"line":95},[55,200,201],{},"  )\n",[55,203,204],{"class":57,"line":101},[55,205,206],{},"  res.json(await upstream.json())\n",[55,208,209],{"class":57,"line":107},[55,210,151],{},[10,212,213,214,217,218,221,222,225,226,229],{},"Rendering the suggestions is the last client-side piece. The endpoint returns a GeoJSON FeatureCollection, and each feature's properties carry the normalized ",[14,215,216],{},"legal_location"," (which names the principal meridian) along with the ",[14,219,220],{},"state"," and ",[14,223,224],{},"county"," it falls in. Check the ",[30,227,228],{"href":32},"API reference"," for the full field list, then map the features onto list items the user can click:",[46,231,233],{"className":48,"code":232,"language":50,"meta":51,"style":51},"function renderSuggestions(results) {\n  list.innerHTML = \"\"\n  for (const { properties: item } of results.features ?? []) {\n    const li = document.createElement(\"li\")\n    li.textContent = `${item.legal_location} (${item.state})`\n    li.addEventListener(\"click\", () => selectSuggestion(item))\n    list.appendChild(li)\n  }\n}\n",[14,234,235,240,245,250,255,260,265,270,275],{"__ignoreMap":51},[55,236,237],{"class":57,"line":58},[55,238,239],{},"function renderSuggestions(results) {\n",[55,241,242],{"class":57,"line":64},[55,243,244],{},"  list.innerHTML = \"\"\n",[55,246,247],{"class":57,"line":70},[55,248,249],{},"  for (const { properties: item } of results.features ?? []) {\n",[55,251,252],{"class":57,"line":77},[55,253,254],{},"    const li = document.createElement(\"li\")\n",[55,256,257],{"class":57,"line":83},[55,258,259],{},"    li.textContent = `${item.legal_location} (${item.state})`\n",[55,261,262],{"class":57,"line":89},[55,263,264],{},"    li.addEventListener(\"click\", () => selectSuggestion(item))\n",[55,266,267],{"class":57,"line":95},[55,268,269],{},"    list.appendChild(li)\n",[55,271,272],{"class":57,"line":101},[55,273,274],{},"  }\n",[55,276,277],{"class":57,"line":107},[55,278,151],{},[22,280,282],{"id":281},"handle-the-meridian-ambiguity","Handle the meridian ambiguity",[10,284,285,286,289],{},"Townships and ranges are numbered relative to a principal meridian, and those grids repeat across the country. ",[14,287,288],{},"T2N R3E"," is a valid origin under several of the 37 principal meridians, so a short query can match real sections in different states. This is the single most common source of a confident-looking wrong answer in PLSS software.",[10,291,292],{},"Showing the meridian and state on each suggestion, as the render step above does, turns that ambiguity into a choice the user makes on purpose. A landman working the Anadarko Basin sees the Indian Meridian candidate and picks it; a user in Colorado picks the 6th Principal Meridian version of the same township and range. The field stops guessing, and the user confirms the one description they meant.",[22,294,296],{"id":295},"complete-the-flow-with-a-lookup","Complete the flow with a lookup",[10,298,299],{},"Autocomplete validates the input. To do something with it, pass the chosen description to the single lookup endpoint, which returns a GeoJSON FeatureCollection with the parcel centroid, the full BLM survey polygon boundary, state, county, and principal meridian.",[46,301,303],{"className":48,"code":302,"language":50,"meta":51,"style":51},"async function selectSuggestion(item) {\n  input.value = item.legal_location\n  list.innerHTML = \"\"\n  const res = await fetch(\n    `\u002Fapi\u002Fplss-lookup?location=${encodeURIComponent(item.legal_location)}`,\n  )\n  const geojson = await res.json()\n  drawOnMap(geojson) \u002F\u002F your Leaflet, Mapbox, or ArcGIS handler\n}\n",[14,304,305,310,315,319,324,329,333,338,343],{"__ignoreMap":51},[55,306,307],{"class":57,"line":58},[55,308,309],{},"async function selectSuggestion(item) {\n",[55,311,312],{"class":57,"line":64},[55,313,314],{},"  input.value = item.legal_location\n",[55,316,317],{"class":57,"line":70},[55,318,244],{},[55,320,321],{"class":57,"line":77},[55,322,323],{},"  const res = await fetch(\n",[55,325,326],{"class":57,"line":83},[55,327,328],{},"    `\u002Fapi\u002Fplss-lookup?location=${encodeURIComponent(item.legal_location)}`,\n",[55,330,331],{"class":57,"line":89},[55,332,201],{},[55,334,335],{"class":57,"line":95},[55,336,337],{},"  const geojson = await res.json()\n",[55,339,340],{"class":57,"line":101},[55,341,342],{},"  drawOnMap(geojson) \u002F\u002F your Leaflet, Mapbox, or ArcGIS handler\n",[55,344,345],{"class":57,"line":107},[55,346,151],{},[10,348,349,350,354],{},"Because the lookup returns the actual survey polygon and not just a center point, you can draw the parcel outline straight onto a map, run a spatial query against it, or write it to a record. The same pattern underpins server-side work too: if you need to resolve many descriptions at once rather than one at a time, the batch endpoint accepts up to 100 per request. For the mechanics of that conversion on its own, see the guide on ",[30,351,353],{"href":352},"\u002Fguides\u002Fconvert-section-township-range-to-coordinates","converting section, township, and range to coordinates",".",[22,356,358],{"id":357},"choosing-an-api-tier","Choosing an API tier",[10,360,361,362,366,367,370],{},"A typeahead is request-heavy by nature: even with debouncing, an active search field sends more calls than a one-off lookup does. The metered API tiers are priced on request volume, so start on the Build tier while traffic is light and move up to Scale as your usage grows. Current limits and prices are on the ",[30,363,365],{"href":364},"\u002Fpricing","pricing page",", and the ",[30,368,369],{"href":32},"API quickstart"," walks through issuing a key.",[10,372,373,374,377],{},"You now have a legal description search field that suggests valid PLSS descriptions as the user types, disambiguates by principal meridian, keeps your API key off the client, and resolves the chosen description to a boundary on the map. From here, the natural extension is to cache common queries in your proxy to trim request volume further, or to pass the ",[14,375,376],{},"proximity"," parameter so suggestions near the user's map view rank first.",[379,380,381],"style",{},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":51,"searchDepth":64,"depth":64,"links":383},[384,385,386,387,388],{"id":24,"depth":64,"text":25},{"id":40,"depth":64,"text":41},{"id":281,"depth":64,"text":282},{"id":295,"depth":64,"text":296},{"id":357,"depth":64,"text":358},null,"2026-10-06T10:00:00Z","Build a PLSS autocomplete for legal description search with the Township America API: debounced typeahead, meridian disambiguation, and GeoJSON output.",false,"md",{"author":395,"category":396},"Township America","guides","\u002Fblog\u002Fbuilding-a-plss-legal-description-autocomplete-with-the-township-america-api",{"title":5,"description":391},"blog\u002Fbuilding-a-plss-legal-description-autocomplete-with-the-township-america-api",[401,402,403,404,405],"API","PLSS","Developer","Autocomplete","Legal Description","K61u3N8kJOqQR5iEc-4jv6TFlKSfsIfhxjLWRmBHHcU"]