Prerequisites

Before you begin, ensure you have an API key from our developer portal.

Step 1: Configure Your Environment

First, install Axios for HTTP requests:

npm install axios

Step 2: Make Your First API Call

Use the following JavaScript code to make a POST request to our Routing API:

const axios = require('axios');

async function fetchRoute() {
  const apiKey = 'YOUR_API_KEY_HERE';
  const apiUrl = 'https://www.usepathway.dev/api/routing';
  const payload = {
    data: {
      coordinates: [
        [12.9715987, 77.5945627],  // Example coordinate
        [13.0826802, 80.2707184]   // Example coordinate
      ]
    }
  };

  try {
    const response = await axios.post(apiUrl, payload, {
      headers: { 'x-api-key': apiKey }
    });
    console.log(response.data);
  } catch (error) {
    console.error('Error:', error.response.data);
  }
}

fetchRoute();

Step 3: Next Steps

Explore further endpoints and configurations as detailed in our full API documentation sections on authentication, request structures, and more.