Installation
Requirements
- Node.js: 18.0.0 or higher
- npm: 7.0.0 or higher (or yarn/pnpm equivalent)
- TypeScript: 5.0.0 or higher (optional, for TypeScript projects)
NPM Installation
bash
npm install tradingview-screenerYarn Installation
bash
yarn add tradingview-screenerPNPM Installation
bash
pnpm add tradingview-screenerTypeScript Support
The library is written in TypeScript and includes full type definitions. No additional @types package is needed.
typescript
// TypeScript works out of the box
import { StockScreener, StockField } from 'tradingview-screener';
const screener = new StockScreener(); // Fully typed!ES Modules vs CommonJS
The package supports both ES Modules and CommonJS:
ES Modules (Recommended)
javascript
import { StockScreener, StockField } from 'tradingview-screener';CommonJS
javascript
const { StockScreener, StockField } = require('tradingview-screener');Verify Installation
Create a test file to verify installation:
typescript
// test.ts
import { StockScreener, StockField } from 'tradingview-screener';
const screener = new StockScreener();
screener.select(StockField.NAME, StockField.PRICE).setRange(0, 5);
screener.get().then(results => {
console.log('Installation successful!');
console.log(`Found ${results.totalCount} stocks`);
console.table(results.data);
});Run it:
bash
# With tsx (recommended for TypeScript)
npm install -g tsx
tsx test.ts
# Or compile first
npx tsc test.ts
node test.jsDevelopment Installation
To contribute to the library or use the latest development version:
bash
# Clone the repository
git clone https://github.com/your-org/tradingview-screener.git
cd tradingview-screener
# Install dependencies
npm install
# Build the library
npm run build
# Run tests
npm test
# Run examples
npm run example:quickstartTroubleshooting
Module Not Found
If you get Cannot find module 'tradingview-screener':
- Verify installation:
npm list tradingview-screener - Clear cache:
npm cache clean --force - Reinstall:
rm -rf node_modules package-lock.json && npm install
TypeScript Errors
If TypeScript can't find types:
Ensure
tsconfig.jsonhas proper module resolution:json{ "compilerOptions": { "moduleResolution": "bundler", "esModuleInterop": true } }Check that types are included:
ls node_modules/tradingview-screener/dist/*.d.ts
Import Errors
For ES Module import errors:
- Add
"type": "module"to yourpackage.json - Or use
.mjsfile extension - Or configure your bundler appropriately
Node Version Issues
If you get errors about unsupported Node features:
bash
# Check your Node version
node --version
# Should be v18.0.0 or higher
# Upgrade if needed:
nvm install 18 # if using nvm
# or download from nodejs.orgNext Steps
- Quick Start Guide - Build your first screener
- Basic Usage - Learn core concepts
- Stock Screener - Detailed stock screening guide
Optional Dependencies
For MCP Server
If using the MCP server functionality:
bash
npm install @modelcontextprotocol/sdkFor Code Generation
If generating field definitions:
bash
npm install --save-dev playwrightFor Development
For contributing or local development:
bash
npm install --save-dev \
typescript \
vitest \
tsup \
tsx \
@types/node