Example queries

This page provides example queries that you can adapt and use with OS Names API. The examples use Node.js the popular axios module.

What you need

Example queries using Node.js

These examples rely on 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/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()

Running a nearest query.

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

Last updated