> 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-places-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 Places API. The examples use Node.js the popular [axios](https://github.com/axios/axios) module.

{% hint style="info" %}
Please read this page in conjunction with [Technical specification](/os-apis/accessing-os-apis/os-places-api/technical-specification.md).
{% endhint %}

## What you need

* OS Places 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 popular [axios](https://github.com/axios/axios) module.

## 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/places/v1/find?maxresults=1&query=Ordnance%20Survey,%20Adanac%20Drive,%20SO16&key=' + apiKey)
    .then(function(response) {
        var response = JSON.stringify(response.data, null, 2);
        console.log(response);
    });
}
find();
```

{% endcode %}

## Running a Postcode query

{% code overflow="wrap" %}

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

const apiKey = 'INSERT_YOUR_API_KEY_HERE';

async function postcode() {
    axios.get('https://api.os.uk/search/places/v1/postcode?postcode=SO16&key=' + apiKey)
    .then(function(response) {
        var response = JSON.stringify(response.data, null, 2);
        console.log(response);
    });
}
postcode();
```

{% endcode %}

## Running a UPRN query

{% code overflow="wrap" %}

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

const apiKey = 'INSERT_YOUR_API_KEY_HERE';

async function uprn() {
    axios.get('https://api.os.uk/search/places/v1/uprn?uprn=200010019924&key=' + apiKey)
    .then(function(response) {
        var response = JSON.stringify(response.data, null, 2);
        console.log(response);
    });
}
uprn();
```

{% 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/places/v1/nearest?point=437293,115515&key=' + apiKey)
    .then(function(response) {
        var response = JSON.stringify(response.data, null, 2);
        console.log(response);
    });
}
nearest();
```

{% endcode %}

## Running a Bounding Box query

{% code overflow="wrap" %}

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

const apiKey = 'INSERT_YOUR_API_KEY_HERE';

async function bbox() {
    axios.get('https://api.os.uk/search/places/v1/bbox?bbox=437201,115447,437385,115640&key=' + apiKey)
    .then(function(response) {
        var response = JSON.stringify(response.data, null, 2);
        console.log(response);
    });
}
bbox();
```

{% endcode %}

## Running a Radius query

{% code overflow="wrap" %}

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

const apiKey = 'INSERT_YOUR_API_KEY_HERE';

async function radius() {
    axios.get('https://api.os.uk/search/places/v1/radius?point=437293,115515&radius=100&key=' + apiKey)
    .then(function(response) {
        var response = JSON.stringify(response.data, null, 2);
        console.log(response);
    });
}
radius();
```

{% endcode %}

## Running a Polygon query

{% code overflow="wrap" %}

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

const apiKey = 'INSERT_YOUR_API_KEY_HERE';

function polygon() {
    axios.post('https://api.os.uk/search/places/v1/polygon/?key=' + apiKey, {
        "type" : "Polygon",
        "crs" : {
          "type" : "name",
          "properties" : {
            "name" : "urn:ogc:def:crs:EPSG::27700"
          }
        },
        "coordinates": [[[437226,115652],[437212,115495],[437387,115495],[437368,115663],[437226,115652]]]
    })
    .then(function(response) {
        console.log(response);
    })
    .catch(function(error) {
        console.log(error);
    });
};
polygon();
```

{% 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 dynamically by asking a question.

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

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
