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 module.

Please read this page in conjunction with Technical specification.

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 for more information.

  • A text editor like Visual Studio Code

  • A working installation of Node.js and the popular axios module.

Running a Find query

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();

Running a Postcode query

Running a UPRN query

Running a Nearest query

Running a Bounding Box query

Running a Radius query

Running a Polygon query

Last updated

Was this helpful?