-
-
Notifications
You must be signed in to change notification settings - Fork 977
Expand file tree
/
Copy pathdrawings.js
More file actions
16 lines (13 loc) 路 768 Bytes
/
Copy pathdrawings.js
File metadata and controls
16 lines (13 loc) 路 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Drawings of a saved layout (the ID in tradingview.com/chart/<ID>/).
// Private layouts need credentials and your user ID (see examples/user-login.js).
// Run: npm run build && node --env-file=.env examples/drawings.js <layoutId> [userId]
import { getDrawings } from '@mathieuc/tradingview';
const [layoutId, userId] = process.argv.slice(2);
if (!layoutId) throw new Error('Please specify a layout ID');
const drawings = await getDrawings(layoutId, {
credentials: process.env.SESSION ? { session: process.env.SESSION, signature: process.env.SIGNATURE } : undefined,
userId: userId ? Number(userId) : undefined,
});
console.log(`Found ${drawings.length} drawings:`, drawings.map((d) => ({
id: d.id, symbol: d.symbol, type: d.type, text: d.state?.text,
})));