Get your devices connected!
Start off by checking out this guide for how to connect your telematics providers to PathStack so you can access data
from all of them in one place.
Start requesting data!
Already set up your devices? No worries, you can start getting data for them, such as trips and positions. Check out
this guide to see how!
Try it out!
Look how easy it is to get up-to-date data on your entire fleet! It’s as easy as 1, 2, 3…- Authentication
- Get devices
- Get trips for a device
- Get positions in a trip
import requests
url = "https://api.pathstack.io/token"
payload = {
"username": "username",
"password": "password"
}
headers = {"Content-Type": "application/json"}
response = requests.request("POST", url, json=payload, headers=headers)
access_token = response.json()['data']['access_token']
refresh_token = response.json()['data']['refresh_token']
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: '{"username":"<username>","password":"<password>"}'
};
fetch('https://api.pathstack.io/token', options)
.then(response => response.json())
.then(response => {
const access_token = response['data']['access_token'];
const refresh_token = response['data']['refresh_token'];
})
.catch(err => console.error(err));
import java.net.HttpURLConnection;
import java.net.URL;
import java.io.OutputStream;
import java.util.Scanner;
import org.json.JSONObject;
public class TokenRequest {
public static void main(String[] args) {
String url = "https://api.pathstack.io/token";
String payload = "{ \"username\": \"username\", \"password\": \"password\" }";
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
connection.setDoOutput(true);
try (OutputStream os = connection.getOutputStream()) {
os.write(payload.getBytes());
}
try (Scanner scanner = new Scanner(connection.getInputStream())) {
String responseBody = scanner.useDelimiter("\\A").next();
JSONObject jsonResponse = new JSONObject(responseBody);
String access_token = jsonResponse.getJSONObject("data").getString("access_token");
String refresh_token = jsonResponse.getJSONObject("data").getString("refresh_token");
}
connection.disconnect();
}
}
using System;
using System.IO;
using System.Net;
using System.Text;
using Newtonsoft.Json.Linq;
class TokenRequest
{
static void Main()
{
string url = "https://api.pathstack.io/token";
string payload = "{ \"username\": \"username\", \"password\": \"password\" }";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/json";
request.ContentLength = payload.Length;
using (Stream requestStream = request.GetRequestStream())
using (StreamWriter writer = new StreamWriter(requestStream))
{
writer.Write(payload);
}
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream responseStream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(responseStream))
{
string responseBody = reader.ReadToEnd();
JObject jsonResponse = JObject.Parse(responseBody);
string access_token = jsonResponse["data"]["access_token"].ToString();
string refresh_token = jsonResponse["data"]["refresh_token"].ToString();
}
}
}
curl --request POST \
--url https://api.pathstack.io/token \
--header 'Content-Type: application/json' \
--data '{
"username": "username",
"password": "password"
}'
import requests
url = "https://api.pathstack.io/device"
querystring = {"telematics_provider":"navman"}
headers = {"Authorization": "Bearer <access-token>"}
response = requests.request("GET", url, headers=headers, params=querystring)
print(response.json())
const options = {method: 'GET', headers: {Authorization: '<authorization>'}};
fetch('https://api.pathstack.io/device', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;
import org.json.JSONObject;
public class DeviceRequest {
public static void main(String[] args) {
String url = "https://api.pathstack.io/device";
String telematicsProvider = "navman";
String fullUrl = url + "?telematics_provider=" + telematicsProvider;
HttpURLConnection connection = (HttpURLConnection) new URL(fullUrl).openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("Authorization", "Bearer <access-token>");
try (Scanner scanner = new Scanner(connection.getInputStream())) {
String responseBody = scanner.useDelimiter("\\A").next();
JSONObject jsonResponse = new JSONObject(responseBody);
// Access and use the parsed JSON data as needed
// Example: String value = jsonResponse.getString("key");
System.out.println(jsonResponse);
}
connection.disconnect();
}
}
using System;
using System.IO;
using System.Net;
using Newtonsoft.Json.Linq;
class DeviceRequest
{
static void Main()
{
string url = "https://api.pathstack.io/device";
string telematicsProvider = "navman";
string fullUrl = $"{url}?telematics_provider={telematicsProvider}";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(fullUrl);
request.Method = "GET";
request.Headers.Add("Authorization", "Bearer <access-token>");
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream responseStream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(responseStream))
{
string responseBody = reader.ReadToEnd();
JObject jsonResponse = JObject.Parse(responseBody);
// Access and use the parsed JSON data as needed
// Example: string value = jsonResponse["key"].ToString();
Console.WriteLine(jsonResponse);
}
}
}
curl --request GET \
--url 'https://api.pathstack.io/device?telematics_provider=mtdata' \
--header 'Authorization: Bearer <access-token>'
import requests
url = "https://api.pathstack.io/device/{device_id}/trip"
querystring = {
"start_time_utc":"2024-01-09T10:58:39",
"end_time_utc":"2024-01-10T10:58:39",
}
headers = {"Authorization": "Bearer <access-token>"}
response = requests.request("GET", url, headers=headers, params=querystring)
print(response.json())
const options = {method: 'GET', headers: {Authorization: 'Bearer <access-token>'}};
fetch('https://api.pathstack.io/device/{device_id}/trip?start_time_utc=2024-01-09T10%3A58%3A39&end_time_utc=2024-01-10T10%3A58%3A39', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;
import org.json.JSONObject;
public class TripRequest {
public static void main(String[] args) {
String url = "https://api.pathstack.io/device/{device_id}/trip";
String startTime = "2024-01-09T10:58:39";
String endTime = "2024-01-10T10:58:39";
String fullUrl = url + "?start_time_utc=" + startTime + "&end_time_utc=" + endTime;
HttpURLConnection connection = (HttpURLConnection) new URL(fullUrl).openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("Authorization", "Bearer <access-token>");
try (Scanner scanner = new Scanner(connection.getInputStream())) {
String responseBody = scanner.useDelimiter("\\A").next();
JSONObject jsonResponse = new JSONObject(responseBody);
// Access and use the parsed JSON data as needed
// Example: String value = jsonResponse.getString("key");
System.out.println(jsonResponse);
}
connection.disconnect();
}
}
using System;
using System.IO;
using System.Net;
using Newtonsoft.Json.Linq;
class TripRequest
{
static void Main()
{
string url = "https://api.pathstack.io/device/{device_id}/trip";
string startTime = "2024-01-09T10:58:39";
string endTime = "2024-01-10T10:58:39";
string fullUrl = $"{url}?start_time_utc={startTime}&end_time_utc={endTime}";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(fullUrl);
request.Method = "GET";
request.Headers.Add("Authorization", "Bearer <access-token>");
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream responseStream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(responseStream))
{
string responseBody = reader.ReadToEnd();
JObject jsonResponse = JObject.Parse(responseBody);
// Access and use the parsed JSON data as needed
// Example: string value = jsonResponse["key"].ToString();
Console.WriteLine(jsonResponse);
}
}
}
curl --request GET \
--url 'https://api.pathstack.io/device/{device_id}/trip?start_time_utc=2024-01-09T10%3A58%3A39&end_time_utc=2024-01-10T10%3A58%3A39' \
--header 'Authorization: Bearer <access-token>'
import requests
url = "https://api.pathstack.io/trip/{trip_id}/position"
headers = {"Authorization": "Bearer <access-token>"}
response = requests.request("GET", url, headers=headers)
print(response.json())
const options = {method: 'GET', headers: {Authorization: 'Bearer <access-token>'}};
fetch('https://api.pathstack.io/trip/{trip_id}/position', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;
import org.json.JSONObject;
public class PositionRequest {
public static void main(String[] args) {
String url = "https://api.pathstack.io/trip/{trip_id}/position";
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("Authorization", "Bearer <access-token>");
try (Scanner scanner = new Scanner(connection.getInputStream())) {
String responseBody = scanner.useDelimiter("\\A").next();
JSONObject jsonResponse = new JSONObject(responseBody);
// Access and use the parsed JSON data as needed
// Example: String value = jsonResponse.getString("key");
System.out.println(jsonResponse);
}
connection.disconnect();
}
}
using System;
using System.IO;
using System.Net;
using Newtonsoft.Json.Linq;
class PositionRequest
{
static void Main()
{
string url = "https://api.pathstack.io/trip/{trip_id}/position";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
request.Headers.Add("Authorization", "Bearer <access-token>");
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream responseStream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(responseStream))
{
string responseBody = reader.ReadToEnd();
JObject jsonResponse = JObject.Parse(responseBody);
// Access and use the parsed JSON data as needed
// Example: string value = jsonResponse["key"].ToString();
Console.WriteLine(jsonResponse);
}
}
}
curl --request GET \
--url https://api.pathstack.io/trip/{trip_id}/position \
--header 'Authorization: Bearer <access-token>'

