How to maintain a local cache of the CommunicationParty API (Adresseregisteret)
This page describes the recommended approach for using the API to keep a local cache fully synchronized.
Steps
1. Call the export endpoint
The export endpoint returns a list of all herIds together with the last sequence number.
The last sequence number is the number of the latest event from the api.
2. Retrive entity data
For each herId returned in the response, you can fetch the full entity data by sending a bulk request to POST /communicationparty
The request body may contain up to 100 herIds, and the API will return the corresponding entity payloads in a single response.
Alternatively, you can retrieve a single entity with GET communicationparty/{herId}.
3. Call the Event endepoint with the last sequence number
To process events incrementally, call GET /event?fromSequenceNumber=fromSequenceNumber+1 using the last sequence number obtained from your export.
Then, for each herId present in the events, call GET /communicationparty/{herId} to retrieve the updated entity data.
Once you have reached the end, store the sequence number of the last event. Repeat this process periodically to keep your local cache up to date.