Search
Royal Protocol Search
The Royal Protocol provides flexible search capabilities for finding accounts and provenance claims. There are two ways to use the search functionality, depending on your tech stack and preferences.
Search Methods
Search with Client SDK
The recommended approach for JavaScript/TypeScript applications is to use the SearchClient
class, which offers:
- A clean, strongly-typed interface for search operations
- Simplified response handling with formatted data
- Helper methods for common search patterns
- Built-in error handling and type safety
import { SearchClient } from '@royal/protocol-client';
const client = new SearchClient({ apiKey: YOUR_API_KEY});
const results = await client.searchAll("alice");
Learn more about using the SearchClient →
Direct API Access
For applications using other programming languages or requiring direct API access, you can use the raw HTTP endpoints:
- Make requests directly to the REST API
- Process the raw Typesense response format
- Implement in any programming language that supports HTTP requests
- Full control over request and response handling
curl -X POST "https://api.royal.io/v0/provenance/search" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_KEY" \ -d '{ "searchParameters": { "q": "alice", "query_by": "username,psqlId,contentHash" } }'
Learn more about the Search API endpoints →
Common Use Cases
Regardless of which method you choose, the Royal Protocol Search enables you to:
- Find accounts by username or ID
- Search for provenance claims by content hash, name, or metadata
- Filter results by type, creator, or other attributes
- Sort results by various fields
- Paginate through large result sets
- Perform advanced queries with faceting and grouping