API Description

This API computes optimal delivery routes for a given destination address and supports the routing operations of the City Express courier service. Designed and maintained by AntSoft, the City Express Routing API provides a reliable RESTful interface for querying route information, with support for both single and batched routing requests. It returns structured JSON responses containing route identifiers, courier types, and – when available – precise geometric location data in standard GeoJSON format. Whether you are integrating with logistics platforms, e-commerce checkouts, or internal delivery planning tools, this API enables accurate and efficient route calculations tailored to real-world delivery workflows.

City Express Routing API base URL is https://api.antsoft.eu/ce/routing/

API Endpoints

EndpointParameters description

/getRoute

HTTP GET / HTTP POST

Returns one or more routing records for the requested address, depending on available courier types.

address {string} — street and house number

postalCode {integer} — postal code of city or municipality

city {string} — city or municipality name

/getRoutes

HTTP POST

Returns a list of optimal routes for the addresses requested, respectively.

Does not return geometry or precision information. Use /getRoute when location details are required.

POST Request body {Content-Type: application/json} — Routing request in JSON format (structure below) with the following entries:


ordinal {integer} — request ordinal number, used to resolve corresponding route from the response

address {string} — street and house number

postalCode {integer} — postal code of city or municipality

city {string} — city or municipality name

API Request & Response

Endpoint /getRoute

API endpoint /getRoute implements both URI path form and query parameter form. It can be called in the URI path form:

/getRoute/{address}/{postalCode}/{city}

or in query parameter form:

/getRoute?address={address}&postalCode={postalCode}&city={city}

Parameter values must be URL-encoded according to IETF URI Specification (RFC 3986). Please note: RFC 3986 specification defines slash symbol "/" as a path separator, so in URI path form parameter values cannot contain slash symbols. One example is address "Francuska 35/2". With such parameter values URI path form would result in error. If your parameter value contains slash symbols, either replace them by other symbol (minus, underscore) or use query parameter form.

API response is represented as JSON array. It may consist of single record or multiple records with different courierType values.

Field value for courierType is:

  • VEHICLE for routes operated by delivery vehicle, or
  • WALK for routes operated by pedestrian courier

If location info is available, field geometry is given in commonly used World Geodetic System 1984 (WGS84, EPSG:4326) as longitude/latitude pair. In API response location is represented in GeoJSON format as geometry of type 'Point'.

Reference info:

Field precision is related to location info and may have one of the following values:

  • POINT - exact location info (most precise location of the address requested)
  • NEAREST_POINT - the nearest known location to address requested
  • STREET - center point of the street requested, exact house number location is not known
  • POLYGON - inner point of the delivery polygon area covering the address requested
/getRoute response JSON array example (location data available):
[
  {
    "courierType": "VEHICLE",
    "center": "BG",
    "routeNr": 50,
    "geometry": {
      "type": "Point",
      "coordinates": [
        20.39833639,
        44.80253477
      ]
    },
    "precision": "NEAREST_POINT"
  },
  {
    "courierType": "WALK",
    "center": "BG",
    "routeNr": 800,
    "geometry": {
      "type": "Point",
      "coordinates": [
        20.39833639,
        44.80253477
      ]
    },
    "precision": "NEAREST_POINT"
  }
]
/getRoute response JSON array example (location data not available):
[
  {
    "courierType": "VEHICLE",
    "center": "NS",
    "routeNr": 99
  }
]

Endpoint /getRoutes

API endpoint /getRoutes is used to send multiple routing requests at once. This endpoint does not return any location info.

Request body is formatted as JSON array with the following structure:

[
  {
    "ordinal": 1,
    "address": "Francuska 35",
    "postalCode": 11000,
    "city": "Beograd Stari Grad"
  },
  {
    "ordinal": 2,
    "address": "Jurija Gagarina 5",
    "postalCode": 11000,
    "city": "Novi Beograd"
  },
  {
    "ordinal": 3,
    "address": "KNJAZA MILOŠA 40b",
    "postalCode": 18220, 
    "city": "ALEKSINAC"
  }
]

Response is formatted as JSON object with the following structure:

{
  "routes": [
    {
      "ordinal": 1,
      "courierType": "VEHICLE",
      "center": "BG",
      "routeNr": 57
    },
    {
      "ordinal": 2,
      "courierType": "VEHICLE",
      "center": "BG",
      "routeNr": 50
    },
    {
      "ordinal": 2,
      "courierType": "WALK",
      "center": "BG",
      "routeNr": 800
    },
    {
      "ordinal": 3,
      "courierType": "VEHICLE",
      "center": "NI",
      "routeNr": 12
    }
  ],
  "count": 3
}

Response is consisted of multiple routes. It returns the same ordinal as contained in request. Non-resolved routes are omitted from the response.

API response may result in a single response per ordinal, or a routing set sharing the same ordinal with different courierType.

Please note that count contains the number of returned route sets with the same ordinal, not the total results count.

The request payload can contain a maximum of 10 route entries. If more than 10 routes are submitted, the response will include only the first 10 items.

For batch processing, the /getRoutes endpoint is recommended, as it provides better performance and reduces the number of individual calls compared to repeatedly invoking the /getRoute endpoint.

Authentication

In order to use this API, requests must contain authentication header i.e. user must provide valid authentication token. Please contact City Express for getting the authentication token.

Header-NameDescription
api-auth-key Your authentication token

Rate Limit

Rate limit is API key-dependent. By default, authenticated users are allowed to send up to 1000 requests per minute. If rate limit is exceeded, error response is returned.

Example Requests

Examples are given for raw HTTP, PHP and Java. Requests can also be sent using other programming/script languages or tools for APIs testing such as Postman.

Example: HTTPS GET /getRoute call, URI path form
GET /ce/routing/getRoute/Francuska 35/11000/Beograd Stari Grad HTTP/1.1
Host: api.antsoft.eu
api-auth-key: YOUR-AUTHENTICATION-TOKEN
Cache-Control: no-cache
Example: HTTPS POST /getRoutes call, request body JSON form
POST /ce/routing/getRoutes HTTP/1.1
Host: api.antsoft.eu
api-auth-key: YOUR-AUTHENTICATION-TOKEN
Content-Type: application/json
Cache-Control: no-cache

[{
  "ordinal": 1,
  "address": "Francuska 35",
  "postalCode": 11000,
  "city": "Beograd Stari Grad"
},
{
  "ordinal": 2,
  "address": "Dositejeva 1",
  "postalCode": 21000,
  "city": "Novi Sad"
}]
Example: PHP GET /getRoute call, query parameters form
<?php
  $uri = 'https://api.antsoft.eu/ce/routing/getRoute';
  $query_data = array(
    'address' => 'Francuska 35',
    'postalCode' => 11000,
    'city' => 'Beograd Stari Grad'
  );
  $stream_context = stream_context_create(array(
    'http' => array(
      'header' => 'api-auth-key: YOUR-AUTHENTICATION-TOKEN',
      'method' => 'GET',
      'content' => http_build_query($query_data)
    )
  ));
  $response = file_get_contents($uri, false, $stream_context);
  $data = json_decode($response);
?>
Example: Java (plain) POST /getRoute call, URI path form
String urlString = "https://api.antsoft.eu/ce/routing/getRoute/Francuska+35/11000/Beograd+Stari+Grad";
URL url = new URL(urlString);
HttpURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setRequestProperty("api-auth-key", "YOUR-AUTHENTICATION-TOKEN");
conn.setRequestMethod("POST");
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8.toString()));
// reader processing omitted
reader.close();
conn.disconnect();
Example: Java (OK HTTP) POST /getRoutes call, request body JSON form
JSONArray jsonRequest = new JSONArray();
JSONObject item1 = new JSONObject();
  item1.put("ordinal", 1);
  item1.put("address", "Francuska 35");
  item1.put("postalCode", 11000);
  item1.put("city", "Beograd Stari Grad");
jsonRequest.put(item1);
JSONObject item2 = new JSONObject();
  item2.put("ordinal", 2);
  item2.put("address", "Dositejeva 1");
  item2.put("postalCode", 21000);
  item2.put("city", "Novi Sad");
jsonRequest.put(item2);
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, jsonRequest.toString());
Request request = new Request.Builder()
  .url("https://api.antsoft.eu/ce/routing/getRoutes")
  .post(body)
  .addHeader("api-auth-key", "YOUR-AUTHENTICATION-TOKEN")
  .addHeader("content-type", "application/json")
  .build();
Response response = client.newCall(request).execute();
// reader processing omitted

Errors

If an error occurs, the API will return one of the following HTTP status codes. If the error is caused by the user the API will try to give a hint with a JSON encoded error message.

HTTP Error 403 (Forbidden) response example:
{
    "status": "403 Forbidden",
    "message": "Not authorized. Please provide valid credentials. More info at: https://api.antsoft.eu/documentation/ce/"
}
HTTP Error 404 (Not Found) response example:
{
    "status": "404 Not Found",
    "message": "No route found for 'Batman Road 1007, 99999 Gotham City'"
}
HTTP Error 429 (Too Many Requests) response example:
{
    "status": "429 Too Many Requests",
    "message": "Requests limit reached. Try again in 9 seconds."
}