RESTful APIs Developer Guide

Our routing, location and mapping APIs allow you to enhance and develop your own specialty applications by calling data from PC*MILER, the industry standard for commercial vehicles for more than 30 years.

With our easy-to-use RESTful APIs, you can generate commercial vehicle specific routes, calculate distances, and gather location information throughout the world.

What Can You Do?

Our services are widely used by fleet management companies, carriers and shippers in the U.S., Canada, Mexico, and Europe for applications such as rating, fuel surcharge computations, and equipment usage monitoring.

They can be used in developing native .NET based applications on your Microsoft Windows machines, Android and iOS applications on mobile devices, as well as web browser applications.

You can also use our JavaScript to build map-centric web applications that call routing and location data.

Accessing the Service

The APIs provide a direct way to access these services via HTTP/S requests.

The base URIs to access our various services via HTTP REST requests are:

Routing, Mapping and Location https://pcmiler.alk.com/apis/rest/v1.0/service.svc

Single Search https://singlesearch.alk.com/{region}/api/

Places https://content.trimblemaps.com/api/locations/v1/

Trip Management https://tripmanagement.alk.com/api/

Fleet https://fleets.trimblemaps.com/api/assets/v1

API Key

All requests to Web Services must include a valid API Key. Go here if you need to purchase a key.

The API Key must be supplied with every request. If the client making the API request has an invalid API key, then the key will fail to authenticate.

For REST, insert the API Key in the http Authorization: header or use authToken={APIKey} in the query string in the URI of the request. For example:

https://pcmiler.alk.com/apis/rest/v1.0/Service.svc/maptile?authToken=23423421341341234&x=5&y=4&z=3

Request Properties

All API request parameters and method parameters can be sent via the standard HTTP methods—POST, GET, PUT, and DELETE. Go here for a listing of our most commonly used endpoints.

A typical REST action consists of sending an HTTP request to the API Server and waiting for the response. Like any HTTP request, a REST request to API Server contains a request method, a URI, request headers, and a query string or request body. The response contains an HTTP status code, response headers, and a response body.

Request ElementDescription
HOSTThe Host header defines PC*MILER REST API server (where to connect).
Example: Host: pcmiler.alk.com
APIKEYAPI Key will be used to fully determine privileges and visibility for the request within PC*MILER platform.
Example:add Authorization: YOUR_KEY_HERE in Request Header
Or
attach &authToken= YOUR_KEY_HERE in the URL.
CONTENT-TYPEDefines expected request MIME type.
application/json: PC*MILER will render the response in JSON format following the current REST API specifications.

Sample GET Requests

Java Header-Based GET Authentication

Query = "coords=-85.974742,37.892845";
String nospac = Query.replace(" ", "%20");
address = "https://pcmiler.alk.com/apis/rest/v1.0/Service.svc/locations?";
urlFormatted = address + nospac;
url = new URL(urlFormatted);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("Authorization", apiKeyVal);
connection.setUseCaches(false);
connection.setDoOutput(true);
connection.setReadTimeout(15 * 1000);
connection.connect();
builder = new StringBuilder();
String type = connection.getContentType();
if (type == null) {
  return;
}

Sample POST Requests

Java POST Request

String address = ("https://pcmiler.alk.com/APIs/REST/v1.0/Service.svc/route/routeReports?dataVersion=Current");
URL url = new URL(address);

HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Authorization", API_KEY);
String postData = "{ \"ReportRoutes\": [{\"RouteId\": \"test\", \"Stops\": [{\"Address\": {\"Zip\": \"08540\"},\"Label\": \"Trimble MAPS\"}, {\"Address\": {\"Zip\": \"90266\"},\"Label\": \"Manhattan Beach\"}], \"ReportTypes\": [{\"__type\": \"MileageReportType:http://pcmiler.alk.com/APIs/v1.0\",\"THoursWithSeconds\": false}]}]}";
conn.setRequestProperty("Content-Length", Integer.toString(postData.length()));
OutputStream os = conn.getOutputStream();
os.write(postData.getBytes());

os.flush();
if (conn.getResponseCode() != 200)
if (conn.getResponseCode() != HttpURLConnection.HTTP_CREATED) {
throw new RuntimeException("Failed : HTTP error code : "+ conn.getResponseCode());
}

BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();

while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();

System.out.println(response.toString());

C# POST Request

var request = (HttpWebRequest)WebRequest.Create("https://pcmiler.alk.com/APIs/REST/v1.0/Service.svc/route/routeReports?dataVersion=Current");
var postData = "{ \"ReportRoutes\": [{\"RouteId\": \"test\", \"Stops\": [{\"Address\": {\"Zip\": \"08540\"},\"Label\": \"Trimble MAPS\"}, {\"Address\": {\"Zip\": \"90266\"},\"Label\": \"Manhattan Beach\"}], \"ReportTypes\": [{\"__type\": \"MileageReportType:http://pcmiler.alk.com/APIs/v1.0\",\"THoursWithSeconds\": false}]}]}";
var data = Encoding.ASCII.GetBytes(postData);
request.Headers.Add("Authorization", API_KEY);
request.Method = "POST";
request.ContentType = "application/json";
request.ContentLength = data.Length;
using (var stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
var response = (HttpWebResponse)request.GetResponse();
var responseJSON = new StreamReader(response.GetResponseStream()).ReadToEnd();
Console.WriteLine(responseJSON);

JavaScript POST Request

reqhttp = new XMLHttpRequest();
var url =
  "https://pcmiler.alk.com/APIs/REST/v1.0/Service.svc/route/routeReports?dataVersion=Current";
reqhttp.open("POST", url, true);
reqhttp.setRequestHeader("Content-type", "application/json");
reqhttp.setRequestHeader("Authorization", APIKEY);
reqhttp.responseType = "arraybuffer";

reqhttp.onreadystatechange = function() {
  //Call a function when the state changes.
  if (reqhttp.readyState == 4 && reqhttp.status == 200) {
    var res = reqhttp.response;
    if (res) {
      var uInt8Array = new Uint8Array(res);
      var i = uInt8Array.length;
      var binaryString = new Array(i);
      while (i--) {
        binaryString[i] = String.fromCharCode(uInt8Array[i]);
      }
      var data = binaryString.join("");

      document.getElementById("textbox").innerText = data;
    }
  }
};

var postData =
  '{ "ReportRoutes": [{"RouteId": "test", "Stops": [{"Address": {"Zip": "08540"},"Label": "Trimble MAPS"}, {"Address": {"Zip": "90266"},"Label": "Manhattan Beach"}], "ReportTypes": [{"__type": "MileageReportType:http://pcmiler.alk.com/APIs/v1.0","THoursWithSeconds": false}]}]}';

doFunction();
function doFunction() {
  reqhttp.send(postData);
}

Examples

Throughout this guide, you will see interactive examples where you can both validate your API key and test any calls to our Web Services. You need to enter your key in the YOUR API KEY HERE field in order for the sample requests to return a response.

Last updated November 8, 2019.