Skip to content

luongnv89/yt-search-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

yt-search-lib Logo

YouTube Search Library

A powerful, purely client-side JavaScript library for searching YouTube videos without an official API key. Built with modern JavaScript, zero dependencies, and comprehensive caching.

✨ Key Features

  • No API Key Required - Works with YouTube's InnerTube API
  • 100% Client-Side - No server code needed (with configurable CORS proxies)
  • Smart Caching - LRU cache with localStorage persistence
  • TypeScript Support - Full type definitions included
  • Zero Dependencies - Pure JavaScript, no bloat
  • Works Everywhere - Browser and Node.js compatible

🚀 Quick Start

npm install yt-search-lib
import { YouTubeClient } from 'yt-search-lib';

const client = new YouTubeClient({
  proxyUrl: 'http://127.0.0.1:3000/proxy?url=' // or use Render, etc.
});

const results = await client.search('lofi hip hop', { limit: 5 });
results.forEach(video => console.log(video.title));

📚 Documentation

Complete documentation is in the /docs directory.

Quick Links

📋 Installation

npm install yt-search-lib

🔧 Configuration

const client = new YouTubeClient({
  proxyUrl: 'https://your-proxy.com/proxy?url=', // Required for browsers
  useCache: true,                                    // Enable caching
  cacheMaxAge: 3600000                              // 1 hour cache TTL
});

See API Reference for all configuration options.

⚠️ Important: CORS Proxies

Browsers block direct requests to YouTube. You must use a CORS proxy:

  • Development: http://127.0.0.1:3000/proxy?url= (run npm run proxy:start)
  • Production: Deploy your own proxy or use Render

See Deployment Guide for options.

💡 Common Use Cases

Goal Guide
Search from React React Integration
Build API backend Express.js Integration
Deploy to production Deployment Options
Handle errors Error Handling
Optimize caching Caching Strategy
Fix a problem Troubleshooting

🛠️ Development

npm run build          # Build the library
npm run test           # Run tests
npm run test:integration:proxy  # Integration tests with proxy
npm run proxy:start    # Start local CORS proxy
npm run lint          # Run ESLint
npm run format        # Format with Prettier

See Development Guide for details.

📄 License

MIT - See LICENSE file for details

🤝 Contributing

We welcome contributions! See Contributing Guide and Code of Conduct.

🆘 Support


Ready to get started?Full Documentation

About

A powerful, purely client-side JavaScript library for searching YouTube videos without an official API key

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors