A dotnet client library for accessing the Danish CVR register via the Logic platform.
In projects or components where you need to access the register, add a NuGet package reference to Kmd.Logic.Cvr.Client.
The simplest example to get a company details is:
using (var httpClient = new HttpClient())
using (var tokenProviderFactory = new LogicTokenProviderFactory(configuration.TokenProvider))
{
var cvrClient = new CvrClient(httpClient, tokenProviderFactory, configuration.Cvr);
var company = await cvrClient.GetCompanyByCvrAsync(configuration.CvrNumber).ConfigureAwait(false);
}
The LogicTokenProviderFactory
authorizes access to the Logic platform through the use of a Logic Identity issued client credential. The authorization token is reused until it expires. You would generally create a single instance of LogicTokenProviderFactory
.
The CvrClient
accesses the Logic CVR service which in turn interacts with one of the data providers.
Perhaps the easiest way to configure the CVR client is from Application Settings.
{
"TokenProvider": {
"ClientId": "",
"ClientSecret": "",
"AuthorizationScope": ""
},
"Cvr": {
"SubscriptionId": "",
"CvrConfigurationId": ""
}
}
To get started:
- Create a subscription in Logic Console. This will provide you the
SubscriptionId
. - Request a client credential. Once issued you can view the
ClientId
,ClientSecret
andAuthorizationScope
in Logic Console. - Create a CVR configuration. Select the CVR provider you have an agreement with and upload the access certificate. If you haven't done this already, you can begin testing with the Fake CVR Provider. This will give you the
CvrConfigurationId
.
A simple console application is included to demonstrate how to call Logic CVR API. You will need to provide the settings described above in appsettings.json
.
When run you should see the details of the Company for the nominated CVR number is printed to the console.
The Datafordeler service is available to any organisation which require access to the CVR register.
To gain access, you must:
- Create a user in the Self Service Portal
- Add a Service User by supplying a FOCES certificate
- Request access to the CVR Service
HentCVRData
Useful links:
- Datafordeler Website
- Self Service Portal (Production)
- Self Service Portal (Test)
- Requesting Access
- CVR Service Details
The Service Platform provider is for exclusive use by municipalities.
For CVR purposes Logic connects to CVROnline service.
To gain access, a user with a FOCES/VOCES certificate must send the request for a Service Agreement in the STS Administration portal for the required environment (Test or Production).
The process of Service Agreement approval can be sometimes accelerated up by sending e-mail to the Service Platform Help-desk, including service agreement UUID. When service agreement is approved, the client must create the configuration at Logic Console.
Logic CVR configuration parameters for Service Platform:
- Name: your customer name in Service Platform which identifies specific configuration within all resources
- Certificate: The
p12
certificate which has been uploaded during configuration of IT-Service at STS Administration portal - Municipality CVR: The CVR of the municipality that you will be requesting access to Service Platform on behalf of
Useful links:
- Service Platform (Production)
- Service Platform (Test)
- STS Administration Portal
- General technical documentation
- More specific documentation (CvrOnline)
- Service Platform Help-desk
The Fake Provider is a great solution for use in Demo or Test environments and also allows you to begin development immediately whilst you wait for your formal credentials.
The Fake Provider will return well-described test data for a CVR number.These can be viewed in the fake folder of this repository. This includes the CVR test data set.
If not one of the well-described tests, the Fake Provider exhibits the following behaviour:
- The CVR number must be 8 digits long, with the first digit greater than 0 (D1 > 0).
- The Fake provider returns random data, using the CVR number as the seed. This ensures recurring calls return the same response
NOTE: While every attempt is made to keep the generated random data consistent, this is not guaranteed. If you need a reliable response, please use a well-known test or request for a suitable one to be added.