Unofficial API service, which returns information on Italian areas, regions, provinces and cities.
Service realized with Node.js server based on the Express framework and on the MySQL database.
- Source of data: ISTAT
- Project structure based on Express Startup Project
- Automatic database update (The ISTAT Permalink is checked every 5 months - configurable)
- API divided by areas, regions, provinces and cities with the possibility of filtering the data. (See documentation)
Starting an "API Comuni italiani" instance is simple:
docker run -p 8000:8000 -e DATABASE_URL="mysql://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_DATABASE}" --name api-comuni-italiani -d antoninobonanno/api-comuni-italiani:latest
Example: DATABASE_URL=mysql://root:@host.docker.internal:3306/comuni-italiani
NOTE: use host.docker.internal
instead of localhost
as DB_HOST
if you have a local database (not in a docker container)
You can see the example present in docker/docker-compose.yml and run the command:
docker-compose -f docker/docker-compose.yml -p api-comuni-italiani up -d
Environment Variables
Parameter | Type | Description |
---|---|---|
DATABASE_URL |
connection string |
Required. The database connection string: mysql://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_DATABASE} |
APP_NAME |
string |
Optional. The name of app: default API Comuni Italiani |
APP_ENV |
development, production |
Optional. The environment mode: default production |
APP_PORT |
integer |
Optional. The local (internal) port where the server is exposed: default 8000 |
ISTAT_SCAN_MONTHLY_PERIOD |
integer |
Optional. How many months you want to scan on the ISTAT site, started every first day of month at 10:00: default 5 |
- Clone the repository
- Copy and rename
.env.example
file to.env
and edit settings - Run
npm install
command to install dependencies - Run
npx prisma migrate dev
command to initialize the database ornpx prisma generate
command if the database already exists - Run
npm start
ornpm run dev
command to run local server (it restarts each time the code is changed)
Want to help out? Found a bug? Missing a feature? Post an issue on our issue tracker.
I welcome contributions no matter how small or big!