searchLibrary method finds libraries matching your search query and library name, ranked by relevance to your specific use case.
Method Signature
Parameters
The user’s question or task description. This is used for relevance ranking to return the most appropriate library matches.Examples:
"I need to build a REST API""Building a dashboard with charts""State management for React app"
The name of the library to search for. This doesn’t need to be an exact match.Examples:
"react""express""typescript"
Configuration options for the search request
Return Types
JSON Format (Default)
Returns an array ofLibrary objects:
Array of matching libraries, ordered by relevance
Text Format
Returns a formatted string with library information ready for display or LLM consumption.Examples
Basic Search (JSON)
Search for React libraries and get structured data:Explicit JSON Format
Text Format for LLMs
Get pre-formatted text suitable for feeding to language models:Filtering by Quality
Find high-quality libraries based on benchmark scores:Library Discovery UI
Build a library selection interface:Comparing Multiple Libraries
Error Handling
Empty Query Validation
Type Definitions
SearchLibraryOptions
Library
Best Practices
Write Descriptive Queries
Better queries lead to more relevant results:Use Quality Scores
Consider both trust and benchmark scores when selecting libraries:Cache Results
For repeated searches, consider caching results:Next Steps
Get Documentation Context
Learn how to retrieve documentation snippets for a specific library