npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

ola-maps-client

v1.0.1

Published

A TypeScript/JavaScript SDK for the Ola Maps API, providing easy access to places, geocoding, routing, and tiles services.

Readme

Ola Maps SDK

A TypeScript/JavaScript SDK for the Ola Maps API, providing easy access to places, geocoding, routing, and tiles services.

⚠️ Important Notice

This SDK has limited API support and was created for personal use. It currently covers basic functionality for the Ola Maps API endpoints. If you need additional features or encounter issues, feel free to raise improvement PRs at github.

Installation

npm install ola-maps-sdk

Quick Start

import { OlaMapsClient } from "ola-maps-sdk";

// Initialize the client
const client = new OlaMapsClient("your-api-key-here");

// Use the services
const results = await client.places.autocomplete({
    input: "Bangalore",
    location: "12.9716,77.5946",
});

API Reference

Initialization

const client = new OlaMapsClient(apiKey, baseURL?);
  • apiKey: Your Ola Maps API key (required)
  • baseURL: Custom base URL (optional, defaults to https://api.olamaps.io)

Services

Places Service

Autocomplete

Get place suggestions based on input text.

const suggestions = await client.places.autocomplete({
    input: "Coffee shop",
    location: "12.9716,77.5946", // lat,lng
    radius: 1000, // optional
    types: "establishment", // optional
});

Place Details

Get detailed information about a specific place.

const details = await client.places.details({
    place_id: "place_id_here",
});

Advanced Place Details

Get comprehensive details about a place.

const advancedDetails = await client.places.advancedDetails({
    place_id: "place_id_here",
});

Geocoding Service

Forward Geocoding

Convert addresses to coordinates.

const geocodeResult = await client.geocode.geocode({
    address: "Koramangala, Bangalore",
    language: "English", // optional, defaults to English
});

Reverse Geocoding

Convert coordinates to address.

const reverseResult = await client.geocode.reverseGeocode({
    latitude: 12.9716,
    longitude: 77.5946,
});

Routing Service

Get Directions

Calculate routes between two points.

const directions = await client.routing.getDirections(
    { latitude: 12.9716, longitude: 77.5946 }, // origin
    { latitude: 13.0827, longitude: 80.2707 }, // destination
    {
        alternatives: true, // optional
        steps: true, // optional
        overview: "full", // optional: 'full', 'simplified', 'false'
        language: "en", // optional
        traffic_metadata: false, // optional
    }
);

Tiles Service

Get Data Tile JSON

Retrieve vector tile configuration for a dataset.

const tileConfig = await client.tiles.getDataTileJSON("dataset-name");

Get Available Styles

List all available map styles.

const styles = await client.tiles.getStyles();

Get Style by Name

Get specific map style configuration.

const style = await client.tiles.getStyleByName("style-name");

Types

The SDK includes TypeScript definitions for all request and response objects:

interface GeocodeRequest {
    address: string;
    language?: string;
}

interface ReverseGeocodeRequest {
    latitude: number;
    longitude: number;
}

interface PlacesAutoCompleteRequest {
    input: string;
    location?: string;
    radius?: number;
    types?: string;
    [key: string]: any;
}

interface PlacesDetailsRequest {
    place_id: string;
}

interface Coordinates {
    latitude: number;
    longitude: number;
}

interface GetDirectionsOptions {
    alternatives?: boolean;
    steps?: boolean;
    overview?: "full" | "simplified" | "false";
    language?: string;
    traffic_metadata?: boolean;
}

Error Handling

The SDK uses the underlying HTTP client for error handling. Wrap your calls in try-catch blocks:

try {
    const result = await client.places.autocomplete({
        input: "Invalid location",
    });
} catch (error) {
    console.error("API call failed:", error);
}

Examples

Complete Places Search Flow

import { OlaMapsClient } from "ola-maps-sdk";

const client = new OlaMapsClient("your-api-key");

async function searchAndGetDetails() {
    try {
        // 1. Search for places
        const suggestions = await client.places.autocomplete({
            input: "Pizza",
            location: "12.9716,77.5946",
        });

        // 2. Get details for first result
        if (suggestions.predictions?.length > 0) {
            const placeId = suggestions.predictions[0].place_id;
            const details = await client.places.details({ place_id: placeId });
            console.log("Place details:", details);
        }
    } catch (error) {
        console.error("Error:", error);
    }
}

Route Planning

async function planRoute() {
    const origin = { latitude: 12.9716, longitude: 77.5946 };
    const destination = { latitude: 13.0827, longitude: 80.2707 };

    try {
        const route = await client.routing.getDirections(origin, destination, {
            alternatives: true,
            steps: true,
            traffic_metadata: true,
        });

        console.log("Route found:", route.routes[0]);
    } catch (error) {
        console.error("Routing failed:", error);
    }
}

Limitations

  • This SDK covers basic functionality of the Ola Maps API
  • Limited error handling and validation
  • Created for personal use - production usage may require additional features
  • Not all API endpoints may be implemented

Contributing

This is a personal project with limited API support. However, contributions are welcome!

To contribute:

  1. Fork the repository at [your-repository-url]
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

Areas for improvement:

  • Additional API endpoint support
  • Better error handling
  • Response type definitions
  • Input validation
  • Unit tests
  • Documentation improvements

License

[Your chosen license]

Support

For issues or feature requests, please:

  1. Check existing issues at [your-repository-url]
  2. Create a new issue with detailed information
  3. Submit a PR with improvements

Note: Remember to keep your API key secure and never commit it to version control. Consider using environment variables or a secure configuration management system.