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

@openpets/flights

v1.0.2

Published

Flight search plugin for OpenCode - search for flights, compare prices, and find the best travel options

Readme

Flights Plugin for OpenCode

A comprehensive flight search plugin that enables you to search for flights, find airport codes, and plan travel dates directly within OpenCode. This plugin uses the factory pattern and supports multiple flight search providers with automatic fallbacks.

Features

  • Flight Search: Search for one-way or round-trip flights between any airports
  • Real-time Pricing: Get current flight prices from major airlines
  • Airport Lookup: Find airport codes by city name or airport name
  • Travel Planning: Calculate suggested travel dates based on your preferences
  • Multiple Providers: Support for SerpAPI (Google Flights), RapidAPI, and Amadeus
  • Mock Mode: Test the plugin without API keys using sample data

Prerequisites

  • OpenCode installed and configured
  • Node.js 16+ (for running the plugin)
  • API key from one of the supported providers (optional for testing)

Supported Providers

1. SerpAPI (Recommended)

  • Description: Provides Google Flights data with the best coverage and accuracy
  • Cost: Free tier available (100 searches/month), paid plans starting at $50/month
  • Get API Key: https://serpapi.com/
  • Best For: Most users, best data quality and coverage

2. RapidAPI

  • Description: Access to multiple flight search APIs
  • Cost: Varies by API, free tiers available
  • Get API Key: https://rapidapi.com/
  • Best For: Alternative to SerpAPI, multiple API options

3. Amadeus

  • Description: Professional flight search API used by travel agencies
  • Cost: Free tier available (limited requests), paid tiers for production
  • Get API Key: https://developers.amadeus.com/
  • Best For: Professional applications, advanced features

Setup

1. Install Dependencies

From the repository root:

pnpm install

2. Configure Environment

Copy the example environment file:

cd pets/flights
cp .env.example .env

Edit .env and add your API key:

SERPAPI_API_KEY=your_serpapi_key_here
FLIGHT_PROVIDER=serpapi
MAX_RESULTS=10
DEFAULT_CABIN_CLASS=economy

3. Configure OpenCode

Add the flights plugin to your OpenCode configuration in opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": [
    "./pets/flights/index.ts"
  ]
}

Available Tools

1. search-flights

Search for one-way or round-trip flights between airports.

Parameters:

  • from (required): Departure airport code (3-letter IATA code)
  • to (required): Arrival airport code (3-letter IATA code)
  • departureDate (required): Departure date in YYYY-MM-DD format
  • returnDate (optional): Return date for round-trip flights
  • adults (optional): Number of adult passengers (default: 1)
  • children (optional): Number of children (default: 0)
  • cabinClass (optional): economy, premium_economy, business, or first
  • maxResults (optional): Maximum number of results (default: 10)

Examples:

opencode run "search flights from LAX to JFK on 2025-01-15"
opencode run "search round trip flights from SFO to NYC departing 2025-01-15 returning 2025-01-22"
opencode run "search business class flights from LAX to LHR on 2025-03-01"

2. search-airports

Find airport codes by city name, airport name, or partial code.

Parameters:

  • query (required): Search term (city/airport name)

Examples:

opencode run "find airport code for Los Angeles"
opencode run "search airports in Tokyo"

3. calculate-travel-dates

Calculate suggested travel dates for flexible planning.

Parameters:

  • daysFromNow (optional): Days from today for departure (default: 30)
  • tripLength (optional): Trip length in days (default: 7)

Examples:

opencode run "calculate travel dates 45 days from now for 10 day trip"
opencode run "suggest dates for a 5 day trip next month"

4. get-provider-status

Check active provider and configuration status.

Example:

opencode run "check provider status"

Mock Mode (No API Key Required)

The plugin includes a mock provider for testing without API keys. It returns sample data for major airports and realistic flight information.

Configuration Options

All configuration via environment variables in .env:

SERPAPI_API_KEY=your_key
FLIGHT_PROVIDER=serpapi
MAX_RESULTS=10
DEFAULT_CABIN_CLASS=economy
LOG_LEVEL=info
REQUEST_TIMEOUT=30000

Common Use Cases

Planning a Vacation

opencode run "calculate travel dates 30 days from now for 14 days"
opencode run "find airports in Hawaii"
opencode run "search round trip from LAX to HNL departing 2025-12-20 returning 2026-01-03"

Business Travel

opencode run "search business class flights from SFO to NYC on 2025-01-15"
opencode run "find airports in New York"

Troubleshooting

"No flights found"

  • Verify airport codes are valid 3-letter IATA codes
  • Check dates are in YYYY-MM-DD format and in the future
  • Ensure API key has available quota

"Using mock data" warning

  • No API key is configured
  • Add valid API key to .env file

Module resolution errors

  • Ensure you're running from the openpets directory
  • Check that all dependencies are installed with pnpm install

Development

Project Structure

pets/flights/
├── index.ts           # Main plugin implementation
├── package.json       # Plugin metadata
├── .env.example       # Environment template
├── README.md          # This file
└── reference/         # Python reference implementations

Testing

npm run quickstart      # Quick test
npm run test:queries    # Test all queries
npm run test:scenarios  # Test all scenarios

License

MIT

Acknowledgments

This plugin merges functionality from: