---
title: "Optimization"
method: GET
path: "/optimization/json"
tags: ["Routing"]
---

# Optimization

`GET /optimization/json`

Nextbillion.ai Optimization API computes and returns an optimized route between an origin and destination which have multiple stop points in between. With NextBillion.ai's Route Optimization API you get.

Optimized routing between way points

Highly accurate ETAs with customized routes

Roundtrip optimization with customized destinations

A list of all parameters is specified in the next section.

## Query parameters

- `coordinates` string, latitude,longitude, required
- `destination` 'any' | 'last'
- `geometries` 'polyline' | 'polyline6' | 'geojson'
- `key` string, 32 character alphanumeric string, required
- `mode` 'car' | 'truck'
- `roundtrip` boolean
- `source` 'any' | 'first'
- `with_geometry` boolean
- `approaches` 'unrestricted' | 'curb', approaches_1;approaches_2;....

## Response `200`

- object
  - `code` string — A string indicating the state of the response. This is a separate code than the HTTP status code. On normal valid responses, the value will be Ok.
  - `trips` object[] — An array of 0 or 1 trip objects. Each object has the following schema.
    - `distance` number — Distance of the trip in meters.
    - `duration` number — Duration of the trip in seconds
    - `geojson` object — The GeoJSON representation of the route.
      - `geometry` string — The encoded geometry of the geojson in the trip.
      - `properties` string — Additional properties associated with the trip.
      - `type` 'Point' | 'MultiPoint' | 'LineString' | 'MultiLineString' | 'Polygon' | 'MultiPolygon' | 'GeometryCollection' | 'Feature' | 'FeatureCollection' | 'Link' — The type of the GeoJSON object.
    - `geometry` string — polyline or polyline6 format of route geometry.
    - `legs` object[]
      - `distance` number — Distance of leg in metres.
      - `duration` number — Duration of leg in seconds.
      - `steps` object[] — An array of step objects.
        - `distance` number — Distance of the step object in meters.
        - `duration` number — Duration of the step object in seconds.
        - `geojson` object — The GeoJSON representation of the step.
          - `geometry` string — The encoded geometry of the geojson in the step.
          - `properties` string — Additional properties associated with the step.
          - `type` 'Point' | 'MultiPoint' | 'LineString' | 'MultiLineString' | 'Polygon' | 'MultiPolygon' | 'GeometryCollection' | 'Feature' | 'FeatureCollection' | 'Link' — The type of the GeoJSON object.
        - `geometry` string — Encoded geometry of the step in the selected format.
      - `summary` string — Summary of the leg object.
  - `waypoints` object[] — Each waypoint is an input coordinate snapped to the road and path network.
    - `location` object — Describes the location of the waypoint.
      - `latitude` number — Latitude coordinate of the waypoint.
      - `longitude` number — Longitude coordinate of the waypoint.
    - `name` string — Name of the waypoint.
    - `trips_index` integer — Denotes the ID of a trip. Starts with 0.
    - `waypoint_index` integer — Denotes the id of a waypoint. The first waypoint is denoted with 0. And onwards with 1, 2 etc.
  - `location` object — Contains the latitude and longitude of a location
    - `latitude` number — Latitude coordinate of the location.
    - `longitude` number — Longitude coordinate of the location.

---

[API](https://skmtc.net/nextbillion-ai/apis/one-spec-service.md) · [All operations](https://skmtc.net/nextbillion-ai/apis/one-spec-service/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/nextbillion-ai/one-spec-service/versions/b647f1808dda/schema)
