# Nearest

{% hint style="warning" %}

### API test authentication

The Open API block allows you to test OS APIs directly from the page with example data and parameters. To use this feature, you will need to add your API Key or OAuth2 token to the authentication field.

For help generating an API Key or OAuth2 token, please see the [Getting started with an API project](https://docs.os.uk/os-apis/core-concepts/getting-started-with-an-api-project) or [OAuth2 documentation](https://docs.os.uk/os-apis/accessing-os-apis/oauth-2-api).
{% endhint %}

## GET /nearest

> Find the features closest to a given point

```json
{"openapi":"3.0.1","info":{"title":"OS Names API","version":"v1.0"},"tags":[{"name":"Nearest","description":"Find the features closest to a given point."}],"servers":[{"url":"https://api.os.uk/search/names/v1"}],"security":[{"api-key":[],"api-key-header":[],"oauth2":[]}],"components":{"securitySchemes":{"api-key":{"type":"apiKey","name":"key","in":"query"}},"schemas":{"SearchResponse":{"type":"object","properties":{"header":{"$ref":"#/components/schemas/Header"},"results":{"type":"array","items":{"$ref":"#/components/schemas/GazetteerEntry"}}}},"Header":{"type":"object","properties":{"uri":{"type":"string"},"query":{"type":"string"},"format":{"type":"string"},"maxresults":{"type":"integer"},"offset":{"type":"integer"},"totalresults":{"type":"integer"}}},"GazetteerEntry":{"type":"object","properties":{"GAZETTEER_ENTRY":{"type":"object","properties":{"ID":{"type":"string"},"NAMES_URI":{"type":"string"},"NAME1":{"type":"string"},"TYPE":{"type":"string"},"LOCAL_TYPE":{"type":"string"},"GEOMETRY_X":{"type":"number"},"GEOMETRY_Y":{"type":"number"},"MOST_DETAIL_VIEW_RES":{"type":"integer"},"LEAST_DETAIL_VIEW_RES":{"type":"integer"},"MBR_XMIN":{"type":"number"},"MBR_YMIN":{"type":"number"},"MBR_XMAX":{"type":"number"},"MBR_YMAX":{"type":"number"},"POSTCODE_DISTRICT":{"type":"string"},"POSTCODE_DISTRICT_URI":{"type":"string"},"POPULATED_PLACE":{"type":"string"},"POPULATED_PLACE_URI":{"type":"string"},"POPULATED_PLACE_TYPE":{"type":"string"},"COUNTY_UNITARY":{"type":"string"},"COUNTY_UNITARY_URI":{"type":"string"},"COUNTY_UNITARY_TYPE":{"type":"string"},"REGION":{"type":"string"},"REGION_URI":{"type":"string"},"COUNTRY":{"type":"string"},"COUNTRY_URI":{"type":"string"}}}}}}},"paths":{"/nearest":{"get":{"tags":["Nearest"],"summary":"Find the features closest to a given point","operationId":"nearestAddress","parameters":[{"name":"point","in":"query","description":"A set of British National Grid coordinates to which the nearest record in a straight line should be found.","required":true,"schema":{"type":"string"}},{"name":"radius","in":"query","description":"The radius in metres to search within. Minimum = 0.01, Maximum = 1,000 . Default = 100","schema":{"type":"number","minimum":0.01,"maximum":1000}},{"name":"format","in":"query","description":"The format the response will be returned in.","schema":{"type":"string","enum":["JSON","XML"]}},{"name":"fq","in":"query","description":"Filters the results by bounding box or local_type. ","schema":{"type":"string","enum":["Airfield","Airport","Bay","Beach","Bus_Station","Channel","Chemical_Works","Cirque_Or_Hollow","City","Cliff_Or_Slope","Coach_Station","Coastal_Headland","Electricity_Distribution","Electricity_Production","Estuary","Further_Education","Gas_Distribution_or_Storage","Group_Of_Islands","Hamlet","Harbour","Helicopter_Station","Heliport","Higher_or_University_Education","Hill_Or_Mountain","Hill_Or_Mountain_Ranges","Hospice","Hospital","Inland_Water","Island","Medical_Care_Accommodation","Named_Road","Non_State_Primary_Education","Non_State_Secondary_Education","Numbered_Road","Oil_Distribution_or_Storage","Oil_Refining","Oil_Terminal","Other_Coastal_Landform","Other_Landcover","Other_Landform","Other_Settlement","Passenger_Ferry_Terminal","Port_Consisting_of_Docks_and_Nautical_Berthing","Postcode","Primary_Education","Railway","Railway_Station","Road_User_Services","Sea","Secondary_Education","Section_Of_Named_Road","Section_Of_Numbered_Road","Special_Needs_Education","Spot_Height","Suburban_Area","Tidal_Water","Town","Tramway","Urban_Greenspace","Valley","Vehicular_Ferry_Terminal","Vehicular_Rail_Terminal","Village","Waterfall","Wetland","Woodland_Or_Forest"]}}],"responses":{"200":{"description":"Retrieves addresses based on a free text search.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SearchResponse"}},"application/xml":{"schema":{"$ref":"#/components/schemas/SearchResponse"}}}}}}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.os.uk/os-apis/accessing-os-apis/os-names-api/technical-specification/nearest.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
