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 🙏

© 2026 – Pkg Stats / Ryan Hefner

rentalcar-api-sdk

v1.0.0

Published

SDK for RentalCar Manager API integration

Readme

RentalCar Manager API Integration Guide

Environment Variables

RENTALCAR_API_KEY=your_api_key
RENTALCAR_SHARED_SECRET=your_shared_secret
RENTALCAR_API_URL=https://api.rentalcarmanager.com/v32

Authentication Flow

  1. Token Generation

    • Endpoint: ${RENTALCAR_API_URL}/token
    • Method: POST
    • Headers: Content-Type: application/x-www-form-urlencoded
    • Body:
      username=${RENTALCAR_API_KEY}&password=${RENTALCAR_SHARED_SECRET}&grant_type=password
    • Response:
      {
        "access_token": "token_value",
        "token_type": "bearer",
        "expires_in": 1799
      }
    • Token validity: 30 minutes
  2. API Methods

Find Booking

  • Endpoint: ${RENTALCAR_API_URL}/api
  • Method: POST
  • Headers:
    Content-Type: application/json
    Authorization: Bearer ${token}
  • Body:
    {
      "method": "findbooking",
      "reservationno": "reservation_number",
      "lastname": "customer_lastname"
    }
  • Response:
    {
      "status": "OK",
      "error": "",
      "results": [
        {
          "reservationref": "reference_id"
        }
      ]
    }

Booking Info

  • Endpoint: ${RENTALCAR_API_URL}/api
  • Method: POST
  • Headers:
    Content-Type: application/json
    Authorization: Bearer ${token}
  • Body:
    {
      "method": "bookinginfo",
      "reservationref": "reference_id"
    }
  • Response: Detailed booking information

Example Implementation

// src/services/rentalcar/types.ts
export interface RentalCarConfig {
  apiKey: string;
  sharedSecret: string;
  apiUrl: string;
}

export interface TokenResponse {
  access_token: string;
  token_type: string;
  expires_in: number;
}

export interface BookingSearchParams {
  reservationno: string;
  lastname: string;
}

// src/services/rentalcar/client.ts
export class RentalCarClient {
  private token: string | null = null;
  private tokenExpiration: Date | null = null;

  constructor(private config: RentalCarConfig) {}

  private async getToken(): Promise<string> {
    if (
      this.token &&
      this.tokenExpiration &&
      new Date() < this.tokenExpiration
    ) {
      return this.token;
    }

    const params = new URLSearchParams({
      username: this.config.apiKey,
      password: this.config.sharedSecret,
      grant_type: "password",
    });

    const response = await fetch(`${this.config.apiUrl}/token`, {
      method: "POST",
      headers: {
        "Content-Type": "application/x-www-form-urlencoded",
      },
      body: params,
    });

    if (!response.ok) {
      throw new Error("Failed to get token");
    }

    const data: TokenResponse = await response.json();
    this.token = data.access_token;
    this.tokenExpiration = new Date(Date.now() + (data.expires_in - 60) * 1000);

    return this.token;
  }

  async findBooking(params: BookingSearchParams) {
    const token = await this.getToken();

    const response = await fetch(`${this.config.apiUrl}/api`, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        Authorization: `Bearer ${token}`,
      },
      body: JSON.stringify({
        method: "findbooking",
        ...params,
      }),
    });

    return response.json();
  }

  async getBookingInfo(reservationref: string) {
    const token = await this.getToken();

    const response = await fetch(`${this.config.apiUrl}/api`, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        Authorization: `Bearer ${token}`,
      },
      body: JSON.stringify({
        method: "bookinginfo",
        reservationref,
      }),
    });

    return response.json();
  }
}

Usage Example

// Initialize client
const client = new RentalCarClient({
  apiKey: process.env.RENTALCAR_API_KEY!,
  sharedSecret: process.env.RENTALCAR_SHARED_SECRET!,
  apiUrl: process.env.RENTALCAR_API_URL!,
});

// Find booking
const booking = await client.findBooking({
  reservationno: "12345",
  lastname: "Smith",
});

// Get booking details
const details = await client.getBookingInfo(booking.results[0].reservationref);

Error Handling

The API returns errors in the following format:

{
  "status": "ERR",
  "error": "Error message",
  "results": null
}

Common error codes:

  • 401: Authentication failed
  • 400: Invalid parameters
  • 404: Booking not found
  • 500: Server error

Best Practices

  1. Token Management

    • Cache the token until near expiration
    • Implement automatic token refresh
    • Handle token errors gracefully
  2. Error Handling

    • Implement retry logic for network errors
    • Log API errors for debugging
    • Provide meaningful error messages to users
  3. Security

    • Never expose API keys in client-side code
    • Store sensitive data in environment variables
    • Implement rate limiting if needed