
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
brave-search
Advanced tools
A TypeScript library for interacting with the Brave Search API, including web search, local POI search, and automatic summarization features.
A TypeScript library for interacting with the Brave Search API, providing easy access to web search, local POI search, and automatic summarization features.
Install the package using npm:
npm install brave-search
Obtain a Brave Search API key from Brave Search API Dashboard.
Install the package:
npm install brave-search
Import and initialize the BraveSearch
class:
import { BraveSearch } from "brave-search";
const BRAVE_API_KEY = "your-api-key-here";
const braveSearch = new BraveSearch(BRAVE_API_KEY);
Perform a web search:
const webSearchResults = await braveSearch.webSearch("TypeScript tutorial", {
count: 5,
safesearch: "off",
search_lang: "en",
country: "US",
text_decorations: false,
});
console.log(webSearchResults);
Get a summarized answer for a query (requires "Data for AI pro" plan):
const { summary, webSearchResponse } = await braveSearch.getSummarizedAnswer(
"What is TypeScript?",
{
count: 5,
safesearch: "off",
search_lang: "en",
country: "US",
text_decorations: false,
freshness: "pw",
spellcheck: false,
extra_snippets: true,
summary: true,
},
);
console.log(summary);
console.log(webSearchResponse);
Search for local points of interest:
const poiResults = await braveSearch.localPoiSearch("poi_id1", "poi_id2");
console.log(poiResults);
Get descriptions for local points of interest:
const descriptionResults = await braveSearch.localDescriptionsSearch(
"poi_id1",
"poi_id2",
);
console.log(descriptionResults);
The library supports various search options as defined in the Brave Search API documentation. Here are some of the available options:
interface BraveSearchOptions {
country?: string;
search_lang?: string;
ui_lang?: string;
safesearch?: "off" | "moderate" | "strict";
freshness?: "pd" | "pw" | "pm" | "py" | string;
text_decorations?: boolean;
spellcheck?: boolean;
goggles_id?: string;
units?: "metric" | "imperial";
extra_snippets?: boolean;
count?: number;
result_filter?: ResultFilterType;
summary?: boolean;
}
For a complete list of options and their descriptions, please refer to the Brave Search API Documentation.
summary
option and getSummarizedAnswer
method are only available with
the Brave "Data for AI pro" plan.For detailed API reference, please refer to the Brave Search API Documentation.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
This library is not officially associated with Brave Software. It is a third-party implementation of the Brave Search API.
FAQs
A fully typed Brave Search API wrapper, providing easy access to web search, local POI search, and automatic polling for web search summary feature.
The npm package brave-search receives a total of 36 weekly downloads. As such, brave-search popularity was classified as not popular.
We found that brave-search demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.