Skip to content

Instantly share code, notes, and snippets.

@hugoledoux
Created March 17, 2026 07:03
Show Gist options
  • Select an option

  • Save hugoledoux/e3b98491eb06676f9b6034af2fa70b04 to your computer and use it in GitHub Desktop.

Select an option

Save hugoledoux/e3b98491eb06676f9b6034af2fa70b04 to your computer and use it in GitHub Desktop.
6-digit NL postcode to BAG pand_id
import requests
base_url = "https://service.pdok.nl/lv/bag/wfs/v2_0"
params = {
"service": "WFS",
"version": "2.0.0",
"request": "GetFeature",
"typeName": "bag:verblijfsobject",
"outputFormat": "json",
"filter": (
"<Filter><And>"
"<PropertyIsEqualTo><PropertyName>postcode</PropertyName>"
"<Literal>2628BL</Literal></PropertyIsEqualTo>"
"<PropertyIsEqualTo><PropertyName>huisnummer</PropertyName>"
"<Literal>134</Literal></PropertyIsEqualTo>"
"</And></Filter>"
),
}
resp = requests.get(base_url, params=params)
data = resp.json()
if data["features"]:
pand_id = data["features"][0]["properties"]["pandidentificatie"]
print("pand_id:", pand_id)
else:
print("No features found")
@hugoledoux
Copy link
Copy Markdown
Author

and then
wget https://api.3dbag.nl/collections/pand/items/NL.IMBAG.Pand.0503100000032914

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment