Skip to content

karbowiak/notdawa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

notdawa

A drop-in replacement for DAWA (Danmarks Adressers Web API), which is shutting down July 1, 2026.

notdawa replicates DAWA's full API surface — 23 entities, 74 endpoints — so consumers can swap their base URL and everything keeps working. Built with Nitro v3.

Data Sources

notdawa pulls from three backends, with every response tagged via the X-Data-Source header:

Source Header value What it serves
Datafordeleren GraphQL DAR-GraphQL Addresses, access addresses, postal codes, street names, reverse geocoding
GSSearch v2.0 GSSearch Autocomplete for addresses, streets, municipalities
DAWA (temporary) DAWA Administrative geography (kommuner, regioner, sogne, etc.) — will be migrated to Datafordeleren when their DAGI GraphQL register has data

See DAWA.md for the full endpoint-by-endpoint compatibility matrix.

Getting Started

1. Install dependencies

bun install

2. Get API keys

You need two tokens:

Datafordeleren API key (for address data via GraphQL):

  1. Go to administration.datafordeler.dk and create an account
  2. Create an IT-system for your application
  3. Generate an API key under the "API-Keys" section
  4. Documentation: Brugeroprettelse

GSSearch token (for autocomplete/search):

  1. Go to dataforsyningen.dk and create a user
  2. Generate a token from your profile
  3. Documentation: GSSearch v2.0

3. Configure environment

Create a .env file in the project root:

GSEARCH_TOKEN=your_gsearch_token_here
DATAFORDELER_API_KEY=your_datafordeler_api_key_here

4. Start the dev server

bun run dev
# or with a specific port
bun run dev -- --port 3002

5. Verify

# Check the API index
curl http://localhost:3000/

# Test an address lookup
curl http://localhost:3000/adresser?per_side=1

# Test autocomplete
curl "http://localhost:3000/adresser/autocomplete?q=Vestergade"

# Test reverse geocoding
curl "http://localhost:3000/adgangsadresser/reverse?x=12.57&y=55.68"

# Check which backend served the response
curl -sI http://localhost:3000/postnumre/2100 | grep x-data-source
# x-data-source: DAR-GraphQL

Running Tests

The test suite compares every endpoint against live DAWA responses — strict key-for-key equality.

# Start the dev server first, then:
bun test

95 tests, 271 assertions — all comparing our output 1:1 against DAWA.

API Endpoints

GET / returns a full JSON index of all 74 endpoints with descriptions and data sources.

Core address endpoints (DAR-GraphQL)

Endpoint Description
/adresser Full addresses (with etage/dør)
/adgangsadresser Access addresses (entrance-level)
/postnumre Postal codes
/vejnavne Street names

Each supports: list (GET /), single lookup (GET /:id), autocomplete (GET /autocomplete?q=), and reverse geocoding (GET /reverse?x=&y=).

Administrative geography (DAWA, pending DAGI GraphQL)

/kommuner, /regioner, /sogne, /retskredse, /politikredse, /opstillingskredse, /afstemningsomraader, /storkredse, /valglandsdele, /landsdele

Property & places (DAWA, pending MAT/DS GraphQL)

/ejerlav, /jordstykker, /navngivneveje, /vejstykker, /supplerendebynavne2, /stednavne2, /steder, /bebyggelser

Special

Endpoint Description
/autocomplete?q= Unified autocomplete across all entity types

Caching

All responses are cached in-memory with stale-while-revalidate (users never wait for a cache refresh). Cache TTLs are configured in nitro.config.ts via routeRules:

Endpoint type TTL Reason
Autocomplete (*/autocomplete, /autocomplete) 5 min Same query = same results
DAR-GraphQL (/adresser, /adgangsadresser, /postnumre, /vejnavne) 10 min DAR data updates a few times daily
DAWA proxy (kommuner, regioner, sogne, retskredse, etc.) 15 min DAGI data updates weekly/daily
Reverse geocoding (*/reverse) 30 min Geographic lookups are very stable

First request: ~200-300ms (upstream round-trip). Cached requests: ~20-30ms.

Architecture

server/
  routes/          74 route handlers (Nitro file-based routing)
  utils/
    dar-graphql.ts   DAR GraphQL client with batch reference resolution
    datafordeler.ts  GraphQL/REST client, UTM↔WGS84 coordinate conversion
    gsearch.ts       GSSearch v2.0 REST client
    dawa.ts          DAWA proxy client (temporary fallback)
    format.ts        Response formatting + X-Data-Source header
    query.ts         DAWA-compatible query parameter parsing
    mat-graphql.ts   MAT GraphQL client (ready for ejerlav/jordstykker migration)
  middleware/
    cors.ts          CORS headers (open, like DAWA)
tests/
  dawa-compat.test.ts           Core endpoint tests (28 tests)
  dawa-compat-extended.test.ts  Extended endpoint tests (67 tests)

DAWA Migration Status

notdawa is designed to be migrated away from DAWA entirely before July 2026. Current status:

  • 10 endpoints on Datafordeleren DAR GraphQL (fully independent)
  • 4 endpoints on GSSearch (fully independent)
  • 60 endpoints still proxying through DAWA (blocked on DAGI/DS GraphQL data availability)

See DAWA.md for the detailed dependency tracker and migration paths.

Deploying

bun run build

See Nitro deployment docs for deployment presets (Node, Bun, Cloudflare, Vercel, etc.).

License

MIT

About

Drop-in replacement for Denmark's DAWA API (shutting down July 2026). Replicates 74 endpoints using Datafordeleren GraphQL, GSSearch v2.0, and Nitro.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors