Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 141 additions & 0 deletions cli-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3141,6 +3141,147 @@
"modulePath": "brave/search.js",
"sourceFile": "brave/search.js"
},
{
"site": "bse-india",
"name": "announcements",
"description": "Latest BSE corporate announcements, optionally filtered by text",
"access": "read",
"domain": "api.bseindia.com",
"strategy": "public",
"browser": false,
"args": [
{
"name": "query",
"type": "string",
"default": "",
"required": false,
"help": "Optional company/text filter"
},
{
"name": "limit",
"type": "int",
"default": 10,
"required": false,
"help": "Max announcements (1-50)"
}
],
"columns": [
"rank",
"title",
"newsId",
"url"
],
"type": "js",
"modulePath": "bse-india/announcements.js",
"sourceFile": "bse-india/announcements.js"
},
{
"site": "bse-india",
"name": "indices",
"description": "BSE index snapshot, including Sensex and sector indices",
"access": "read",
"domain": "api.bseindia.com",
"strategy": "public",
"browser": false,
"args": [
{
"name": "limit",
"type": "int",
"default": 20,
"required": false,
"help": "Max indices (1-100)"
}
],
"columns": [
"rank",
"code",
"name",
"alias",
"price",
"change",
"changePct",
"updateTime",
"url"
],
"type": "js",
"modulePath": "bse-india/indices.js",
"sourceFile": "bse-india/indices.js"
},
{
"site": "bse-india",
"name": "movers",
"description": "BSE gainers, losers, or top turnover securities",
"access": "read",
"domain": "api.bseindia.com",
"strategy": "public",
"browser": false,
"args": [
{
"name": "type",
"type": "string",
"default": "gainers",
"required": false,
"help": "gainers / losers / turnover"
},
{
"name": "limit",
"type": "int",
"default": 10,
"required": false,
"help": "Max rows (1-10)"
}
],
"columns": [
"rank",
"code",
"symbol",
"name",
"price",
"change",
"changePct",
"turnoverCr",
"volume",
"url"
],
"type": "js",
"modulePath": "bse-india/movers.js",
"sourceFile": "bse-india/movers.js"
},
{
"site": "bse-india",
"name": "quote",
"description": "BSE stock quote by symbol, company name, ISIN, or code",
"access": "read",
"domain": "api.bseindia.com",
"strategy": "public",
"browser": false,
"args": [
{
"name": "symbol",
"type": "str",
"required": true,
"positional": true,
"help": "BSE symbol, code, company name, or ISIN"
}
],
"columns": [
"code",
"symbol",
"name",
"isin",
"price",
"change",
"changePct",
"open",
"high",
"low",
"updateTime",
"url"
],
"type": "js",
"modulePath": "bse-india/quote.js",
"sourceFile": "bse-india/quote.js"
},
{
"site": "chatgpt",
"name": "ask",
Expand Down
68 changes: 68 additions & 0 deletions clis/bse-india/announcements.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { EmptyResultError } from '@agentrhq/webcmd/errors';
import { cli, Strategy } from '@agentrhq/webcmd/registry';
import { BSE_API, BSE_SITE, bseJson, requireLimit, text } from './utils.js';

function newsId(value) {
return String(value ?? '').split('&')[0].trim();
}

function announcementRows(body) {
let value = body;
if (typeof body === 'string') {
try {
value = JSON.parse(body);
} catch {
value = [];
}
}
return Array.isArray(value) ? value : [];
}

function announcementTitle(row) {
return text(row?.Subject ?? row?.NewsSubj);
}

async function companyNews(query) {
const matches = await bseJson(`${BSE_API}/GetQuoteAllSearchDatabeta/w?searchString=${encodeURIComponent(query)}`, 'bse-india announcements company search');
const rows = Array.isArray(matches) ? matches : [];
const match = rows.find((row) => /Equity/i.test(String(row?.Type ?? '')));
const code = String(match?.strSricpCode ?? '').trim();
if (!code)
return null;
const body = await bseJson(`${BSE_API}/TabResults_PAR/w?scripcode=${encodeURIComponent(code)}&tabtype=NEWS`, 'bse-india announcements company news');
return announcementRows(body);
}

cli({
site: 'bse-india',
name: 'announcements',
access: 'read',
description: 'Latest BSE corporate announcements, optionally filtered by text',
domain: 'api.bseindia.com',
strategy: Strategy.PUBLIC,
browser: false,
args: [
{ name: 'query', type: 'string', default: '', help: 'Optional company/text filter' },
{ name: 'limit', type: 'int', default: 10, help: 'Max announcements (1-50)' },
],
columns: ['rank', 'title', 'newsId', 'url'],
func: async (args) => {
const query = String(args.query ?? '').trim().toLowerCase();
const limit = requireLimit(args.limit, 10, 50);
const companyRows = query ? await companyNews(query) : null;
const body = companyRows ? companyRows : announcementRows(await bseJson(`${BSE_API}/CorpAnn/w`, 'bse-india announcements'));
const rows = body
.filter((row) => companyRows || !query || String(row?.Subject ?? '').toLowerCase().includes(query))
.slice(0, limit);
if (!rows.length) throw new EmptyResultError('bse-india announcements', query ? `No announcements matched "${args.query}".` : 'BSE returned no announcements.');
return rows.map((row, i) => {
const id = newsId(row?.Newsid);
return {
rank: i + 1,
title: announcementTitle(row),
newsId: id,
url: id ? `${BSE_SITE}/corporates/anndet_new.aspx?newsid=${encodeURIComponent(id)}` : null,
};
});
},
});
Loading
Loading