The TravelTime API SDK for Node.js (current stable version 7.3.3) provides a robust interface for interacting with the TravelTime API. This SDK is designed for TypeScript projects, offering type safety and comprehensive autocomplete. Its primary function is to enable developers to find locations and calculate travel times based on journey time rather than traditional 'as the crow flies' distance, facilitating more relevant and personalized spatial search applications. The library sees frequent updates, including regular CVE patching and minor feature enhancements, ensuring a stable and secure development experience. It differentiates itself by focusing on realistic travel time calculations across various transport modes, crucial for logistics, real estate, and urban planning applications.
npm install traveltime-apiVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to initialize the TravelTimeClient with API keys and rate limit settings, then performs a basic `timeMap` departure search request for a location in London, logging the successful response or any errors.
When creating `TravelTimeClient`, set `rateLimitSettings: { enabled: true, hitsPerMinute: YOUR_PLAN_HPM, retryCount: 3, timeBetweenRetries: 1000 }`. Adjust `hitsPerMinute` to match your TravelTime API plan.Periodically run `npm update traveltime-api` to get the latest security patches and integrate dependency scanning tools (e.g., Dependabot, Snyk) into your CI/CD pipeline.
Always access the response data via `response.data` after awaiting an API call, e.g., `const result = (await client.someApiCall(params)).data;`.
Consult the official TravelTime Node.js SDK documentation and any available migration guides when upgrading from versions prior to 7.0.0 to understand and adapt to updated API patterns.
Enable and correctly configure `rateLimitSettings` when initializing your `TravelTimeClient` instance. Set `enabled: true`, provide your `hitsPerMinute` value, and optionally adjust `retryCount` and `timeBetweenRetries`.
Ensure your project is configured for ES Modules (e.g., `"type": "module"` in `package.json` for Node.js) and use `import { TravelTimeClient } from 'traveltime-api';`. If bound to CommonJS, consider using a transpiler (e.g., Babel, TypeScript with `moduleResolution: 'node'` and `module: 'CommonJS'`) or adjust your import strategy.Pass your `applicationId` and `apiKey` (obtained from the TravelTime Developer Portal Dashboard) as part of the client configuration object: `new TravelTimeClient({ applicationId: 'YOUR_APP_ID', apiKey: 'YOUR_APP_KEY' })`. Always use environment variables for these sensitive credentials.