Skip to content

Residential Registry

davidmagnussonvalueguard edited this page Jun 28, 2024 · 93 revisions

Test Account

We have a free test account that you may use to access our api.
If you want to use it please send an e-mail to info@valueguard.se

Import the whole registry to MySQL-database

The code below gives an example of how to use the client to fetch the whole registry.

import mysql.connector 
import valueguard

vgClient = valueguard.Client()
vgClient.authenticate("<username>", "<password>")

mydb = mysql.connector.connect(
   host="<db_host>",
   user="<db_username>",
   passwd="<db_password>",
   database="<db_name>"
)

mycursor = mydb.cursor()

limit = 20000
i = 0
while True:
    data = vgClient.residential_registry(offset=i, limit=limit)
    for residence in data['residences']:
        sql = "INSERT INTO `<table_name>` (`id`, `street`, " \
              "`number`, `letter`, `apartment_nr`,`rooms`, `home_type`, `ownership_type`, `deleted`," \
              "`probability_deleted`, `updated_at`, `updated_from`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, " \
              "%s, %s); "
        val = (residence['id'],
               residence['street'],
               residence['number'],
               residence['letter'],
               residence['apartment_nr'],
               residence['rooms'],
               residence['home_type'],
               residence['ownership_type'],
               residence['deleted'],
               residence['probability_deleted'],
               residence['updated_at'],
               residence['updated_from'])

        mycursor.execute(sql, val)
        mydb.commit()
    fetched_data = data['meta_data']['offset'] + data['meta_data']['response_rows']
    if data['meta_data']['total_nr_records'] <= data['meta_data']['offset'] + data['meta_data']['response_rows']:
        break
    i += data['meta_data']['response_rows']

Search in the registry

Example:

import valueguard

vgClient = valueguard.Client()
vgClient.authenticate("<username>", "<password>")

limit=5

print (vgClient.residential_registry(offset=0, limit=limit, search_criteria={
    "address":"Vangsbyvägen"
}))

print (vgClient.residential_registry(offset=0, limit=limit, search_criteria={
    "address":"Vangsbyvägen 16"
}))

Field list

OBS! You will only be able to fetch the fields that you have access to.

Field name Type Example Description
id varchar(255) 481515 unique id (serial number) for all residences
source: Valueguard
property_key int(8) 170053749 unique id for all properties
source: Fastighetsregistret LMV
address varchar(60) 1:a villagatan 1, 65341 address of the residence (street, nr, letter, postal code, postal area)
source: Fastighetsregistret LMV
street varchar(60) 1:a villagatan street name in address
number list [1,3,None] number of the street in address
letter char(5) A letter of the street in address
entrance varchar(5) U1 entance of the address, empty string (i.e. "") if not specified
is_meter_address tinyint(1) 1 1 = the address is a meter address (i.e. the number of the address is of type "302-12")
0 = the address is not a meter address
postal_code varchar(7) 65341 postal code
postal_area varchar(40) Karlstad postal area
house_nr mediumint(5) 1 unique number on every house belonging to the same property
apartment_nr smallint(4) 1101 unique number on every apartment at the same address
living_space double 137 area of residence in sqm
source: Lägenhetsregistret washed with Fastighetsregistret LMV
apartment_area smallint(4) 137 area of residence in sqm (all home types)
source: Lägenhetsregistret LMV
rooms double 5 number of rooms for areas above 7sqm, excluding kitchen and bathroom (not available for houses)
floor double 2 the floor of the residence
floors double 2 the highest floor on the address
apartment_category tinyint(2) 1 1 = ordinary apartment
2 = special apartment customized for elderly or disabled
3 = student residence
4 = other special residence
9 = missing
kitchen_type tinyint(2) 1 1 = kitchen
2 = kitchenette
3 = kitchen cabinet
4 = no kitchen equipment
9 = unknown
building_purpose tinyint(2) 1 1 = home
2 = industry
3 = society
4 = organization
5 = business building
6 = complement buildning
7 = other buildning
sweref99x int(7) 6583373 X-coordinate (latitude) from SWEREF.
a Swedish positioning system by LMV used from 2007 (note: according to usual standard for sweref-coordinates, the X-coordinate should denote longitude but we have chosen to use the previous standard from the rt90 system in which the x-coordinate denotes latitude)
sweref99y int(7) 413689 Y-coordinate (longitude) from SWEREF.
a Swedish positioning system by LMV used from 2007 (note: see the note for sweref99x)
rt90x double 6586700 X-coordinate (latitude) from RT90.
a Swedish positioning system by LMV used before 2007
rt90y double 1367905 Y-coordinate (longitude) from RT90.
a Swedish positioning system by LMV used before 2007
wgs84lat double 59.3801951334688 Y-coordinate (latitude) from WGS84.
a global positioning system
wgs84lon double 13.4808053113366 X-coordinate (longitude) from WGS84.
a global positioning system
construction_year smallint(4) 1920 building year
The construction_year = 1909 for houses and 1929 for flats/apartments are in some cases used by Lantmäteriet when the true year of construction is unknown. For more info see detailed explanation
owner_id char(11) 769613-3375 organizational number, for example of a housing cooperative
building_type tinyint(2) 33 -1 = missing
1 = bathhouse
2 = fire station
3 = bus station
4 = distribution building
5 = veterinary
6 = army
7 = health care center
8 = university
9 = ice rink
10 = railway station
11 = municipality building
12 = correctional institution
13 = cultural building
14 = police station
15 = treatment plant
16 = riding area
17 = community
18 = hospital
19 = school
20 = sports area
21 = university
22 = water treatment plant
24 = multi arena
30 = detached house
31 = terraced house
32 = townhouse
33 = block of apartments
35 = house with several apartments
40 = other production industry
41 = gas turbine facility
42 = hotel for industries
43 = chemical industry
44 = condensing plant
45 = nuclear plant
46 = food industry
47 = metal- or machine industry
48 = textile industry
49 = wood industry
50 = hydroelectric plant
51 = windmills
52 = heating plant
53 = other industry building
99 = unspecified
type_code smallint(3) 320 113 = farm unit (building value < 50000 SEK)
120 = farm unit (built-up)
213 = house (building value < 50000 SEK)
220 = house (built-up)
221* = house (cottege)
222* = house (3 or more residence buildnings)
320 = rental (residences)
321 = rental (residences & local places)
325 = rental (local places)
823 = special unit.
* = type code ended in 2015 but is in the register. These are the codes for number of residences of 10000 or more. Complete list can be found at the Swedish Tax Agency.
home_type varchar(20) lägenhet the different types of residence are divided into:
radhus (townhouse)
lägenhet (apartment)
kedjehus (terraced house)
villa (house)
lantbruk (farm)
småhus övriga (other houses)
lantbruk övriga (other farms)
okänd (unknown)
ownership_type varchar(30) bostadsrätt the different types of ownership are divided into:
äganderätt (property rights)
bostadsrätt (co-operative apartment)
hyresrätt (rented apartment)
tomträtt (site leasehold)
okänd (unknown), vast majority rentals
living_area smallint(5) 130 area of residence in sqm
source: Fastighetsregistret LMV
ancillary_area smallint(5) 40 ancillary area in sqm, not part of the primary building area
standard_points tinyint(2) 32 a number between 0-59 based on assessed value measuring the condition of the residence, higher number represents better condition (not available for co-operative apartments)
plot_area int(9) 896 area of the plot belonging to the residence in sqm
error_code tinyint(1) 0 1 = suspected error in data
0 = no suspected error in data
Variable explanation
deleted tinyint(1) 0 0 = not deleted
1 = deleted
2 = maybe deleted
OBS! This registry only contains objects with deleted 0 or 2.
For deleted objects, see markups
Variable explanation
probability_deleted decimal(3,2) 0.00 sometimes we know 3/4 out of a group of homes are deleted, but we do not know which 3. Then all get 0.75 here
area_id int(9) 7850 id for area_name
area_name varchar(60) Karlstad_Romstad/Strand Valueguard's own neighbourhood definitions
updated_at varchar(10) 2016-06-19 latest date of update from the sources.
ads: ad date
commercial_site: update date with bank-id
private_user: date for register in system
public_data: date for delivery from LM
sales: contract date
updated_from varchar(60) public_data designates the source of an update
OBS! Only public_data in this registry!
For other sources, see markups.
county_code varchar(2) 05 County code
municipality_code varchar(2) 13 Municipality code
parish_code varchar(2) 02 Parish code
vacation_like_home tinyiny(1) 1 1 = Estimated to be a vacation home
0 = Estimated to not be a vacation home
person_registered tinyiny(1) 0 1 = Someone is registered at the address
0 = No one is registered at the address, or we have not been able to match the address.
person_registered_date varchar(10) 2016-06-19 Update date for person_registered. Objects that never have had someone registered will have the date of our first information of person_registerd(2020-11-16)
first_person_registered_date varchar(10) 2019-03-12 The date when the first person currently living there was registered

Search Criteria fields

OBS! Searching for parameters that you do not have access to will be ignored in the API!

Field name Description Example
id The id of the object 481515
address address with postal code
NOTE this is treated as a "like",
so 'Torgatan' will return both Torgatan and Storgatan
1:a villagatan 1, 65341
apartment_area_max Maximum apartment area 200
apartment_area_min Minimum apartment area 80
apartment_category Category of apartment 4
apartment_nr Appartment number 901
area_id Area’s id 5920
building_purpose Building purpose 1
construction_year_max Maximum construction year 2000
construction_year_min Minimum construction year 1960
floor_max Maximum floor 3
floor_min Minimum floor 2
floors_max Maximum number of floors 8
floors_min Minimum number of floors 6
kitchen_type Kitchen type 3
living_space_max Maximum living space 210
living_space_min Minimum living space 85
owner_id Owner’s id 782600-0312
postal_area Postal area Borlänge
postal_code Postal code 78436
rooms_max Maximum number of rooms 5
rooms_min Minimum number of rooms 2
updated_at_min Minimum update date 2016-08-10
street Street name villagatan
letter House's address letter A
number House's address number 34
entrance Entrance to the residence U1
is_meter_address 1 = the address is a meter address (i.e. the number of the address is of type "302-12")
0 = the address is not a meter address
1
property_key Property's unique id 170053749
ownership_type Type of ownership bostadsrätt
building_type Type of building 21
county_code County code 05
municipality_code Municipality code 13
parish_code Type of building 02
residence_per_building How many residences in the building 1
residence_per_building_min Minimum amount of residences in the building 1
residence_per_building_max Maximum amount of residences in the building 10

Special search criteria fields

Requires special access.

Field name Description Example
SSN Send in social security number and get the home where he/she is registered 202005302399
sensitive_data Signals that a home might be sensitive, for GDPR reasons
0 = Exclude sensitive data, and get only non-sensitive data
1 = Get only sensitive data
For all data, just skip this parameter
0

Raw request

GET

curl https://api.valueguard.se/v1/residential/registry?access_token={ACCESS_TOKEN}&offset={OFFSET}&limit={LIMIT}&{SEARCH_CRITERA AS VALUE-KEY PAIR &address="Vangsbyvägen"...}

Normal use case in Jupyter notebook

Clone this wiki locally