Spain Social Security Affiliation by Municipality Scraper
Pricing
from $1.00 / 1,000 affiliation row delivereds
Spain Social Security Affiliation by Municipality Scraper
Monthly count of workers affiliated to the Spanish Social Security in each Spanish municipality, total and by regime, from the official Seguridad Social file. One row per municipality, month and indicator. Public data, no login.
Pricing
from $1.00 / 1,000 affiliation row delivereds
Rating
0.0
(0)
Developer
Steadfetch
Maintained by CommunityActor stats
0
Bookmarked
2
Total users
1
Monthly active users
5 days ago
Last modified
Features
Share
Returns the number of workers affiliated to the Spanish Social Security in each municipality, total and by regime, as JSON, from the official monthly file "Afiliados por municipio" published by the Seguridad Social.
- Source: Seguridad Social, Afiliados por municipio (public, no login, no CAPTCHA).
- One row per municipality, month and indicator (7 indicators, so one municipality gives 7 rows).
- Coverage: every Spanish municipality in the file (8,126 in September 2026), including the 88 municipalities of the Canary Islands.
- No personal data: only aggregated counts of workers.
What it does
A run does three things:
- Reads the Seguridad Social index page and picks the requested month, or the latest one published.
- Downloads that month's Excel file (the download needs a
Refererheader pointing at the index, which the Actor sends; it uses no browser and no proxy). - Emits one validated row per municipality and indicator. Figures the source hides for statistical secrecy are not turned into zero: the row has
value: nullandvalueNoteholds the literal text of the source, for example<5.
Province totals and the "not distributed" rows of the file are not municipalities and are left out.
Minimum input
{ "municipalityCodes": ["03047"] }
That returns the latest month for Calp (INE code 03047). With {} the Actor returns every municipality in Spain for the latest month (about 57,000 rows).
| Field | Type | Required | Description |
|---|---|---|---|
municipalityCodes | array of strings | no | Five-digit INE codes with the leading zero, e.g. "03047". Empty or missing means every municipality. A badly written code ("3047", 3047, "03047 ") fails the run before anything is downloaded. A well-formed code that is not in the file gives no rows and a warning in the log. |
period | string | no | Month as YYYY-MM. Missing means the latest published month. A month that is not published makes the run fail and says which is the latest available; it is never replaced by another month. |
Example output
{"municipalityCode": "03047","municipalityName": "CALPE/CALP","period": "2026-09","indicator": "affiliates_total","value": 9620,"valueNote": null,"unit": "persons","breakdown": null,"source": "Seguridad Social - Afiliados por municipio","url": "https://www.seg-social.es/wps/portal/wss/internet/EstadisticasPresupuestosEstudios/Estadisticas/EST8/EST10/EST305/c43ad8ea-fe79-4329-ac8e-e5758f3c4d7a/6609c55f-65e4-4e64-b1ab-8917fce27a84","title": "CALPE/CALP (03047) - affiliates_total - 2026-09","scrapedAt": "2026-11-16T12:00:00.000Z"}
A hidden figure looks like this:
{"municipalityCode": "01001","municipalityName": "ALEGRIA-DULANTZI","period": "2026-09","indicator": "affiliates_agrario","value": null,"valueNote": "<5","unit": "persons"}
Output fields
municipalityCode: INE code, five digits.municipalityName: name exactly as written in the source file (it can be truncated, e.g.CALPE/CALP).period: month,YYYY-MM.indicator: one ofaffiliates_total,affiliates_general,affiliates_agrario,affiliates_hogar,affiliates_mar,affiliates_autonomos,affiliates_carbon.value: number of affiliated workers, ornullwhen the source hides it.valueNote: literal text of the source whenvalueisnull(<5, or>=768for a total that includes a hidden component), otherwisenull.unit: alwayspersons.breakdown: alwaysnull(the regime is already the indicator).source,url,title,scrapedAt: common Steadfetch envelope;urlis the public Seguridad Social index page that lists the monthly file.
| Indicator | Source column |
|---|---|
affiliates_total | TOTAL |
affiliates_general | Reg. General |
affiliates_agrario | R. G. - S.E. Agrario |
affiliates_hogar | R. G. - S.E. Hogar |
affiliates_mar | R. E. MAR |
affiliates_autonomos | R. E. T. Autonomos |
affiliates_carbon | R. E. M. Carbon |
Pricing
Pay per event:
| Event | When it fires | Price |
|---|---|---|
apify-actor-start | once per run (synthetic, automatic) | 0.00005 USD |
apify-default-dataset-item | one validated row saved to the dataset (synthetic, automatic) | 0.001 USD per row = 1.00 USD per 1,000 rows |
Works on the Apify free plan: about 4,999 rows for the $5 monthly credit (700 municipalities at 7 rows each).
Only validated rows are pushed. There is no custom per-item event, so a row is never billed twice. A single-municipality run costs about 0.007 USD.
Cost per 1,000 results (measured locally, 16 November 2026)
| Measurement | Value |
|---|---|
Calp run (apify run, real source) | 7 rows, 19 s wall clock including tool start-up, the 2 s courtesy pause and 2 requests |
| Whole file (September 2026 workbook, 521,876 bytes) | 56,882 rows validated in 0.4 s, 170 MB process RSS, 63 MB JS heap |
| Run memory | 512 MB minimum, 1,024 MB maximum |
At 512 MB and about 10 s of platform time, a run costs roughly 0.0014 GB-hours, well below 0.01 USD per 1,000 rows. The platform figure has not been billed yet: no platform run has been spent on this Actor.
Development
npm install --include=devnpm test # lint + typecheck + tests (no network, no credit)npm run publish:checknpm run build && npm run verify:build
Tests run on the real September 2026 workbook and index page saved in test/fixtures/.
Data notes
- The source is a monthly file; the Actor never mixes months. The
periodis the month of the file. - Revised files (for example
Muni0226R, February 2026 revised) are read like any month and replace the plain file of the same month when both are listed. - Values are copied as published. Hidden figures keep their literal text in
valueNote. - Source: Seguridad Social, Afiliados por municipio. The month of each row is in
period.
FAQ
Why is value null? The Seguridad Social hides small counts (<5) and the totals that include them (>=768). The Actor keeps the text instead of inventing a number, and never writes zero in its place.
Why is there a 403 or a failure? The download refuses requests without a Referer; the Actor sends it. If the source still blocks the run, it aborts with a clear error and delivers nothing: no CAPTCHA solving, no proxy evasion.
Can I get several months? Run once per period. The index lists the months from January 2024.
Does it need a proxy or a browser? No. Plain HTTP requests and a local XLSX reader.
Maintenance
This Actor is tested daily: automated runs keep the source reachable and the output schema valid, and failures open an issue in this repository. Schema changes are announced through repository releases.
Legal and attribution
Only public, aggregated data published by the Seguridad Social is read. Its legal notice allows reuse, including commercial reuse, if the content is not distorted and the source is cited. Source: Seguridad Social, "Afiliados por municipio". The Actor honours robots.txt, sends an honest User-Agent with contact information and makes two requests per run (the index and one file, with a pause between them). See docs/legal-gate.md. Steadfetch is not affiliated with the Seguridad Social.