# Lookup lists and additional features

# Getting local authorities from postcodes

To get the local authority details from a postcode issue a GET to /api/rest/open/postcode/{uk-postcode}

Example: GET /api/rest/portal/postcode/W1W 7RG

The response will contain not only the local authority id, but other details that could be displayed to the home seeker.

This is the response from the previous example:

{
  "id": 322,
  "name": "Westminster",
  "longName": "Westminster City Council",
  "type": "London borough",
  "county": {
    "id": 27,
    "name": "London",
    "region": {
      "id": 13,
      "name": "London"
    }
  }
}

If the postcode is not valid the API will respond with an error code.

To validate the UK postcode client side, this is an acceptable regular expression in js.

/^([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z]))))\\s?[0-9][A-Za-z]{2})$/i;

# Customer form lookup lists

There are some lookup lists, that even when they are unlikely to change, they are not static, and they should be requested to the API.

That's the case of the lists of living circumstances, working circumstances, buying interest periods, best time to contact, genders, ethnicities, nationalities, religions, sexualities, marital statuses, home ownership statuses and relationship statuses.

For buying interest periods and best time to contact, the result will always have the same structure, a collection of objects with two fields: id and name, where id should be the field to be sent in corresponding payload fields when submitting forms.

In the case of working circumstances, an extra field is returned: working, which is a boolean value to indicate if the working circumstances is related to the "currently working" status or not, useful to determine if working details should be asked to the home seeker or not.

In the case of living circumstances, an extra field is returned: owner, which is a boolean value to indicate if the living circumstances is related to the "home owner" status or not, useful to determine which options to display when requesting the home ownership status of the home seeker.

In the case of genders, ethnicities, nationalities, religions, sexualities, marital statuses, home ownership statuses and relationship statuses, an extra field is returned: slug, which is a string and represents an URL friendly "slug" of the value.

Example:

{
  "data": [
    {
      "id": 1,
      "name": "Immediately"
    },
    {
      "id": 2,
      "name": "Within 3 months"
    },
    {
      "id": 3,
      "name": "3 to 6 months"
    },
    {
      "id": 4,
      "name": "6 to 12 months"
    },
    {
      "id": 5,
      "name": "I am just looking"
    }
  ]
}

# Living circumstances

GET /api/rest/open/lists/living-circumstances

# Working circumstances

GET /api/rest/open/lists/working-circumstances

# Buying interest periods

GET /api/rest/open/lists/buying-interest-periods

# Best time to contact

GET /api/rest/open/lists/best-time-to-contact

# Genders

GET /api/rest/open/lists/genders

# Ethnicities

GET /api/rest/open/lists/ethnicities

# Nationalities

GET /api/rest/open/lists/nationalities

# Religions

GET /api/rest/open/lists/religions

# Sexualities

GET /api/rest/open/lists/sexualities

# Marital statuses

GET /api/rest/open/lists/marital-statuses

# Home ownership statuses

GET /api/rest/open/lists/home-ownership-statuses

# Relationship statuses

GET /api/rest/open/lists/relationship-statuses

# Local authorities

GET /api/rest/open/lists/local-authorities

# Counties

GET /api/rest/open/lists/counties