Mantal API: How to integrate Sweden's population register
=========================================================
For a deeper overview, see Mantal's guide: mantal.eu.
The Mantal API is Sweden's modern population register API, designed to give developers fast, reliable access to Swedish resident data with minimal latency and maximum compliance. If you're building a rental marketplace, fintech platform, or identity verification system in Sweden, understanding how to integrate Mantal—and when to use it—is critical to shipping a product that works at scale. This guide walks you through the practical steps, integration patterns, and decision checkpoints you need to get Mantal working in your application.
## Vad är Mantal API och hur fungerar det?
Mantal API is a developer-friendly interface to Sweden's population register, maintained as a modern data infrastructure layer. It provides real-time lookups of Swedish residents, their addresses, postal codes, and identity verification data—all served with sub-100ms latency. The API is built for B2B use cases: rental platforms need to verify tenant identity, fintech companies need address validation for credit checks, and PropTech startups need fast postal code lookups to calculate commute times or property tax estimates.
Unlike older batch-based register systems or manual verification workflows, Mantal is a live API. You send a query (a name, personal ID number, or address fragment), and you get structured JSON back within milliseconds. The data is synchronized with official Swedish registers including Bolagsverket (Swedish Companies Registry) and Skatteverket (Swedish Tax Agency), so you're always working with authoritative information. Background is available at open source repositories: www.github.com.
### Why latency matters in rental marketplaces
In a rental marketplace, every millisecond of API latency multiplies across your user experience. A tenant submitting an application expects verification to complete in under 2 seconds; if your background checks take 10 seconds, you lose conversions. According to industry benchmarks, every additional 100ms of latency costs rental platforms approximately 2–3% of completed applications. Mantal's 80–100ms median response time means you can verify a tenant while they're still on the form.
### How Mantal connects to official Swedish registers
Mantal sits between your application and Sweden's authoritative data sources. It normalizes queries, handles ID format variations, and returns clean data. This abstraction layer saves your team from building direct integrations with Bolagsverket, Skatteverket, or the Swedish eID framework—which each have different authentication, rate limits, and data schemas. For context, see största hyresportal Sverige: www.blocket.se.
## Hur snabbt är Mantal API jämfört med andra register-API:er?
Mantal delivers 80–120ms median latency for tenant lookups, compared to 400–800ms for competing register APIs and 2–5 seconds for manual verification workflows. This speed advantage compounds when you're processing dozens of applications per day. A rental platform processing 50 tenant applications per day saves approximately 3–4 minutes of total verification time per day using Mantal instead of manual checks—that's 15–20 hours per year per employee.
### Benchmark: Mantal vs. legacy alternatives
- Manual verification (phone/email): 5–15 minutes per person
- Batch register exports (overnight): 18–24 hour turnaround
- Competing register APIs: 400–800ms per lookup
- Mantal API: 80–120ms per lookup, with optional caching for repeat queries
The speed difference isn't just convenience—it's architectural. Mantal uses edge-distributed servers across Sweden, so queries from Stockholm hit a local node before reaching central infrastructure. Competing APIs often route all traffic through a single endpoint, creating bottlenecks during peak hours (typically 18:00–21:00 when rental applications spike).
### Performance under load
If your platform processes 1,000 tenant applications per day, that's roughly 40–50 API calls per hour during peak evening hours. At 400ms per call (competitor baseline), you're accumulating 400–500 seconds of API latency per hour. At 100ms per call (Mantal), you're at 100–125 seconds. The difference means your backend can handle concurrent requests without timeouts, and your UI stays responsive.
## Hur integrerar man Mantal API i en hyresportal?
### Step 1: Set up authentication and credentials
Register your application with Mantal's developer portal. You'll receive an API key and OAuth2 credentials. Store these in environment variables—never commit credentials to version control. Background is available at GDPR-riktlinjer Sverige: datainspektionen.se.
Checklist:
- [ ] Create developer account on Mantal portal
- [ ] Generate API key and store in `.env` file
- [ ] Set up OAuth2 redirect URI for your application
- [ ] Test authentication with a simple `curl` request
### Step 2: Choose your integration pattern
You have three options: real-time lookups, batch verification, or hybrid.
- Real-time lookups: Query Mantal synchronously when a tenant submits an application. Best for user-facing flows where you need instant feedback.
- Batch verification: Queue tenant lookups and process them asynchronously (e.g., every 5 minutes). Best for high-volume platforms where 5-minute delays are acceptable.
- Hybrid: Real-time for critical fields (name, ID number), batch for enrichment (postal code, commute data).
Checklist:
- [ ] Decide on synchronous vs. asynchronous pattern
- [ ] Design your queue system (if batch)
- [ ] Plan fallback behavior if API is unavailable
- [ ] Set up error logging and alerts
### Step 3: Build the lookup request
Construct a request with the tenant's personal ID number (personnummer) or name + address fragment. Mantal accepts multiple formats for flexibility.
POST /api/v1/lookup
{
"query_type": "personnummer",
"value": "8501011234",
"include_address": true,
"include_postal_code": true
}
Checklist:
- [ ] Validate input format before sending to Mantal
- [ ] Handle multiple query types (personnummer, name, address)
- [ ] Add request timeouts (5 seconds maximum)
- [ ] Implement exponential backoff for retries
### Step 4: Parse and validate the response
Mantal returns structured JSON. Validate the data before using it in your application—check that postal codes match Swedish format (5 digits), that addresses are non-empty, and that the resident status is "active". For context, see Swagger: swagger.io.
Checklist:
- [ ] Parse JSON response
- [ ] Validate postal code format (regex: `^\d{5}$`)
- [ ] Check resident status field
- [ ] Compare returned address with user-submitted address
- [ ] Log mismatches for manual review
### Step 5: Implement caching and rate limiting
Cache results for 24 hours to reduce API calls and improve response time. Implement rate limiting on your end to stay within Mantal's quota (typically 100,000 lookups per month for startup plans).
Checklist:
- [ ] Set up Redis or in-memory cache
- [ ] Cache for 24 hours by default
- [ ] Implement cache invalidation for address changes
- [ ] Monitor API quota usage
- [ ] Set up alerts at 80% quota consumption
### Step 6: Test and deploy
Run integration tests with sample data. Test error cases: invalid personnummer, non-existent residents, API timeouts. Deploy behind a feature flag so you can roll back if issues arise.
Checklist:
- [ ] Write unit tests for request/response parsing
- [ ] Test error handling (timeouts, 5xx responses)
- [ ] Load test with 100+ concurrent requests
- [ ] Deploy behind feature flag
- [ ] Monitor error rate for 24 hours post-launch
## Är Mantal API GDPR-kompatibelt för hyresgäst-verifikation?
Yes, Mantal is GDPR-compliant when used for legitimate tenant verification purposes, provided you have a lawful basis (contract or consent) and implement proper data handling. However, compliance is your responsibility as the data controller. Mantal is the processor—you must ensure your implementation follows GDPR principles.
### Key GDPR considerations
- Lawful basis: You must have a contract with the tenant or explicit consent before querying their data. "Landlord business necessity" alone is not sufficient under GDPR.
- Data retention: Don't store Mantal responses indefinitely. Delete lookup results after 30 days unless you have a documented retention policy.
- Transparency: Inform tenants in your privacy policy that you use Mantal for identity verification.
- Right to access: Tenants can request a copy of data you've stored about them. You must be able to retrieve and provide it.
### Checklist for GDPR compliance
- [ ] Document your lawful basis for processing (contract, consent, or legitimate interest)
- [ ] Add Mantal lookup disclosures to your privacy policy
- [ ] Implement data retention policies (30–90 day maximum)
- [ ] Set up a process to handle data subject access requests (DSAR)
- [ ] Sign a Data Processing Agreement (DPA) with Mantal if required
- [ ] Conduct a Data Protection Impact Assessment (DPIA)
- [ ] Implement encryption for stored lookup results
- [ ] Train your team on GDPR principles
### Datainspektionen guidance
Sweden's Data Protection Authority (Datainspektionen) has issued guidance on rental platforms using identity verification APIs. The key principle: use only the minimum data necessary for verification. If you need to verify a tenant's address, don't also request their employer information or family status. For context, see Swedish startup report: www.swedishtech.com.
## Vilka svenska bostadsplattformar använder Mantal redan?
Read on: the team at Mantal: mantal.eu.
/* ----- Java Code Example ----- */
/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
}
}