get_data
Retrieve ISTAT statistical data: small queries return inline text, large datasets are saved to a local file. Use key filters or last_n_observations to avoid timeouts on long time series.
Instructions
Fetch statistical data from ISTAT. Returns formatted text inline for small queries and automatically downloads to a local disk file for large datasets, for payloads above 1 MB, or when force_file_download=True. The key_filter is a dotted SDMX key string (e.g. 'A.053011.W_SUPPL+W_TOTLOS'), not a dictionary. On dataflows with long time series (e.g. 22_389) pass last_n_observations=1, otherwise ISTAT scans the whole series and the request times out.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | Formato richiesto a ISTAT (default 'tsv'). Attenzione: l'endpoint SDMX di ISTAT serve SDMX-CSV anche quando si chiede TSV. Il campo 'format' della risposta riporta il formato effettivamente ricevuto, 'requested_format' quello richiesto. | tsv |
| end_period | No | Periodo finale SDMX, es. '2022' o '2022-12'. | |
| key_filter | No | Chiave SDMX in forma di stringa puntata, NON un dizionario. Un segmento per dimensione, nell'ordine di posizione restituito da get_constraints; segmento vuoto = tutti i valori; piu' valori sullo stesso segmento si separano con '+'. Esempio 609_1_DF_DCCV_URBANENV_1 (FREQ.REF_AREA.DATA_TYPE.TIME_PERIOD...): 'A.053011.W_SUPPL+W_TOTLOS' oppure '..W_SUPPL+W_TOTLOS' per tutti i comuni. Omesso, '.', 'all' o '*' = nessun filtro (l'intero dataflow). (Nelle versioni precedenti del server si chiamava 'dimension_filters'.) | |
| dataflow_id | Yes | ID del dataflow ISTAT, es. '609_1_DF_DCCV_URBANENV_1'. | |
| start_period | No | Periodo iniziale SDMX, es. '2022' o '2022-01'. | |
| max_inline_rows | No | Soglia di righe oltre la quale il risultato viene salvato su file invece che restituito inline (default 500). | |
| force_file_download | No | Se True salta l'output inline e scrive sempre il dataset su disco in MCP_STORAGE_DIR, restituendo percorso, dimensione e anteprima. Da usare per dataflow grandi (es. 22_389 popolazione residente). | |
| last_n_observations | No | Restituisce solo le ultime N osservazioni di ogni serie. Indispensabile sui dataflow con serie storiche lunghe (es. 22_389): senza vincolo temporale ISTAT scandisce tutta la serie e la richiesta va in timeout, con last_n_observations=1 risponde in pochi secondi. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||