Get Started

Use Chrome Advanced REST Client to try out NHS Data REST API

Google Chrome

Use Google Chrome's REST client.

Open this window in Chrome and click here. Click the install button to install the REST Client. Alternatively, from Chrome, using your favourite search engine enter the search term 'chrome rest client', the first item on the page should take you to the Chrome store where you can install the plug-in.

Download example C# code for getting data from NHS Data REST API

C# Code

Write your own client in C#.

Download Example

The minimum requirements for a C# application for requesting NHS data is shown below. The variable 'responseValue' will contain the JSON string representation of the requested data.

using System;
using System.Net;
using System.IO;

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("");
request.Method = "GET";
request.ContentLength = 0;
request.ContentType = "application/json";

HttpWebResponse response=(HttpWebResponse)request.GetResponse();
if (response.StatusCode!=HttpStatusCode.OK)
    throw new ApplicationException(String.Format("Request failed. Received HTTP {0}", response.StatusCode));

Stream responseStream = response.GetResponseStream();
if (responseStream != null)
    StreamReader reader = new StreamReader(responseStream);
    string responseValue=reader.ReadToEnd();
Download example JavaScript code using Angular for getting data from NHS Data REST API

JavaScript Code Using Angular.js

Write your own web client in JavaScript using Angular.js.

Download Example

The code below renders a text box, a submit button and a text area. On clicking submit data will be retreived and displayed in the text area. Simply copy this into a file with the extension .htm and open in a browser to try it out. Remember to replace [key] with the key you receive when you have registered.

  <h1>NHS Data ReST Client Example</h1>
  <div ng-app="NHSDataRestClientExample" ng-controller="NHSDataController as ctrl">
   <input ng-model="ctrl.getUrl" style="width:100%" />
   <br />
   <button ng-click="ctrl.submitButtonClick()">Submit</button>
   <br />
   <textarea ng-model="ctrl.dataDisplay" style="width:100%;height:200px;"></textarea>
  <script src=""></script>
      .module("NHSDataRestClientExample", [])

    NHSDataController.$inject = ["$http"];

    function NHSDataController($http) {
      var vm = this;
      console.log("Started controller");

      vm.getUrl = "[key]/ods/egpcur?Organisation Code=G0102";
      vm.dataDisplay = '';
      vm.submitButtonClick = submitButtonClick;

      function submitButtonClick() {
        vm.dataDisplay = "Getting data, please wait...";
            function (data) {
              // Get data for the first item returned only then convert the data to a JSON object.
              var JSONDataObj = JSON.parse(data[0].data);
              // Construct the datathat we will display in the textarea.
              vm.dataDisplay = 'Data:\n' + JSON.stringify(JSONDataObj);
              // Access specific attributes in the data.
              vm.dataDisplay += '\n\nName: ' + JSONDataObj.Name;
              vm.dataDisplay += '\nPostcode: ' + JSONDataObj.Name;
            function (err) {
Example JavaScript code using Node.js for getting data from NHS Data REST API

JavaScript Code Using Node.js

Write your own server side client in JavaScript using Node.js.

The code snippet below shows how to retrieve data from a server side Node.js application. Remember to replace [key] with the key you receive when registered.

var http=require('http');

var uri="[key]/ods/egpcur?Organisation Code=G0102";

  var responseString='';
    // We've got the full response now convert to JSON object.
    var JSONObj=JSON.parse(responseString);
}).on('error',function(e) {
    // Something went wrong.