Authentication
How to get your API key and authenticate with Ola Maps API
Authentication
To use the Ola Maps API, you need an API key. This guide explains how to obtain and use your API key.
Getting Your API Key
Step 1: Create an Account
- Visit the Ola Maps Developer Portal
- Click on "Sign Up" or "Register"
- Complete the registration process
Step 2: Generate API Key
- Log in to your developer account
- Navigate to the "API Keys" section
- Click "Generate New API Key"
- Give your API key a descriptive name (e.g., "Production", "Development")
- Copy and securely store your API key
Important: Your API key is like a password. Never share it publicly or commit it to version control.
Using Your API Key
Basic Usage
Initialize the SDK client with your API key:
const OlaMapsClient = require('ola-map-sdk');
const client = new OlaMapsClient('YOUR_API_KEY');Environment Variables (Recommended)
For security, use environment variables:
1. Create a .env file:
OLA_MAPS_API_KEY=your_api_key_here2. Load environment variables:
require('dotenv').config();
const OlaMapsClient = require('ola-map-sdk');
const client = new OlaMapsClient(process.env.OLA_MAPS_API_KEY);3. Install dotenv:
npm install dotenvNode.js Applications
In server-side applications:
// config/maps.js
const OlaMapsClient = require('ola-map-sdk');
const client = new OlaMapsClient(process.env.OLA_MAPS_API_KEY);
module.exports = client;Then use it in your application:
const client = require('./config/maps');
// Use the client
const results = await client.places.autocomplete('Bangalore');Need Help?
- Visit the Ola Maps Developer Portal