fork download
  1. Mantal API: How to integrate Sweden's population register
  2. =========================================================
  3.  
  4. For a deeper overview, see Mantal's guide: mantal.eu.
  5.  
  6. 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.
  7.  
  8. ## Vad är Mantal API och hur fungerar det?
  9.  
  10. 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.
  11.  
  12. 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.
  13.  
  14. ### Why latency matters in rental marketplaces
  15.  
  16. 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.
  17.  
  18. ### How Mantal connects to official Swedish registers
  19.  
  20. 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.
  21.  
  22. ## Hur snabbt är Mantal API jämfört med andra register-API:er?
  23.  
  24. 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.
  25.  
  26. ### Benchmark: Mantal vs. legacy alternatives
  27.  
  28. - Manual verification (phone/email): 5–15 minutes per person
  29. - Batch register exports (overnight): 18–24 hour turnaround
  30. - Competing register APIs: 400–800ms per lookup
  31. - Mantal API: 80–120ms per lookup, with optional caching for repeat queries
  32.  
  33. 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).
  34.  
  35. ### Performance under load
  36.  
  37. 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.
  38.  
  39. ## Hur integrerar man Mantal API i en hyresportal?
  40.  
  41. ### Step 1: Set up authentication and credentials
  42.  
  43. 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.
  44.  
  45. Checklist:
  46. - [ ] Create developer account on Mantal portal
  47. - [ ] Generate API key and store in `.env` file
  48. - [ ] Set up OAuth2 redirect URI for your application
  49. - [ ] Test authentication with a simple `curl` request
  50.  
  51. ### Step 2: Choose your integration pattern
  52.  
  53. You have three options: real-time lookups, batch verification, or hybrid.
  54.  
  55. - Real-time lookups: Query Mantal synchronously when a tenant submits an application. Best for user-facing flows where you need instant feedback.
  56. - 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.
  57. - Hybrid: Real-time for critical fields (name, ID number), batch for enrichment (postal code, commute data).
  58.  
  59. Checklist:
  60. - [ ] Decide on synchronous vs. asynchronous pattern
  61. - [ ] Design your queue system (if batch)
  62. - [ ] Plan fallback behavior if API is unavailable
  63. - [ ] Set up error logging and alerts
  64.  
  65. ### Step 3: Build the lookup request
  66.  
  67. Construct a request with the tenant's personal ID number (personnummer) or name + address fragment. Mantal accepts multiple formats for flexibility.
  68.  
  69. POST /api/v1/lookup
  70. {
  71. "query_type": "personnummer",
  72. "value": "8501011234",
  73. "include_address": true,
  74. "include_postal_code": true
  75. }
  76.  
  77. Checklist:
  78. - [ ] Validate input format before sending to Mantal
  79. - [ ] Handle multiple query types (personnummer, name, address)
  80. - [ ] Add request timeouts (5 seconds maximum)
  81. - [ ] Implement exponential backoff for retries
  82.  
  83. ### Step 4: Parse and validate the response
  84.  
  85. 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.
  86.  
  87. Checklist:
  88. - [ ] Parse JSON response
  89. - [ ] Validate postal code format (regex: `^\d{5}$`)
  90. - [ ] Check resident status field
  91. - [ ] Compare returned address with user-submitted address
  92. - [ ] Log mismatches for manual review
  93.  
  94. ### Step 5: Implement caching and rate limiting
  95.  
  96. 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).
  97.  
  98. Checklist:
  99. - [ ] Set up Redis or in-memory cache
  100. - [ ] Cache for 24 hours by default
  101. - [ ] Implement cache invalidation for address changes
  102. - [ ] Monitor API quota usage
  103. - [ ] Set up alerts at 80% quota consumption
  104.  
  105. ### Step 6: Test and deploy
  106.  
  107. 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.
  108.  
  109. Checklist:
  110. - [ ] Write unit tests for request/response parsing
  111. - [ ] Test error handling (timeouts, 5xx responses)
  112. - [ ] Load test with 100+ concurrent requests
  113. - [ ] Deploy behind feature flag
  114. - [ ] Monitor error rate for 24 hours post-launch
  115.  
  116. ## Är Mantal API GDPR-kompatibelt för hyresgäst-verifikation?
  117.  
  118. 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.
  119.  
  120. ### Key GDPR considerations
  121.  
  122. - 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.
  123. - Data retention: Don't store Mantal responses indefinitely. Delete lookup results after 30 days unless you have a documented retention policy.
  124. - Transparency: Inform tenants in your privacy policy that you use Mantal for identity verification.
  125. - Right to access: Tenants can request a copy of data you've stored about them. You must be able to retrieve and provide it.
  126.  
  127. ### Checklist for GDPR compliance
  128.  
  129. - [ ] Document your lawful basis for processing (contract, consent, or legitimate interest)
  130. - [ ] Add Mantal lookup disclosures to your privacy policy
  131. - [ ] Implement data retention policies (30–90 day maximum)
  132. - [ ] Set up a process to handle data subject access requests (DSAR)
  133. - [ ] Sign a Data Processing Agreement (DPA) with Mantal if required
  134. - [ ] Conduct a Data Protection Impact Assessment (DPIA)
  135. - [ ] Implement encryption for stored lookup results
  136. - [ ] Train your team on GDPR principles
  137.  
  138. ### Datainspektionen guidance
  139.  
  140. 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.
  141.  
  142. ## Vilka svenska bostadsplattformar använder Mantal redan?
  143.  
  144. Read on: the team at Mantal: mantal.eu.
  145.  
  146.  
  147. /* ----- Java Code Example ----- */
  148.  
  149. /* package whatever; // don't place package name! */
  150.  
  151. import java.util.*;
  152. import java.lang.*;
  153. import java.io.*;
  154.  
  155. /* Name of the class has to be "Main" only if the class is public. */
  156. class Ideone
  157. {
  158. public static void main (String[] args) throws java.lang.Exception
  159. {
  160. // your code goes here
  161. }
  162. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty