> For the complete documentation index, see [llms.txt](https://docs.os.uk/os-apis/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.os.uk/os-apis/accessing-os-apis/os-names-api/getting-started-with-example-queries-using-node.js.md).

# Getting started with example queries using Node.js

This page provides example queries that you can adapt and use with OS Names API. The examples use Node.js the popular [axios](https://github.com/axios/axios) module.

## What you need

* OS Names API added to an API project in the OS Data Hub with an API Key; see [Getting started with an API project](/os-apis/core-concepts/getting-started-with-an-api-project.md) for more information
* A text editor like Visual Studio Code
* A working installation of [Node.js](https://nodejs.org/) and the [axios](https://github.com/axios/axios) module

## Example queries using Node.js

{% hint style="info" %}
These examples rely on a working installation of [Node.js](https://nodejs.org/) and the popular [axios](https://github.com/axios/axios) module.
{% endhint %}

### Running a `find` query

{% code overflow="wrap" %}

```javascript
const axios = require('axios');

const apiKey = 'INSERT_YOUR_API_KEY_HERE';

async function find() {
    axios.get('https://api.os.uk/search/names/v1/find?query=Southampton&key=' + apiKey)
    .then(function (response) {
        /* For explanation and debugging purposes we display the full response from the API in the console */
        console.log(JSON.stringify(response.data, null, 2));
    });
}
find()
```

{% endcode %}

### Running a `nearest` query.

{% code overflow="wrap" %}

```javascript
const axios = require('axios');

const apiKey = 'INSERT_YOUR_API_KEY_HERE';

async function nearest() {
    axios.get('https://api.os.uk/search/names/v1/nearest?point=440200,449300&key=' + apiKey)
    .then(function (response) {
        /* For explanation and debugging purposes we display the full response from the API in the console */
        console.log(JSON.stringify(response.data, null, 2));
    });
}
nearest()
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.os.uk/os-apis/accessing-os-apis/os-names-api/getting-started-with-example-queries-using-node.js.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
