Documentation
¶
Overview ¶
Package rdw provides types, an HTTP client, and formatters for the Dutch RDW open vehicle registration API.
Index ¶
- Constants
- Variables
- func CleanKenteken(raw string) string
- func FormatVehicleInfo(data *AllVehicleData) string
- func ResetCache()
- func SetClientConfig(cfg ClientConfig)
- func SetUserAgent(ua string)
- func ValidateKenteken(raw string) (string, error)
- type AllVehicleData
- type ClientConfig
- type VehicleAPKInspection
- type VehicleAxesInfo
- type VehicleBaseInfo
- type VehicleBodyInfo
- type VehicleDefect
- type VehicleFuelInfo
- type VehicleRecall
Constants ¶
const ( APIBase = "https://opendata.rdw.nl/resource" // HTTPTimeout is the default per-request timeout for the RDW HTTP client. HTTPTimeout = 10 * time.Second // DefaultCacheTTL is the default TTL for cached RDW responses. DefaultCacheTTL = 6 * time.Hour // DefaultCacheSize is the default LRU capacity (entries). DefaultCacheSize = 1024 // DefaultMaxAttempts is the default total number of attempts (initial + // retries) used when ClientConfig.MaxAttempts is unset. DefaultMaxAttempts = 3 // DefaultBaseBackoff is the initial exponential-backoff delay. DefaultBaseBackoff = 200 * time.Millisecond // DefaultMaxBackoff caps exponential backoff per retry. DefaultMaxBackoff = 2 * time.Second // DefaultPerCallTimeout bounds an individual endpoint call (incl. retries). DefaultPerCallTimeout = 8 * time.Second )
RDW API endpoint identifiers and HTTP client configuration.
Variables ¶
var ErrInvalidKenteken = errors.New("invalid kenteken")
ErrInvalidKenteken is returned by ValidateKenteken when the input does not match any of the 14 official Dutch license plate sidecodes.
var UserAgent = "RDW-MCP-Server/dev" //nolint:gochecknoglobals // intentional injectable build identity
UserAgent is the HTTP User-Agent header sent with every RDW API request. It is overridable via SetUserAgent so the binary can inject the build version.
Functions ¶
func CleanKenteken ¶
CleanKenteken strips hyphens / spaces and uppercases the input.
func FormatVehicleInfo ¶
func FormatVehicleInfo(data *AllVehicleData) string
FormatVehicleInfo assembles the full multi-section text report for a vehicle.
func ResetCache ¶
func ResetCache()
ResetCache clears the active response cache. Intended for tests.
func SetClientConfig ¶
func SetClientConfig(cfg ClientConfig)
SetClientConfig replaces the active RDW client configuration. Safe to call concurrently. Resetting the cache size or TTL rebuilds the cache.
A negative CacheTTL or CacheSize disables caching. The zero value leaves caching disabled — main must opt in by calling SetClientConfig with positive CacheTTL/CacheSize. This keeps tests deterministic without requiring them to reset shared state.
func SetUserAgent ¶
func SetUserAgent(ua string)
SetUserAgent overrides the default User-Agent header used for RDW API requests. Intended to be called once at startup with a build-time version.
func ValidateKenteken ¶
ValidateKenteken normalises raw and returns the cleaned form when it matches one of the 14 official Dutch sidecodes. It returns ErrInvalidKenteken (wrapped with diagnostic context) otherwise.
Types ¶
type AllVehicleData ¶
type AllVehicleData struct {
Base *VehicleBaseInfo
Fuel []VehicleFuelInfo
Axles []VehicleAxesInfo
Body []VehicleBodyInfo
Recalls []VehicleRecall
APKHistory []VehicleAPKInspection
Defects []VehicleDefect
}
AllVehicleData bundles the results from all parallel RDW API calls.
func FetchAllVehicleData ¶
func FetchAllVehicleData( ctx context.Context, client *http.Client, kenteken string, ) (*AllVehicleData, error)
FetchAllVehicleData runs every RDW endpoint call concurrently and returns the combined result. A nil Base means no vehicle was found for the kenteken.
type ClientConfig ¶
type ClientConfig struct {
// MaxAttempts is the total number of attempts (initial request + retries)
// for transient errors. Zero -> default. Set to 1 to disable retries.
MaxAttempts int
// BaseBackoff is the initial exponential backoff delay. Zero -> default.
BaseBackoff time.Duration
// MaxBackoff caps the per-retry sleep. Zero -> default.
MaxBackoff time.Duration
// PerCallTimeout bounds a single endpoint call (including retries).
// Zero -> default.
PerCallTimeout time.Duration
// CacheTTL is the TTL for entries in the response cache. Zero -> default.
// A negative TTL disables the cache.
CacheTTL time.Duration
// CacheSize is the LRU capacity in entries. Zero -> default. Negative
// disables the cache.
CacheSize int
}
ClientConfig controls retry, per-call timeout and response-cache behaviour of doRDWGet. The zero value is safe — defaults are applied as needed.
type VehicleAPKInspection ¶
type VehicleAPKInspection struct {
Kenteken string `json:"kenteken"`
SoortErkenningOmschrijving string `json:"soort_erkenning_omschrijving"`
SoortMeldingKIOmschrijving string `json:"soort_melding_ki_omschrijving"`
MeldDatumDoorKeuringsinstantie string `json:"meld_datum_door_keuringsinstantie"`
MeldTijdDoorKeuringsinstantie string `json:"meld_tijd_door_keuringsinstantie"`
VervaldatumKeuring string `json:"vervaldatum_keuring"`
}
VehicleAPKInspection holds one APK (MOT) inspection record for a vehicle.
func FetchAPKHistory ¶
func FetchAPKHistory( ctx context.Context, client *http.Client, kenteken string, ) ([]VehicleAPKInspection, error)
FetchAPKHistory returns all APK (MOT) inspection records for a kenteken.
type VehicleAxesInfo ¶
type VehicleAxesInfo struct {
Kenteken string `json:"kenteken"`
AsNummer string `json:"as_nummer"`
AantalAssen string `json:"aantal_assen"`
AangedrevenAs string `json:"aangedreven_as"`
PlaatscodeAs string `json:"plaatscode_as"`
Spoorbreedte string `json:"spoorbreedte"`
TechnischToegestaneMaximumAslast string `json:"technisch_toegestane_maximum_aslast"`
WettelijkToegestaneMaximumAslast string `json:"wettelijk_toegestane_maximum_aslast"`
AfstandTotVolgendeAsVoertuig string `json:"afstand_tot_volgende_as_voertuig"`
}
VehicleAxesInfo holds axle-level technical specifications.
func FetchAxles ¶
func FetchAxles( ctx context.Context, client *http.Client, kenteken string, ) ([]VehicleAxesInfo, error)
FetchAxles returns all axle specification records for a kenteken.
type VehicleBaseInfo ¶
type VehicleBaseInfo struct {
Kenteken string `json:"kenteken"`
Voertuigsoort string `json:"voertuigsoort"`
Merk string `json:"merk"`
Handelsbenaming string `json:"handelsbenaming"`
TypeGoedkeuringNummer string `json:"type_goedkeuring_nummer"`
Variant string `json:"variant"`
Uitvoering string `json:"uitvoering"`
EersteKleur string `json:"eerste_kleur"`
TweedeKleur string `json:"tweede_kleur"`
AantalZitplaatsen string `json:"aantal_zitplaatsen"`
AantalStaanplaatsen string `json:"aantal_staanplaatsen"`
DatumEersteToelating string `json:"datum_eerste_toelating"`
DatumEersteTenaamstellingInNederland string `json:"datum_eerste_tenaamstelling_in_nederland"`
VervaldatumApk string `json:"vervaldatum_apk"`
Inrichting string `json:"inrichting"`
AantalDeuren string `json:"aantal_deuren"`
AantalWielen string `json:"aantal_wielen"`
MassaLedigVoertuig string `json:"massa_ledig_voertuig"`
MassaRijklaar string `json:"massa_rijklaar"`
MaximumMassaTrekkenOngeremd string `json:"maximum_massa_trekken_ongeremd"`
MaximumMassaTrekkenGeremd string `json:"maximum_massa_trekken_geremd"`
MaximumTrekkenMassaGeremd string `json:"maximum_trekken_massa_geremd"`
DatumTenaamstelling string `json:"datum_tenaamstelling"`
BrutoBpm string `json:"bruto_bpm"`
Zuinigheidsclassificatie string `json:"zuinigheidsclassificatie"`
Zuinigheidslabel string `json:"zuinigheidslabel"`
ExportIndicator string `json:"export_indicator"`
Exportindicator string `json:"exportindicator"`
OpenstaandeTerugroepactieIndicator string `json:"openstaande_terugroepactie_indicator"`
VervaldatumTachograaf string `json:"vervaldatum_tachograaf"`
TaxiIndicator string `json:"taxi_indicator"`
MaximumMassaVoertuig string `json:"maximum_massa_voertuig"`
Catalogusprijs string `json:"catalogusprijs"`
WamVerzekerd string `json:"wam_verzekerd"`
AantalCilinders string `json:"aantal_cilinders"`
Cilinderinhoud string `json:"cilinderinhoud"`
MassaAltAandr string `json:"massa_alt_aandr"`
Nettomaximumvermogen string `json:"nettomaximumvermogen"`
NominaalContinuMaximumvermogen string `json:"nominaal_continu_maximumvermogen"`
ToegestaneMaximumMassaVoertuig string `json:"toegestane_maximum_massa_voertuig"`
TechnischeMaxMassaVoertuig string `json:"technische_max_massa_voertuig"`
MaximumMassaSamenstelling string `json:"maximum_massa_samenstelling"`
VermogenMassarijklaar string `json:"vermogen_massarijklaar"`
Typegoedkeuringsnummer string `json:"typegoedkeuringsnummer"`
JaarLaatsteRegistratieTellerstand string `json:"jaar_laatste_registratie_tellerstand"`
Type string `json:"type"`
MaximaleConstructiesnelheid string `json:"maximale_constructiesnelheid"`
Lengte string `json:"lengte"`
Breedte string `json:"breedte"`
HoogteVoertuig string `json:"hoogte_voertuig"`
EuropeseVoertuigcategorie string `json:"europese_voertuigcategorie"`
VolgnummerWijzigingEuTypegoedkeuring string `json:"volgnummer_wijziging_eu_typegoedkeuring"`
Wielbasis string `json:"wielbasis"`
Tellerstandoordeel string `json:"tellerstandoordeel"`
CodeToelichtingTellerstandoordeel string `json:"code_toelichting_tellerstandoordeel"`
TenaamstellenMogelijk string `json:"tenaamstellen_mogelijk"`
WachtOpKeuren string `json:"wacht_op_keuren"`
RegistratieDatumGoedkeuringBpm string `json:"registratie_datum_goedkeuring_afschrijvingsmoment_bpm"`
AerodynamicVoorziening string `json:"aerodyn_voorz"`
VerlengdeCabineIndicator string `json:"verl_cab_ind"`
}
VehicleBaseInfo holds the primary RDW registration record for a vehicle.
type VehicleBodyInfo ¶
type VehicleBodyInfo struct {
Kenteken string `json:"kenteken"`
CarrosserieVolgnummer string `json:"carrosserie_volgnummer"`
Carrosserietype string `json:"carrosserietype"`
TypeCarrosserieEuropeseOmschrijving string `json:"type_carrosserie_europese_omschrijving"`
}
VehicleBodyInfo holds carrosserie (body type) classification data.
type VehicleDefect ¶
type VehicleDefect struct {
Kenteken string `json:"kenteken"`
GebrekIdentificatie string `json:"gebrek_identificatie"`
AantalGebrekenGeconstateerd string `json:"aantal_gebreken_geconstateerd"`
MeldDatumDoorKeuringsinstantie string `json:"meld_datum_door_keuringsinstantie"`
SoortErkenningOmschrijving string `json:"soort_erkenning_omschrijving"`
}
VehicleDefect holds one observed defect record for a vehicle.
func FetchDefects ¶
func FetchDefects( ctx context.Context, client *http.Client, kenteken string, ) ([]VehicleDefect, error)
FetchDefects returns all observed defect records for a kenteken.
type VehicleFuelInfo ¶
type VehicleFuelInfo struct {
Kenteken string `json:"kenteken"`
BrandstofVolgnummer string `json:"brandstof_volgnummer"`
BrandstofOmschrijving string `json:"brandstof_omschrijving"`
EmissiecodeOmschrijving string `json:"emissiecode_omschrijving"`
Uitlaatemissieniveau string `json:"uitlaatemissieniveau"`
Co2Emissieklasse string `json:"co2_emissieklasse"`
Nettomaximumvermogen string `json:"nettomaximumvermogen"`
GeluidsniveauRijdend string `json:"geluidsniveau_rijdend"`
GeluidsniveauStationair string `json:"geluidsniveau_stationair"`
Roetuitstoot string `json:"roetuitstoot"`
MilieuklasseEgGoedkeuringLicht string `json:"milieuklasse_eg_goedkeuring_licht"`
ToerentalGeluidsniveau string `json:"toerental_geluidsniveau"`
EmisDeeltjesType1Wltp string `json:"emis_deeltjes_type1_wltp"`
EmisCo2GecombineerdWltp string `json:"emissie_co2_gecombineerd_wltp"`
BrandstofVerbruikGecombineerd string `json:"brandstof_verbruik_gecombineerd_wltp"`
}
VehicleFuelInfo holds fuel type, emissions, and power data for one fuel entry.
type VehicleRecall ¶
type VehicleRecall struct {
Kenteken string `json:"kenteken"`
ReferentiecodeRDW string `json:"referentiecode_rdw"`
CodeStatus string `json:"code_status"`
Status string `json:"status"`
// Description is populated client-side by FetchRecalls from endpointRecallDesc.
Description string `json:"omschrijving_defect,omitempty"`
// PublicationDate is populated client-side by FetchRecalls.
PublicationDate string `json:"publicatiedatum_rdw,omitempty"`
}
VehicleRecall holds an open RDW recall action for a vehicle.
func FetchRecalls ¶
func FetchRecalls( ctx context.Context, client *http.Client, kenteken string, ) ([]VehicleRecall, error)
FetchRecalls returns all open recall actions for a kenteken, enriched with the human-readable description and publication date from the recall catalog.