Skip to content

Commit

Permalink
Merge pull request #55 from statisticsnorway/mfm_brreg_api_test
Browse files Browse the repository at this point in the history
Et lite script for å kontakte brreg-API
  • Loading branch information
sindre-haugen authored Jun 21, 2023
2 parents 9c8b360 + 1045848 commit 38b9bea
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions experimental/brreg_api_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# +
import requests
HEADERS = {

"Accept": 'application/json',

}

BASE_URL = "https://data.brreg.no/enhetsregisteret/api/"
def get_json(url, params={}):

url = BASE_URL + url
req = requests.Request("GET", url=url, headers=HEADERS, params=params)

#print(req.url, req.headers, req.params)
print("Full URL, check during testing:", req.prepare().url)

response = requests.Session().send(req.prepare())

response.raise_for_status()

# print(response.text)
return response.json()

get_json("enheter")["_embedded"]

# -


0 comments on commit 38b9bea

Please sign in to comment.