Distance between Municipalities
Resource Information
- URL
- https://b5m.gipuzkoa.eus/api/2.0/distancemuni
- Response Formats
- JSON
- Authentication
- No
- Limited ratio
- Yes
The objective of this API is to consult the distances and routes between municipalities. These itineraries are the fastest routes that can be done by road between the town halls of each municipality. For the calculation of the distances between municipalities, three types of situations have been considered:
1. Gipuzkoa - Gipuzkoa
From any municipality in Gipuzkoa, to any other municipality in Gipuzkoa.
2. Gipuzkoa - Adjacent region
Starting from any municipality of Gipuzkoa, and reaching any municipality of a region adjacent to Gipuzkoa.
3. Adjacent region - Gipuzkoa
Starting from any municipality in a region adjacent to Gipuzkoa, and reaching any municipality in Gipuzkoa.
Note: The four adjacent administrative regions of Gipuzkoa are the adjacent regions, i.e. Araba/Álava, Bizkaia, Navarre and Pyrénées-Atlantiques.
There are three types of requests for API execution: region, municipality and route. The type of request will be indicated by the type parameter.
1. Region
Request to display the list of regions. The region that is not Gipuzkoa will be considered an adjacent region.
Request parameters
Parameter | Description | Default | Required |
---|---|---|---|
type | Type of request. In this case: region | - | Yes |
lang | Language. Three are available: eu, es and en. Default, eu. | eu | No |
region | Name or code of the region (GFA_codregion). | - | No |
sort | Order of response: region (by default) or code | region | No |
format | Format of the response. It should be: json, xml or php. | json | No |
Examples
- 1.1. List of supported regions
-
https://b5m.gipuzkoa.eus/api/2.0/distancemuni?type=region&lang=en
- 1.2. Selection of a region (Gipuzkoa) by name and code
-
https://b5m.gipuzkoa.eus/api/2.0/distancemuni?type=region®ion=gipuzkoa&lang=en
-
https://b5m.gipuzkoa.eus/api/2.0/distancemuni?type=region®ion=001&lang=en
Response
Field | Description |
---|---|
GFA_codregion | Region code. |
region | Name of the region. |
2. Municipality
Request to obtain the names and codes of the municipalities.
Request parameters
Parameter | Description | Default | Required |
---|---|---|---|
type | Type of request. In this case: municipality | - | Yes |
lang | Language. Three are available: eu, es and en. Default, eu. | eu | No |
municipality | Name or code of the municipality. | - | No |
region | Name or code of the region (to get the code see section 1). | - | No |
sort | Order of the response: municipality (ordered by municipalities) or region (ordered by regions). | region | No |
format | Format of the response. It should be: json, xml or php. | json | No |
Examples
- 2.1. List of all municipalities, ordered by region
-
https://b5m.gipuzkoa.eus/api/2.0/distancemuni?type=municipality&sort=region&lang=en
- 2.2. List of the municpalities of Gipuzkoa
-
https://b5m.gipuzkoa.eus/api/2.0/distancemuni?type=municipality®ion=gipuzkoa&lang=en
https://b5m.gipuzkoa.eus/api/2.0/distancemuni?type=municipality®ion=001&lang=en
- 2.3. List of municipalities that begin with the text ¿irun¿, ordered by municipality
-
https://b5m.gipuzkoa.eus/api/2.0/distancemuni?type=municipality&municipality=irun&sort=municipality&lang=en
Response
Field | Description |
---|---|
GFA_codmunicipality | Municipality code. |
municipality | Municipality name. |
GFA_codregion | Region code. |
region | Region name. |
3. Route
Request for the route and distance between municipalities.
Request parameters
Parameter | Description | Default | Required |
---|---|---|---|
type | Type of request. In this case: route | - | Yes |
lang | Language. Three are available: eu, es and en. Default, eu. | eu | No |
municipality1 | Name or code of the municipality of origin of the route (see section 2 to obtain the code). | - | Yes |
municipality2 | Name or code of the municipality of destination of the route (see section 2 to obtain the code). | - | Yes |
region1 | Name or code of the region of origin of the route (see section 1 to obtain the code). | - | No |
region2 | Name or code of the region of destination of the route (see section 1 to obtain the code). | - | No |
sort | Order of the response: The combination of the first four fields separated by commas is supported. For example: municipality1, region1 (to sort by municipalities and territories of origin). | - | No |
format | Format of the response. It should be: json, xml or php. | json | No |
Note: For a more accurate answer we recommend using the code in the following parameters: municipality1, municipality2, region1 and region2.
Examples
- 3.1. Distance and route between two municipalities, using municipality codes
-
https://b5m.gipuzkoa.eus/api/2.0/distancemuni?type=route&municipality1=0069&municipality2=2028&lang=eu
- 3.2. From a municipality of Gipuzkoa, list of distances and routes to the rest of the municipalities of Gipuzkoa
-
https://b5m.gipuzkoa.eus/api/2.0/distancemuni?type=route&municipality1=eibar®ion2=gipuzkoa&lang=en
- 3.3. From a municipality of Gipuzkoa, list of distances and routes to the municipalities of Bizkaia (using names)
-
https://b5m.gipuzkoa.eus/api/2.0/distancemuni?type=route&municipality1=aduna®ion2=bizkaia&lang=en
- 3.4. From a municipality in an adjacent region, list of distances and routes to the municipalities of Gipuzkoa (using names)
-
https://b5m.gipuzkoa.eus/api/2.0/distancemuni?type=route&municipality1=bayonne®ion2=gipuzkoa&lang=en
- 3.5. From all the municipalities of the adjoining territory of Araba/Álava, list of distances and routes to the municipalities of Gipuzkoa (using names)
-
https://b5m.gipuzkoa.eus/api/2.0/distancemuni?type=route®ion1=araba®ion2=gipuzkoa&lang=eu
Response
Field | Description |
---|---|
b5mcode | b5m code of the route. |
map_link | Link to see the map of the route. |
GFA_codmunicipality1 | Code of the municipality of departure. |
municipality1 | Name of the municipality of departure. |
GFA_codregion1 | Code of the region of departure. |
region1 | Name of the region of departure. |
GFA_codmunicipality2 | Code of the municipality of arrival. |
municipality2 | Name of the municipality of arrival. |
GFA_codregion2 | Code of the region of arrival. |
region2 | Name of the region of arrival. |
distance | Distance of the route (kilometres). |
date | Date of route calculation (YYYY-MM-DD). |
Route calculation
Calculations of the routes made with the analytical engine of the OSRM project, which uses the data of the OpenStreetMap collaborative initiative.
Warning: The Provincial Council of Gipuzkoa does not guarantee the absence of errors in these calculations.