Skip to content

search_apple_docs returns 0 results for valid APIs (Apple search page is now JS-rendered) #51

Description

@profmike

Summary

search_apple_docs (and search_wwdc_content) return 0 results even for common, well-documented Apple APIs — e.g. NavigationStack, Observable, ScrollView — while search_framework_symbols and get_apple_doc_content return those exact pages fine.

Root cause

searchAppleDocs fetches https://developer.apple.com/search/?q=<query> and parses .search-result DOM nodes (src/index.tsparseSearchResults). That page is now JS-rendered: the shell HTML only echoes the query, and results are loaded client-side by /search/scripts/search.js, which calls window.SEARCH_CONFIG.api (an Apple host, path /api/v1/search) that isn't reachable as a public JSON endpoint. So the .search-result selector matches nothing and the parser returns 0 for essentially every query. The legacy search_data.php endpoint is also gone (404).

Repro

search_apple_docs("NavigationStack")   → 0 results
search_framework_symbols("swiftui", namePattern="NavigationStack")  → NavigationStack (struct)
get_apple_doc_content("https://developer.apple.com/documentation/swiftui/navigationstack")  → full page

Suggested fix

When the HTML scrape yields 0 results, fall back to the stable public documentation index JSON — the same source search_framework_symbols already uses (https://developer.apple.com/tutorials/data/index/<framework>). Resolve candidate frameworks from the query (a symbol-prefix → framework map plus a common-framework scan set), fetch their indexes in parallel, and return matching symbols. This is index-backed rather than dependent on Apple's shifting/internal search API.

Happy to open a PR if useful.

Environment: v1.0.26, macOS, Node 20.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions