A simple REST API service that retrieves:
- the list of zip codes (CAP) of a given Italian region name
- the region name given an Italian zip code (CAP)
Examples:
Marche
-->61041
,63095
,63075
,60020
,63824
...61041
-->Marche
Because in 2020 there's no Italian official service that gives you this simple information. I needed this service in order to display the region name for the registered users in an application, because during the registration of the address we only asked the CAP.
- Written in javascript and built with Express.
- Dataset is a json (
data.json
) offered by this guy and it is currently updated at01/01/2020
- Get all zip codes (CAP) of a region
- Get the region name of a zip code (CAP)
There are 2 available endpoints:
GET /region2cap?region=_REGION_
GET /cap2region?cap=_CAP_
In each request you can pass the argument as query string parameter.
GET /region2cap?region=Basilicata
{
"success": true,
"count": 131,
"data": [
"85010",
"75011",
"85011",
"85010",
"75010",
...
]
}
GET /cap2region?cap=47838
{ "success": true, "cap": "85010", "region": "Basilicata" }
Service is currently hosted on Heroku and available for free at this url.
If you will use this service, please consider to make a little donation in order to keep the service up & running. You can do it by sponsoring this repository or just clicking here. Thanks!
If you want to host the service yourself or try it locally, follow the next steps:
-
Clone the repository
git clone [email protected]:damiandominella/regioni-cap-it.git
-
Navigate to the directory where you downloaded the project
cd regioni-cap-it
-
Install the dependencies
npm install
-
Start the application
npm run start
-
Navigate to http://127.0.0.1:3000
Tests are written using jest and supertest and you can run them with: npm test
Dataset credits: https://github.com/matteocontrini/comuni-json