NSN API Documentation (v1.0)

The API is available at https://api.nsn.org.uk/v1/

Documentation homepage https://docs.api.nsn.org.uk/


CURL example

The example below shows you how to authenticate against the API using CURL, and hit the /areas endpoint.

If you have an username and password, enter them here to populate the examples:

POST /v1/jwt

To authenticate against the API you must first POST your username and password in a JSON object in the body of your request to the /jwt endpoint to retrieve your JWT IdToken.

import http.client

conn = http.client.HTTPSConnection("api.nsn.org.uk")
payload = "{ \"username\": \"{username}\", \"password\": \"{password}\"\r\n}"
headers = {
  'Content-Type': 'text/plain'
}
conn.request("POST", "/v1/jwt", payload, headers)
res = conn.getresponse()
data = json.load(res)
print(data)

GET /v1/jwt/areas

Extract the IdToken from the JSON response and include it as an Authorization token within the header of all subsequent requests

import http.client

conn = http.client.HTTPSConnection("api.nsn.org.uk")
payload = ''
headers = {
  'Authorization': 'Bearer {IdToken}'
}
conn.request("GET", "/v1/jwt/areas", payload, headers)
res = conn.getresponse()
data = json.load(res)
print(data)

PUT /v1/jwt/

The initial token also returns a RefreshToken which you may use to refresh your IdToken for 30 days. To refresh a token, PUT a request with your token in a JSON object in the body of your request to retrieve a new IdToken.

import http.client

conn = http.client.HTTPSConnection("api.nsn.org.uk")
payload = "{ \"token\": \"{RefreshToken}\"\r\n}"
headers = {
  'Content-Type': 'text/plain'
}
conn.request("PUT", "/v1/jwt", payload, headers)
res = conn.getresponse()
data = json.load(res)
print(data)

Documentation homepage https://docs.api.nsn.org.uk/