CDRC API Home Page

Welcome to the CDRC API Information Portal. You can find information about how to access the CDRC API and its data and resources here.

Introduction - About the CDRC API

The CDRC API is a repository of datasets of geographical data prepared by CDRC for the consumption of academic, public sector and private sector clients and colleagues.

The API is constructed to OpenAPI Specification Version 3 which provides a secure and easy to use interface which is platform and programming language agnostic.

CDRC Datasets

Register for a CDRC API Account

The CDRC API is not open access - you will first need to register for an account before you can use the API resources.

Register for a free account here.

Logging in to the API

To access the data in the CDRC API you will first need to log in to be issued with a JSON Web Token. You can then use this token to authorise your subsequent API data requests and gain access to your required dataset.

A login request may look something like the following:


                    POST /Login HTTP/1.1
                    Host: https://api.cdrc.ac.uk
                    Accept: application/json
                    Content-Type: application/json
                    {
                        "username": "dsmith",
                        "password": "APIGuru1"
                    }
                    

cURL Method:


                    curl -X 'POST' \'https://api.cdrc.ac.uk/Login' \
                    -H 'accept: application/json' \
                    -H 'Content-Type: application/json' \
                    -d '{
                    "username": "dsmith",
                    "password": "APIGuru1"
                    }'
                

If successful, the response body returned from the server will look something like the following:


                {
                    "token": "12345abcdef",
                    "message": "Login successful"
                }
                

You can now use your returned token value to access the datasets.

Accessing API Data

With your token supplied when you successfully log in you can now access the data.

You can input the token into the header section of your request using the following format:


                Header Name: Authorization
                
                For the value: input 'Bearer' then [space] and then your token value.

                An example: "Bearer 12345abcdef"                
                

Accessing data by a single value search term - GET method

An example using the API's IUC dataset, searched by a single postcode:

                 
                    GET /v1/IUC2018/PostCode?postCode=L693BX HTTP/1.1
                    Host: https://api.cdrc.ac.uk
                    Accept: application/json
                    Authorization: Bearer 12345abcdef
                

cURL Method:


                    curl -X 'GET' \'https://api.cdrc.ac.uk/v1/IUC2018/PostCode?postCode=L693BX' \
                    -H 'accept: application/json' \
                    -H 'Authorization: Bearer 12345abcdef'
                

Accessing data by a multiple value search terms - POST method

An example using the API's IUC dataset, searched by multiple postcodes:


                    POST /v1/IUC2018/PostCodes HTTP/1.1
                    Host: https://api.cdrc.ac.uk
                    Accept: application/json
                    Content-Type: application/json
                    [
                      "L693BX",
                      "LS29JT"
                    ]
                

cURL Method:


                    curl -X 'POST' \'https://api.cdrc.ac.uk/v1/IUC2018/PostCodes' \
                    -H 'accept: application/json' \
                    -H 'Authorization: Bearer 12345abcdef' \
                    -H 'Content-Type: application/json' \
                    -d '[
                    "L693BX",
                    "LS29JT"
                    ]'
                

Swagger Interface to the CDRC API

The CDRC API is equipped with the Swagger Foundation documentation framework.

You can view a detailed list of all the currently available CDRC API implementation endpoints in the Swagger interface and use this interface to aid you in developing programmatic interfaces to the API resources.