Features
The author search functionality allows searching for MTMT authors by name or MTMT ID, with support for voice input and real-time suggestions.
Features
- Real-time author suggestions while typing
- MTMT ID validation
- Voice search support
API Endpoints
Used for real-time search suggestions
// API Endpoints
// 1. Author Suggestions API
GET https://m2.mtmt.hu/api/author
?size=200 // Maximum number of results
&depth=0 // Basic information only
&cond=label;any;{searchTerm} // Search in author names
&sort=familyName,asc // Sort by family name and given name
&sort=givenName,asc
&labelLang=hun // Hungarian labels
&format=json // Response format
// 2. Author Verification API
GET https://m2.mtmt.hu/api/author/{mtmtId}?format=json
Search Implementation
The search implementation includes debouncing to prevent excessive API calls and provides real-time suggestions as the user types:
// Author search with debouncing
const fetchAuthorSuggestions = useCallback(
debounce(async (input: string) => {
if (input.length < 3) {
setAuthorState(prev => ({ ...prev, suggestions: [] }));
return;
}
const response = await fetch.authorSuggestions(input);
if (!response.ok) throw new Error("Failed to fetch suggestions");
setAuthorState(prev => ({
...prev,
suggestions: response.data.content.map((item: any) => ({
id: item.mtid,
name: item.label
}))
}));
}, 300),
[]
);
Voice Search Implementation
Voice search is implemented using the Web Speech API, with fallback handling for browsers that don't support it:
// Voice search implementation
const startListening = async () => {
// Request microphone permission
const hasPermission = await requestMicrophonePermission();
if (!hasPermission) return;
const SpeechRecognition = window.SpeechRecognition ||
window.webkitSpeechRecognition;
const recognition = new SpeechRecognition();
recognition.lang = 'hu-HU';
recognition.continuous = false;
recognition.interimResults = false;
recognition.onresult = (event) => {
const transcript = event.results[0][0].transcript;
setAuthorState(prev => ({ ...prev, name: transcript }));
fetchAuthorSuggestions(transcript);
};
await recognition.start();
};
Response Format
The API returns author suggestions in the following format:
// Example response from author suggestions API
{
"content": [
{
"mtid": 10012345,
"label": "Dr. Example Name (Department)",
"familyName": "Example",
"givenName": "Name",
"auxName": "Department"
}
]
}
Usage Guidelines
Best Practices
- Enter at least 3 characters for name search
- Use the exact MTMT ID if known
- Check for the green checkmark to confirm valid MTMT ID
Error Handling
Common Errors
- Invalid MTMT ID: The provided ID does not exist in the MTMT database
- API Connection Error: Failed to connect to MTMT servers
- Voice Recognition Error: Microphone access denied or browser does not support voice input