Source: https://maps.vietmap.vn/docs/migrate-v4/ # Migrate to v4 Older versions of the VIETMAP Maps API are no longer updated and will stop being supported in the future. This guide lists the changes required to migrate each API to v4: endpoints, parameters, response fields, and request examples. To convert a single request quickly, paste your old curl command into [Convert requests to v4](https://tools.vietmap.vn/playground/en/migrate-v4) on the Playground. ## Versions and their v4 replacements | Old version | Old endpoint | v4 replacement | v4 endpoint | | --- | --- | --- | --- | | [Autocomplete v3](https://maps.vietmap.vn/docs/map-api/autocomplete-version/autocomplete-ver3.0/) | `GET /api/autocomplete/v3` | [Autocomplete v4](#autocomplete-v3) | `GET /api/autocomplete/v4` | | [Geocode v3](https://maps.vietmap.vn/docs/map-api/geocode-version/geocode-ver3.0/) | `GET /api/search/v3` | [Geocode v4](#geocode-v3) | `GET /api/search/v4` | | [Place v3](https://maps.vietmap.vn/docs/map-api/place/) | `GET /api/place/v3` | [Place v4](#place-v3) | `GET /api/place/v4` | | [Reverse v3](https://maps.vietmap.vn/docs/map-api/reverse-version/reverse-ver3.0/) | `GET /api/reverse/v3` | [Reverse v4](#reverse-v3) | `GET /api/reverse/v4` | | [Reverse Batch](https://maps.vietmap.vn/docs/map-api/reverse-batch/) | `POST /api/geocode-fleet/reverse-batch` | [Reverse v4](#reverse-batch) | `GET /api/reverse/v4` | | [Route v1.1](https://maps.vietmap.vn/docs/map-api/route/) | `GET /api/route?api-version=1.1` | [Route v4](#route-v1-1) | `GET /api/route/v4` | | [Route v3](https://maps.vietmap.vn/docs/map-api/route-version/route-v3/) | `GET /api/route/v3` | [Route v4](#route-v3) | `GET /api/route/v4` | | [Route Tolls](https://maps.vietmap.vn/docs/map-api/route-tolls/) | `POST /api/route-tolls?api-version=1.1` | [Route v4 with `annotations=toll`](#route-tolls) | `GET /api/route/v4` | | [Matrix v1.1](https://maps.vietmap.vn/docs/map-api/matrix/) | `GET /api/matrix?api-version=1.1` | [Matrix v4](#matrix-v1-1) | `GET /api/matrix/v4` | | [TSP v1.1](https://maps.vietmap.vn/docs/map-api/tsp/) | `GET /api/tsp?api-version=1.1` | [TSP v4](#tsp-v1-1) | `GET /api/tsp/v4` | | [TSP v3](https://maps.vietmap.vn/docs/map-api/tsp-version/tsp-v3/) | `GET /api/tsp/v3` | [TSP v4](#tsp-v3) | `GET /api/tsp/v4` | ## Before you start - Keep passing the API key in the `apikey` query parameter. Use a Services key—the key type for Map APIs (address search, geocoding, routing, distance matrix, and route optimization)—and keep it on the backend. - Test each v4 request in the [Playground](https://tools.vietmap.vn/playground/) before updating code. - Migrate one API at a time. Send the same input to both the old and v4 endpoints and compare responses before cutting over all traffic. In the tables below, "Unchanged" means the parameter or field keeps the same name, with any differences noted in the Notes column; "—" in the Old column marks a parameter or field new in v4; "Removed" means it is no longer in v4. ## Search & Geocode ### Autocomplete v3 → Autocomplete v4 { #autocomplete-v3 } Autocomplete v4 keeps all v3 parameters and adds `display_type` to choose the address format. Pass each returned `ref_id` to Place v4 to retrieve place details. **Endpoint** | | Old | v4 | | --- | --- | --- | | Request | `GET /api/autocomplete/v3` | `GET /api/autocomplete/v4` | | Reference | [Autocomplete v3](https://maps.vietmap.vn/docs/map-api/autocomplete-version/autocomplete-ver3.0/) | [Autocomplete v4](https://maps.vietmap.vn/docs/map-api/autocomplete-version/autocomplete-v4/) | **Parameters** | Old | v4 | Notes | | --- | --- | --- | | — | `display_type` | Address format: `1` — new 2-level (ward, province); `2` — old 3-level (ward, district, province), matching v3; `3` — matches the format of `text`; `5` — new format, with the old format in `data_old`; `6` — old format, with the new format in `data_new`. Use `5` while migrating. See [Display type options](https://maps.vietmap.vn/docs/map-api/autocomplete-version/autocomplete-v4/#display-type-options). | | — | `admin_new` | Used with `cityId`, `distId`, or `wardId`: `true` filters by new administrative boundaries; `false` filters by old ones. | | `apikey`, `text`, `focus`, `cityId`, `distId`, `wardId`, `circle_center`, `circle_radius`, `cats`, `layers` | Unchanged | — | **Response** | Old | v4 | Notes | | --- | --- | --- | | `ref_id` (`vm:ADDRESS:…`) | `ref_id` (prefixed) | Pass verbatim, prefix included, as `refid` to [Place v4](https://maps.vietmap.vn/docs/map-api/place-v4/) to get `lat`/`lng` and address components. | | `boundaries` | Unchanged | In the new format (`display_type=1`, `5`, or `3` with a new-format input), contains ward (`type` 2) and province (`type` 0). To get district (`type` 1), send `display_type=2`, or send `display_type=5` and read `data_old.boundaries`. | | `address` | Unchanged | Administrative portion of the address: ward, district (old format only), and province. House number and street are in `name`; full address string is in `display`. | | — | `data_old` | Returned when `display_type=5`: the same result in the old 3-level format. | | — | `data_new` | Returned when `display_type=6`: the same result in the new 2-level format. | | `entry_points[].ref_id` | Unchanged | Pass to [Place v4](https://maps.vietmap.vn/docs/map-api/place-v4/) to get entry point coordinates. | **Example** === "Autocomplete v3" ```bash curl -G 'https://maps.vietmap.vn/api/autocomplete/v3' \ --data-urlencode 'apikey=YOUR_API_KEY' \ --data-urlencode 'text=197 tran phu' \ --data-urlencode 'focus=10.75887508,106.67538868' ``` === "Autocomplete v4" ```bash curl -G 'https://maps.vietmap.vn/api/autocomplete/v4' \ --data-urlencode 'apikey=YOUR_API_KEY' \ --data-urlencode 'text=197 tran phu' \ --data-urlencode 'focus=10.75887508,106.67538868' \ --data-urlencode 'display_type=5' ``` ### Geocode v3 → Geocode v4 { #geocode-v3 } Geocode v4 keeps all v3 parameters and adds `display_type` and `admin_new`. Pass a full address string in `text`. **Endpoint** | | Old | v4 | | --- | --- | --- | | Request | `GET /api/search/v3` | `GET /api/search/v4` | | Reference | [Geocode v3](https://maps.vietmap.vn/docs/map-api/geocode-version/geocode-ver3.0/) | [Geocode v4](https://maps.vietmap.vn/docs/map-api/geocode-version/geocode-v4/) | **Parameters** | Old | v4 | Notes | | --- | --- | --- | | `text` | Unchanged | Send a full address string (house number, street, and administrative units in the old or new format), e.g., `197 Trần Phú, phường 4, quận 5, thành phố Hồ Chí Minh`. For typeahead suggestions, use [Autocomplete v4](https://maps.vietmap.vn/docs/map-api/autocomplete-version/autocomplete-v4/). | | — | `display_type` | Address format: `1` — new 2-level; `2` — old 3-level, matching v3; `3` — matches the format of `text`; `5` — new format, with the old format in `data_old`; `6` — old format, with the new format in `data_new`. Use `5` while migrating. See [Display type options](https://maps.vietmap.vn/docs/map-api/geocode-version/geocode-v4/#display-type-options). | | — | `admin_new` | Used with `cityId`, `distId`, or `wardId`: `true` filters by new administrative boundaries; `false` filters by old ones. | | `apikey`, `focus`, `layers`, `circle_center`, `circle_radius`, `cats`, `cityId`, `distId`, `wardId` | Unchanged | — | **Response** | Old | v4 | Notes | | --- | --- | --- | | `ref_id` (`vm:POI:…`) | `ref_id` (prefixed, e.g., `geocode:`) | Pass verbatim, prefix included, as `refid` to [Place v4](https://maps.vietmap.vn/docs/map-api/place-v4/) to get `lat`/`lng` and address components. | | `boundaries` | Unchanged | In the new format, each entry is a ward or province. Send `display_type=2` to get ward, district, and province as in v3. | | — | `data_old` | Returned when `display_type=5`: the same result in the old 3-level format. | | — | `data_new` | Returned when `display_type=6`: the same result in the new 2-level format. | | `entry_points[].ref_id` | Unchanged | Pass to [Place v4](https://maps.vietmap.vn/docs/map-api/place-v4/) to get entry point details. | **Example** === "Geocode v3" ```bash curl -G 'https://maps.vietmap.vn/api/search/v3' \ --data-urlencode 'apikey=YOUR_API_KEY' \ --data-urlencode 'focus=10.75887508,106.67538868' \ --data-urlencode 'text=Công Ty Cổ Phần Ứng Dụng Bản Đồ Việt,HCM' ``` === "Geocode v4" ```bash curl -G 'https://maps.vietmap.vn/api/search/v4' \ --data-urlencode 'apikey=YOUR_API_KEY' \ --data-urlencode 'focus=10.75887508,106.67538868' \ --data-urlencode 'display_type=5' \ --data-urlencode 'text=197 Trần Phú, phường 4, quận 5, thành phố Hồ Chí Minh' ``` ### Place v3 → Place v4 { #place-v3 } Place v4 accepts a `ref_id` from Autocomplete v4 or Geocode v4. It returns the v3 response fields in the address format of that `ref_id`. **Endpoint** | | Old | v4 | | --- | --- | --- | | Request | `GET /api/place/v3` | `GET /api/place/v4` | | Reference | [Place v3](https://maps.vietmap.vn/docs/map-api/place/) | [Place v4](https://maps.vietmap.vn/docs/map-api/place-v4/) | **Parameters** | Old | v4 | Notes | | --- | --- | --- | | `refid` (`vm:ADDRESS:…` from v3 search) | `refid` (`ref_id` from v4 search) | Same parameter name, but pass the `ref_id` from [Autocomplete v4](https://maps.vietmap.vn/docs/map-api/autocomplete-version/autocomplete-v4/) or [Geocode v4](https://maps.vietmap.vn/docs/map-api/geocode-version/geocode-v4/) verbatim, keeping its `auto:` or `geocode:` prefix. The prefix determines the response address format. Migrate search and Place calls to v4 together. | | `apikey` | Unchanged | — | **Response** | Old | v4 | Notes | | --- | --- | --- | | `name` | POI name | Returns `""` for plain street addresses. Read house number and street from `address`, or from `hs_num` and `street`. | | `address` | House number and street (`hs_num` + `street`) | Example: `197 Đường Trần Phú`. | | `district_id` | District ID (old format), `0` (new format) | A `ref_id` from a 2-level result returns the new format; a `ref_id` from a 3-level result returns all three levels. | | `district` | District name (old format), `""` (new format) | Follows the same rule as `district_id`. | **Example** === "Place v3" ```bash curl -G 'https://maps.vietmap.vn/api/place/v3' \ --data-urlencode 'apikey=YOUR_API_KEY' \ --data-urlencode 'refid=vm:ADDRESS:8D92EB120DDE9996' ``` === "Place v4" ```bash curl -G 'https://maps.vietmap.vn/api/place/v4' \ --data-urlencode 'apikey=YOUR_API_KEY' \ --data-urlencode 'refid=auto:RAkPcicmZ3d-NQhac2kADHYlbFAkBiEeAQAkCV0EXwdF_KakgoWOrg0FFWZfh4jFXA1kXfbZFlNRGFUYCAJXAF8BUQBVCAZUC18EA1VMAwUYXwJQBBQFBQVTHVFacANBQlU' ``` ### Reverse v3 → Reverse v4 { #reverse-v3 } Reverse v4 keeps `lat` and `lng` and adds `display_type` to choose the address format. When `display_type` is omitted, it returns the new 2-level format. **Endpoint** | | Old | v4 | | --- | --- | --- | | Request | `GET /api/reverse/v3` | `GET /api/reverse/v4` | | Reference | [Reverse v3](https://maps.vietmap.vn/docs/map-api/reverse-version/reverse-ver3.0/) | [Reverse v4](https://maps.vietmap.vn/docs/map-api/reverse-version/reverse-v4/) | **Parameters** | Old | v4 | Notes | | --- | --- | --- | | `lat`, `lng` | Unchanged | — | | — | `display_type` | Omit or `1` — new 2-level format (ward, province); `2` — old 3-level format, matching v3; `4` — both formats as two list items, new format first; `5` — new format, with the old format in `data_old`; `6` — old format, with the new format in `data_new`. See [Display type options](https://maps.vietmap.vn/docs/map-api/reverse-version/reverse-v4/#display-type-options). | | `cats` | Removed | — | | `apikey` | Unchanged | — | **Response** | Old | v4 | Notes | | --- | --- | --- | | `address` | Unchanged | Administrative portion of the address: ward and province in the new format; ward, district, and province in the old format. Street name is in `name`. | | `boundaries` | Unchanged | In the new format, contains ward (`type` 2) and province (`type` 0). To get district (`type` 1), send `display_type=2`, or send `display_type=5` and read `data_old.boundaries`. | | — | `entry_points` | Entry points for the location. Pass `entry_points[].ref_id` to [Place v4](https://maps.vietmap.vn/docs/map-api/place-v4/) for details. | | — | `data_old` | Present on every object. Holds the same location in the old 3-level format when `display_type=5`; otherwise `null`. | | — | `data_new` | Present on every object. Holds the same location in the new 2-level format when `display_type=6`; otherwise `null`. | | List items | One item per format when `display_type=4` | Returns one new-format item and one old-format item for the same location. | **Example** === "Reverse v3" ```bash curl -G 'https://maps.vietmap.vn/api/reverse/v3' \ --data-urlencode 'apikey=YOUR_API_KEY' \ --data-urlencode 'lat=10.758970242000032' \ --data-urlencode 'lng=106.67546114000004' ``` === "Reverse v4" ```bash curl -G 'https://maps.vietmap.vn/api/reverse/v4' \ --data-urlencode 'apikey=YOUR_API_KEY' \ --data-urlencode 'lat=10.758970242000032' \ --data-urlencode 'lng=106.67546114000004' \ --data-urlencode 'display_type=5' ``` ### Reverse Batch → Reverse v4 { #reverse-batch } Reverse v4 looks up one coordinate per `GET` request. Split each coordinate in the Reverse Batch JSON body into a separate request. **Endpoint** | | Old | v4 | | --- | --- | --- | | Request | `POST /api/geocode-fleet/reverse-batch` (JSON body) | `GET /api/reverse/v4` (query parameters, one request per coordinate) | | Reference | [Reverse Batch](https://maps.vietmap.vn/docs/map-api/reverse-batch/) | [Reverse v4](https://maps.vietmap.vn/docs/map-api/reverse-version/reverse-v4/) | **Parameters** | Old | v4 | Notes | | --- | --- | --- | | Body array `[{ "lon": …, "lat": … }, …]` | One request per item | Send each coordinate as query parameters. | | `lon` (body) | `lng` (query) | Point longitude. | | `lat` (body) | `lat` (query) | Point latitude. | | — | `display_type` | Optional. Omit or `1` — new 2-level format; `2` — old 3-level format; `4`, `5`, or `6` — both formats. See [Display type options](https://maps.vietmap.vn/docs/map-api/reverse-version/reverse-v4/#display-type-options). | | `apikey` | Unchanged | — | **Response** | Old | v4 | Notes | | --- | --- | --- | | Single array with one object per input coordinate | One array per request | Contains location objects for that coordinate. | | `admin`, `address`, and `network` objects | Location object | Read `name` (place name or street address), `address` (administrative part), `display` (full address string), `boundaries` (administrative units with IDs), `lat`/`lng`, and `distance` (distance from the query point, in km). See [Reverse v4 response](https://maps.vietmap.vn/docs/map-api/reverse-version/reverse-v4/#response-description). | **Example** === "Reverse Batch" ```bash curl -X POST 'https://maps.vietmap.vn/api/geocode-fleet/reverse-batch?apikey=YOUR_API_KEY' \ -H 'Content-Type: application/json' \ -d '[{"lon": 107.42193008289291, "lat": 10.91527176296465}, {"lon": 107.4267435202076, "lat": 10.889979077535088}]' ``` === "Reverse v4" ```bash # One request per coordinate curl -G 'https://maps.vietmap.vn/api/reverse/v4' \ --data-urlencode 'apikey=YOUR_API_KEY' \ --data-urlencode 'lat=10.91527176296465' \ --data-urlencode 'lng=107.42193008289291' curl -G 'https://maps.vietmap.vn/api/reverse/v4' \ --data-urlencode 'apikey=YOUR_API_KEY' \ --data-urlencode 'lat=10.889979077535088' \ --data-urlencode 'lng=107.4267435202076' ``` ## Route & Logistics ### Route v1.1 → Route v4 { #route-v1-1 } Switch to `/api/route/v4`. Route v4 keeps all [Route v1.1](https://maps.vietmap.vn/docs/map-api/route/) response field names and adds truck and container profiles, departure time, alternative routes, and toll costs. **Endpoint** | Version | Method | URL | | --- | --- | --- | | Route v1.1 | `GET` | `https://maps.vietmap.vn/api/route?api-version=1.1` | | Route v4 | `GET` | `https://maps.vietmap.vn/api/route/v4` | **Parameters** | Old | v4 | Notes | | --- | --- | --- | | `api-version=1.1` | Removed | Version is now in the path (`/api/route/v4`). | | `apikey` | Unchanged | — | | `point` | Unchanged | Format `latitude,longitude`, one `point` per location. | | `points_encoded` | Unchanged | Default: `true`. | | `vehicle` | Unchanged | Required in v4; send `vehicle` in every request. `car` and `motorcycle` work as before; replace `bike` and `foot` with `car`, `motorcycle`, `truck`, or `container`. | | `optimize` | Removed | Use [TSP v4](https://maps.vietmap.vn/docs/map-api/tsp-version/tsp-v4/) to optimize stop order for a single vehicle. | | `avoid` | Unchanged | Allowed value: `ferry`. | | — | `capacity` | Required when `vehicle=truck`. Gross vehicle weight in kg, e.g., `capacity=2000`. | | — | `container_feet` | Used with `vehicle=container`. Container length in feet, e.g., `container_feet=40`. | | — | `time` | Departure time in ISO-8601 (UTC), e.g., `time=2025-08-01T12:01:00Z`. Used to avoid restricted zones for the selected vehicle. | | — | `heading` | Current vehicle heading in degrees (`0`–`360`, `0` = north), used to determine departure direction. | | — | `alternative` | Set to `true` to include alternative routes in `paths`. | | — | `annotations` | Comma-separated keys: `congestion`, `congestion_distance`, `toll`. `toll` returns `toll_cost` and `tolls` in each path. Calculated leg by leg: send 2 `point` values per request, and call each leg separately for multi-stop trips. | **Response** | Old | v4 | Notes | | --- | --- | --- | | `paths` | Unchanged | Includes alternative routes when `alternative=true`. | | — | `paths[].annotations` | Returned with `annotations=congestion` or `congestion_distance`: congestion per segment. See [Annotation Object Model](https://maps.vietmap.vn/docs/map-api/route-version/route-v4/#annotation-object-model). | | — | `paths[].toll_cost` | Returned with `annotations=toll`: total toll cost for the route in VND for the requested `vehicle`. | | — | `paths[].tolls` | Returned with `annotations=toll`: toll stations along the route (`id`, `name`, `address`, `type`, `price`, `lat`, `lng`). See [Toll Object Model](https://maps.vietmap.vn/docs/map-api/route-version/route-v4/#toll-object-model). | **Example** Before — Route v1.1: ```text https://maps.vietmap.vn/api/route?api-version=1.1&apikey=YOUR_API_KEY&point=10.79628438955497,106.70592293472612&point=10.801891047584164,106.70660958023404&vehicle=motorcycle ``` After — Route v4: ```text https://maps.vietmap.vn/api/route/v4?apikey=YOUR_API_KEY&point=10.79628438955497,106.70592293472612&point=10.801891047584164,106.70660958023404&vehicle=motorcycle ``` ### Route v3 → Route v4 { #route-v3 } Replace `/api/route/v3` with `/api/route/v4` and remove `optimize`. Route v4 adds the `container` profile, `container_feet`, and toll costs via `annotations=toll`. **Endpoint** | Version | Method | URL | | --- | --- | --- | | [Route v3](https://maps.vietmap.vn/docs/map-api/route-version/route-v3/) | `GET` | `https://maps.vietmap.vn/api/route/v3` | | [Route v4](https://maps.vietmap.vn/docs/map-api/route-version/route-v4/) | `GET` | `https://maps.vietmap.vn/api/route/v4` | **Parameters** | Old | v4 | Notes | | --- | --- | --- | | `apikey`, `point`, `points_encoded` | Unchanged | — | | `vehicle` | Unchanged | Required in v4; send `vehicle` in every request. `car`, `motorcycle`, and `truck` work as before; v4 adds `container`. | | `capacity` | Unchanged | Gross vehicle weight in kg; required when `vehicle=truck`. | | — | `container_feet` | Used with `vehicle=container`. Container length in feet, e.g., `container_feet=40`. | | `time` | Unchanged | No default. Send departure time in ISO-8601 (UTC), e.g., `time=2025-08-01T12:01:00Z`, to avoid restricted zones for the selected vehicle. For immediate departure, send the current time. | | `annotations` | Unchanged | Adds `toll`, which returns `toll_cost` and `tolls`. Calculated leg by leg: send 2 `point` values per request, and call each leg separately for multi-stop trips. | | `alternative` | Unchanged | Set to `true` to include alternative routes in `paths`. | | `heading` | Unchanged | Heading in degrees (`0`–`360`, `0` = north). | | `avoid` | Unchanged | Allowed value: `ferry`. | | `optimize` | Removed | Use [TSP v4](https://maps.vietmap.vn/docs/map-api/tsp-version/tsp-v4/) to optimize stop order for a single vehicle. | **Response** | Old | v4 | Notes | | --- | --- | --- | | `paths[].annotations` | Unchanged | Keys: `congestion`, `congestion_distance`. Calculated leg by leg: send 2 `point` values per request. | | — | `paths[].toll_cost` | Returned with `annotations=toll`: total toll cost for the route in VND for the requested `vehicle`. | | — | `paths[].tolls` | Returned with `annotations=toll`: toll stations along the route (`id`, `name`, `address`, `type`, `price`, `lat`, `lng`). See [Toll Object Model](https://maps.vietmap.vn/docs/map-api/route-version/route-v4/#toll-object-model). | **Example** Before — Route v3 (truck): ```text https://maps.vietmap.vn/api/route/v3?apikey=YOUR_API_KEY&point=10.755222,106.662633&point=10.7559910,106.6633234&vehicle=truck&capacity=2000 ``` After — Route v4 (truck, with departure time and tolls): ```text https://maps.vietmap.vn/api/route/v4?apikey=YOUR_API_KEY&point=10.755222,106.662633&point=10.7559910,106.6633234&vehicle=truck&capacity=2000&time=2025-08-01T12:01:00Z&annotations=toll ``` After — Route v4 (40-foot container): ```text https://maps.vietmap.vn/api/route/v4?apikey=YOUR_API_KEY&point=10.755222,106.662633&point=10.7559910,106.6633234&vehicle=container&container_feet=40&time=2025-08-01T12:01:00Z&annotations=toll ``` ### Route Tolls → Route v4 { #route-tolls } Replace the [Route Tolls](https://maps.vietmap.vn/docs/map-api/route-tolls/) `POST` request with a Route v4 `GET` request passing `point`, the vehicle profile, and `annotations=toll`. Each path returns the total toll in `toll_cost` and the toll stations in `tolls`; see [Toll costs for trucks and containers](https://maps.vietmap.vn/docs/map-api/toll-cost/). **Endpoint** | Version | Method | URL | | --- | --- | --- | | Route Tolls | `POST` | `https://maps.vietmap.vn/api/route-tolls?api-version=1.1` | | [Route v4](https://maps.vietmap.vn/docs/map-api/route-version/route-v4/) | `GET` | `https://maps.vietmap.vn/api/route/v4` | !!! warning "Coordinate order" The Route Tolls example body uses `[longitude, latitude]`, e.g., `[106.765137, 10.477009]`. Route v4 `point` uses `latitude,longitude`: `point=10.477009,106.765137`. **Parameters** | Old | v4 | Notes | | --- | --- | --- | | `api-version=1.1` (query) | Removed | Version is now in the path (`/api/route/v4`). | | `apikey` (query) | Unchanged | — | | Request body: JSON array of locations | `point` (query), one per location | Send origin and destination as two `point` parameters. Tolls are calculated leg by leg: send 2 `point` values per request, and for multi-stop trips call each leg separately and sum `toll_cost`. | | Body item `[longitude, latitude]` | `point=latitude,longitude` | Swap the coordinate order: `[106.765137, 10.477009]` becomes `point=10.477009,106.765137`. | | `vehicle` (query): class `1`–`5`, default `1` | `vehicle`, with `capacity` or `container_feet` | Required in v4; send a vehicle profile (`car`, `motorcycle`, `truck`, or `container`) instead of a class number in every request. Route v4 calculates `toll_cost` and each station's `price` for the selected vehicle. See the vehicle class table below. | | — | `capacity` | Required when `vehicle=truck`. Gross vehicle weight in kg, e.g., `capacity=15000` for a 15-ton truck. | | — | `container_feet` | Used with `vehicle=container`. Container length in feet, e.g., `container_feet=40`. | | — | `annotations=toll` | Returns `toll_cost` and `tolls` in each path. Can be combined with other keys, e.g., `annotations=congestion,toll`. | | — | `time` | Recommended. Departure time in ISO-8601 (UTC), e.g., `time=2025-08-01T12:01:00Z`, to avoid restricted zones for the selected vehicle. | | — | `points_encoded` | Optional. Default `true` returns route geometry in `points` as an encoded polyline; set `false` for a GeoJSON `LineString` with `[longitude, latitude]` coordinates. | **Vehicle class → Route v4 vehicle parameters** | Vehicle (Route Tolls definition) | Route Tolls `vehicle` | Route v4 | | --- | --- | --- | | Truck, by gross tonnage: under 2 t, under 4 t, under 10 t, under 18 t, 18 t and over | `1`, `2`, `3`, `4`, `5` | `vehicle=truck&capacity=` | | Tractor with a container, by container length: up to 20 ft, over 20 ft | `4`, `5` | `vehicle=container&container_feet=` | | Passenger car with fewer than 12 seats | `1` | `vehicle=car` | **Response** | Old | v4 | Notes | | --- | --- | --- | | — | `code` | `OK` on success. Check this field before reading `paths`. | | `path` (array of `[longitude, latitude]`) | `paths[0].points` | Route geometry. Route Tolls returns a single `path`; Route v4 returns a `paths` array—read `paths[0]`. Defaults to an encoded polyline (`google polyline 5`); set `points_encoded=false` for a GeoJSON `LineString` with `[longitude, latitude]` coordinates. | | `tolls` | `paths[0].tolls` | Toll stations along the route, nested inside each path. | | `tolls[].name` | Unchanged | Toll station name. | | `tolls[].address` | Unchanged | Toll station address or road. | | `tolls[].type` | Unchanged | `entry` — entry station; `exit` — exit station where the toll is charged. | | `tolls[].amount` | `tolls[].price` | Toll fee at this station for the requested `vehicle`, in VND. | | — | `tolls[].id` | Unique toll station ID. | | — | `tolls[].lat`, `tolls[].lng` | Toll station coordinates (latitude, longitude). | | — | `paths[0].toll_cost` | Total toll cost for the route in VND for the requested `vehicle`. | | — | `paths[0].distance`, `paths[0].time`, `paths[0].instructions` | Distance (meters), travel time (milliseconds), and turn-by-turn instructions. | **Example** Before — Route Tolls (`vehicle=5`): ```text POST https://maps.vietmap.vn/api/route-tolls?api-version=1.1&apikey=YOUR_API_KEY&vehicle=5 [[106.765137, 10.477009], [108.363304, 11.398591]] ``` After — Route v4 (18-ton truck, equivalent to class `5`): ```text https://maps.vietmap.vn/api/route/v4?apikey=YOUR_API_KEY&point=10.477009,106.765137&point=11.398591,108.363304&vehicle=truck&capacity=18000&time=2025-08-01T12:01:00Z&annotations=toll ``` After — Route v4 (40-foot container tractor, equivalent to class `5`): ```text https://maps.vietmap.vn/api/route/v4?apikey=YOUR_API_KEY&point=10.477009,106.765137&point=11.398591,108.363304&vehicle=container&container_feet=40&time=2025-08-01T12:01:00Z&annotations=toll ``` Read the total toll from `paths[0].toll_cost` and individual stations from `paths[0].tolls`. **Cost:** a 2-point Route v4 request counts as 1 transaction. See the full formula in [How Pricing Works](https://maps.vietmap.vn/docs/map-api/console/request-to-transaction/). ### Matrix v1.1 → Matrix v4 { #matrix-v1-1 } Move the version into the path. Matrix v4 adds the `truck` and `container` vehicle profiles and shares the routing engine of [Route v4](https://maps.vietmap.vn/docs/map-api/route-version/route-v4/), keeping travel times and distances consistent across both APIs. **Endpoint** | | Old | v4 | | --- | --- | --- | | Request | `GET /api/matrix?api-version=1.1` | `GET /api/matrix/v4` | | Reference | [Matrix v1.1](https://maps.vietmap.vn/docs/map-api/matrix/) | [Matrix v4](https://maps.vietmap.vn/docs/map-api/matrix-version/matrix-v4/) | **Parameters** | Old | v4 | Notes | | --- | --- | --- | | `api-version=1.1` | Removed | Version is now in the path. | | — | `vehicle=truck` | Truck profile. | | — | `vehicle=container` | Container truck profile. | | `vehicle=bike`, `vehicle=foot` | `car`, `motorcycle`, `truck`, or `container` | Replace with one of the four v4 profiles. | | `vehicle=car`, `vehicle=motorcycle` | Unchanged | Required in v4: send `vehicle` in every request (no default). | | `apikey`, `point`, `sources`, `destinations`, `annotation` | Unchanged | Same values and defaults; `point` uses `lat,lng`. | **Response** | Old | v4 | Notes | | --- | --- | --- | | `code` | Unchanged | Values: `OK`, `INVALID_REQUEST`, `OVER_DAILY_LIMIT`, `MAX_POINTS_EXCEED`, and `ERROR_UNKNOWN`. See [Status Code Values](https://maps.vietmap.vn/docs/map-api/matrix-version/matrix-v4/#status-code-values). | | `messages`, `durations`, `distances` | Unchanged | `durations[i][j]` is travel time in seconds from `sources[i]` to `destinations[j]`; `distances` uses the same layout, in meters. | **Example** === "Matrix v1.1" ```bash curl -G 'https://maps.vietmap.vn/api/matrix' \ --data-urlencode 'api-version=1.1' \ --data-urlencode 'apikey=YOUR_API_KEY' \ --data-urlencode 'point=10.768897,106.678505' \ --data-urlencode 'point=10.765496,106.67626' \ --data-urlencode 'point=10.7627936,106.6750729' \ --data-urlencode 'point=10.7616745,106.6792425' \ --data-urlencode 'point=10.765605,106.685383' \ --data-urlencode 'point=10.766843,106.674029' \ --data-urlencode 'sources=0;1' \ --data-urlencode 'destinations=2;3;4;5' ``` === "Matrix v4" ```bash curl -G 'https://maps.vietmap.vn/api/matrix/v4' \ --data-urlencode 'apikey=YOUR_API_KEY' \ --data-urlencode 'point=10.768897,106.678505' \ --data-urlencode 'point=10.765496,106.67626' \ --data-urlencode 'point=10.7627936,106.6750729' \ --data-urlencode 'point=10.7616745,106.6792425' \ --data-urlencode 'point=10.765605,106.685383' \ --data-urlencode 'point=10.766843,106.674029' \ --data-urlencode 'vehicle=car' \ --data-urlencode 'sources=0;1' \ --data-urlencode 'destinations=2;3;4;5' ``` For trucks or containers, replace `vehicle=car` with `vehicle=truck` or `vehicle=container`. ### TSP v1.1 → TSP v4 { #tsp-v1-1 } Move the version into the path. TSP v4 keeps the same response field names, adds the `truck` and `container` vehicle profiles, and shares the routing engine of [Route v4](https://maps.vietmap.vn/docs/map-api/route-version/route-v4/), keeping results consistent with Route v4. **Endpoint** | | Old | v4 | | --- | --- | --- | | Request | `GET /api/tsp?api-version=1.1` | `GET /api/tsp/v4` | | Reference | [TSP v1.1](https://maps.vietmap.vn/docs/map-api/tsp/) | [TSP v4](https://maps.vietmap.vn/docs/map-api/tsp-version/tsp-v4/) | **Parameters** | Old | v4 | Notes | | --- | --- | --- | | `api-version=1.1` | Removed | Version is now in the path. | | — | `vehicle=truck` | Truck profile. Travel times are computed on the road network for the selected `vehicle`, including one-way streets and restrictions. | | — | `vehicle=container` | Container truck profile. | | `vehicle=bike`, `vehicle=foot` | `car`, `motorcycle`, `truck`, or `container` | Replace with one of the four v4 profiles. | | `vehicle=car`, `vehicle=motorcycle` | Unchanged | Required in v4: send `vehicle` in every request (no default). | | `apikey`, `point`, `points_encoded`, `roundtrip`, `sources`, `destinations` | Unchanged | Defaults: `roundtrip=true`, `sources=any` (or `first`), `destinations=any` (or `last`). | **Response** | Old | v4 | Notes | | --- | --- | --- | | `code` | Unchanged | Values: `OK`, `INVALID_REQUEST`, `OVER_DAILY_LIMIT`, `MAX_POINTS_EXCEED`, `ERROR_UNKNOWN`, and `ZERO_RESULTS`. `ZERO_RESULTS` indicates no road path connects all `point` values for the selected `vehicle`. See [Status Code Values](https://maps.vietmap.vn/docs/map-api/tsp-version/tsp-v4/#status-code-values). | | `license`, `messages`, `paths`, `paths[].instructions` | Unchanged | `paths[].distance` is in meters; `paths[].time` is in milliseconds. | **Example** === "TSP v1.1" ```bash curl -G 'https://maps.vietmap.vn/api/tsp' \ --data-urlencode 'api-version=1.1' \ --data-urlencode 'apikey=YOUR_API_KEY' \ --data-urlencode 'point=10.79628438955497,106.70592293472612' \ --data-urlencode 'point=10.801891047584164,106.70660958023404' \ --data-urlencode 'point=10.801595962927763,106.6898296806408' \ --data-urlencode 'points_encoded=true' \ --data-urlencode 'vehicle=motorcycle' \ --data-urlencode 'roundtrip=true' ``` === "TSP v4" ```bash curl -G 'https://maps.vietmap.vn/api/tsp/v4' \ --data-urlencode 'apikey=YOUR_API_KEY' \ --data-urlencode 'point=10.79628438955497,106.70592293472612' \ --data-urlencode 'point=10.801891047584164,106.70660958023404' \ --data-urlencode 'point=10.801595962927763,106.6898296806408' \ --data-urlencode 'points_encoded=true' \ --data-urlencode 'vehicle=motorcycle' \ --data-urlencode 'roundtrip=true' ``` For trucks or containers, replace `vehicle=motorcycle` with `vehicle=truck` or `vehicle=container`. ### TSP v3 → TSP v4 { #tsp-v3 } Replace `/v3` with `/v4` in the path. TSP v4 keeps the same response field names, adds the `truck` and `container` vehicle profiles, and shares the routing engine of [Route v4](https://maps.vietmap.vn/docs/map-api/route-version/route-v4/), keeping results consistent with Route v4. **Endpoint** | | Old | v4 | | --- | --- | --- | | Request | `GET /api/tsp/v3` | `GET /api/tsp/v4` | | Reference | [TSP v3](https://maps.vietmap.vn/docs/map-api/tsp-version/tsp-v3/) | [TSP v4](https://maps.vietmap.vn/docs/map-api/tsp-version/tsp-v4/) | **Parameters** | Old | v4 | Notes | | --- | --- | --- | | — | `vehicle=truck` | Truck profile. Travel times are computed on the road network for the selected `vehicle`, including one-way streets and restrictions. | | — | `vehicle=container` | Container truck profile. | | `vehicle=bike`, `vehicle=foot` | `car`, `motorcycle`, `truck`, or `container` | Replace with one of the four v4 profiles. | | `vehicle=car`, `vehicle=motorcycle` | Unchanged | Required in v4: send `vehicle` in every request (no default). | | `apikey`, `point`, `points_encoded`, `roundtrip`, `sources`, `destinations` | Unchanged | Defaults: `roundtrip=true`, `sources=any` (or `first`), `destinations=any` (or `last`). | **Response** | Old | v4 | Notes | | --- | --- | --- | | `code` | Unchanged | Values: `OK`, `INVALID_REQUEST`, `OVER_DAILY_LIMIT`, `MAX_POINTS_EXCEED`, `ERROR_UNKNOWN`, and `ZERO_RESULTS`. `ZERO_RESULTS` indicates no road path connects all `point` values for the selected `vehicle`. See [Status Code Values](https://maps.vietmap.vn/docs/map-api/tsp-version/tsp-v4/#status-code-values). | | `license`, `messages`, `paths`, `paths[].instructions` | Unchanged | `paths[].distance` is in meters; `paths[].time` is in milliseconds. | **Example** === "TSP v3" ```bash curl -G 'https://maps.vietmap.vn/api/tsp/v3' \ --data-urlencode 'apikey=YOUR_API_KEY' \ --data-urlencode 'point=10.79628438955497,106.70592293472612' \ --data-urlencode 'point=10.801891047584164,106.70660958023404' \ --data-urlencode 'point=10.801595962927763,106.6898296806408' \ --data-urlencode 'points_encoded=true' \ --data-urlencode 'vehicle=motorcycle' \ --data-urlencode 'roundtrip=true' ``` === "TSP v4" ```bash curl -G 'https://maps.vietmap.vn/api/tsp/v4' \ --data-urlencode 'apikey=YOUR_API_KEY' \ --data-urlencode 'point=10.79628438955497,106.70592293472612' \ --data-urlencode 'point=10.801891047584164,106.70660958023404' \ --data-urlencode 'point=10.801595962927763,106.6898296806408' \ --data-urlencode 'points_encoded=true' \ --data-urlencode 'vehicle=motorcycle' \ --data-urlencode 'roundtrip=true' ``` For trucks or containers, replace `vehicle=motorcycle` with `vehicle=truck` or `vehicle=container`. ## After migrating - [Error codes](https://maps.vietmap.vn/docs/map-api/errors/) — in addition to the HTTP status, Route v4, Matrix v4, and TSP v4 return a `code` field. - [How requests convert into transactions](https://maps.vietmap.vn/docs/map-api/console/request-to-transaction/) — transaction count for each v4 API. - [Docs for AI agents](https://maps.vietmap.vn/docs/map-api/ai-agents/) — plain-text v4 reference for updating code with an AI assistant.