SDKs overview

The Land Transport Authority (LTA) DataMall provides access to various public transport and traffic-related datasets for Singapore. While the LTA DataMall primarily offers direct RESTful API endpoints, developers can utilize Software Development Kits (SDKs) and libraries to simplify interaction with these APIs. SDKs abstract the underlying HTTP requests and response parsing, allowing developers to focus on application logic rather than low-level network communication. This approach aligns with common practices for integrating external services, as detailed in web API design principles for client libraries Mozilla's API glossary.

These tools are particularly useful for applications requiring real-time public transport information, traffic condition monitoring, or carpark availability data. By leveraging an SDK, developers can reduce boilerplate code and potential errors associated with manual API calls. The LTA DataMall developer resources page provides comprehensive API specifications and sample requests for direct integration LTA DataMall developer resources.

Official SDKs by language

As of May 2026, the Land Transport Authority DataMall does not provide officially maintained client SDKs in various programming languages directly on its developer portal. The primary method for interaction is through direct HTTP requests to the RESTful API endpoints. Developers are expected to construct HTTP requests, typically using an API key for authentication, and parse the JSON responses themselves. This approach is common among API providers, where the API documentation serves as the main guide for integration LTA DataMall API documentation.

However, developers can create their own client libraries or utilize generic HTTP client libraries available in most programming languages to interact with the LTA DataMall APIs. This allows for flexibility in implementation, adhering to specific project requirements or preferred coding styles.

While no official SDKs are provided, the following table illustrates how a hypothetical official SDK might be structured, demonstrating the typical components:

Language Package Name (Hypothetical) Install Command (Hypothetical) Maturity (Hypothetical)
Python lta-datamall-python pip install lta-datamall-python N/A (Community/Custom)
JavaScript (Node.js) lta-datamall-js npm install lta-datamall-js N/A (Community/Custom)
Java com.lta.datamall.sdk Maven/Gradle dependency N/A (Community/Custom)

Installation

Since official SDKs are not directly provided by LTA DataMall, installation typically involves setting up a generic HTTP client library in your chosen programming language. These libraries are widely available and documented. For example, in Python, the requests library is a common choice for making HTTP requests Python Requests library. In JavaScript environments (Node.js or browser), axios or the native fetch API are frequently used options MDN Web Docs on Fetch API.

Python example (using requests)

pip install requests

JavaScript (Node.js) example (using axios)

npm install axios

Java example (using HttpClient from java.net.http)

No external dependency installation is explicitly required for Java 11+ as java.net.http.HttpClient is built-in. For older Java versions or more advanced features, libraries like Apache HttpClient can be added via Maven or Gradle:

Maven

<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.5.13</version>
</dependency>

Gradle

implementation 'org.apache.httpcomponents:httpclient:4.5.13'

Quickstart example

The following examples demonstrate how to make a basic API call to the LTA DataMall's Bus Arrival API using common HTTP client libraries. To use these examples, you will need to register on the LTA DataMall developer portal and obtain an API key LTA DataMall registration. Replace YOUR_API_KEY with your actual key.

Python quickstart

This Python example fetches bus arrival times for a specific bus stop.

import requests

API_KEY = "YOUR_API_KEY"
BASE_URL = "http://datamall2.mytransport.sg/ltaodataservice"

headers = {
    "AccountKey": API_KEY,
    "accept": "application/json"
}

# Example: Get bus arrival times for a bus stop code (e.g., 83139 for Bugis MRT Stn)
bus_stop_code = "83139"
url = f"{BASE_URL}/BusArrivalv2?BusStopCode={bus_stop_code}"

try:
    response = requests.get(url, headers=headers)
    response.raise_for_status()  # Raise an exception for HTTP errors
    data = response.json()
    print("Bus Arrival Data:")
    for service in data.get("Services", []):
        print(f"  Service No: {service['ServiceNo']}")
        next_bus = service.get('NextBus', {})
        if next_bus:
            print(f"    Estimated Arrival: {next_bus.get('EstimatedArrival')}")
        next_bus2 = service.get('NextBus2', {})
        if next_bus2:
            print(f"    Next Bus 2 Arrival: {next_bus2.get('EstimatedArrival')}")
except requests.exceptions.RequestException as e:
    print(f"An error occurred: {e}")

JavaScript (Node.js) quickstart

This Node.js example uses axios to retrieve traffic incident information.

const axios = require('axios');

const API_KEY = "YOUR_API_KEY";
const BASE_URL = "http://datamall2.mytransport.sg/ltaodataservice";

const headers = {
    "AccountKey": API_KEY,
    "accept": "application/json"
};

// Example: Get traffic incidents
const url = `${BASE_URL}/TrafficIncidents`;

async function getTrafficIncidents() {
    try {
        const response = await axios.get(url, { headers });
        console.log("Traffic Incidents:");
        if (response.data.value && response.data.value.length > 0) {
            response.data.value.forEach(incident => {
                console.log(`  Type: ${incident.Type}, Message: ${incident.Message}`);
            });
        } else {
            console.log("  No traffic incidents reported.");
        }
    } catch (error) {
        console.error(`An error occurred: ${error.message}`);
    }
}

getTrafficIncidents();

Java quickstart

This Java example uses the built-in HttpClient to fetch real-time carpark availability data.

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.io.IOException;

public class LtaCarparkAvailability {

    private static final String API_KEY = "YOUR_API_KEY";
    private static final String BASE_URL = "http://datamall2.mytransport.sg/ltaodataservice";

    public static void main(String[] args) {
        HttpClient client = HttpClient.newHttpClient();
        String url = BASE_URL + "/CarParkAvailabilityv2";

        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("AccountKey", API_KEY)
                .header("accept", "application/json")
                .build();

        try {
            HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

            if (response.statusCode() == 200) {
                System.out.println("Carpark Availability Data:");
                System.out.println(response.body()); // Parse JSON as needed
            } else {
                System.err.println("Error: " + response.statusCode() + " - " + response.body());
            }
        } catch (IOException | InterruptedException e) {
            System.err.println("An error occurred: " + e.getMessage());
            Thread.currentThread().interrupt();
        }
    }
}

Community libraries

Given the absence of official SDKs, the LTA DataMall ecosystem benefits from community-driven efforts to create libraries. These libraries often wrap the raw REST API calls into more developer-friendly functions, similar to how many open-source projects contribute client libraries for popular APIs PayPal's API overview. Developers are encouraged to search public code repositories like GitHub for community-maintained wrappers or contribute their own.

When using community-maintained libraries, it is advisable to consider factors such as:

  • Maintenance status: How actively is the library maintained and updated?
  • Documentation: Is there clear documentation for installation and usage?
  • Community support: Is there an active community that can provide assistance?
  • Security: Does the library handle API keys and sensitive data securely?
  • Feature completeness: Does it cover all the necessary LTA DataMall APIs your application requires?

While specific community libraries are not officially endorsed by LTA, searching platforms like GitHub for terms such as "LTA DataMall Python" or "LTA DataMall Node.js" can yield various open-source projects. These projects often serve as valuable starting points or examples for building custom integrations.