You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The find similar endpoint finds pages that are similar to a given URL. This is useful for discovering related content, finding alternative sources, or expanding research.
Basic Usage
request=Exa::FindSimilarRequest.new(api_key: ENV['EXA_API_KEY'])response=request.submit('https://www.ruby-lang.org/en/')ifresponse.success?response.result.eachdo | result |
putsresult.titleputsresult.urlendend
Options
Options can be passed as a hash or built using the DSL:
# using DSLoptions=Exa::FindSimilarOptions.builddonum_results10exclude_source_domaintrueend# using hashoptions={num_results: 10,exclude_source_domain: true}response=request.submit(url,options)
When the request succeeds, response.result is a FindSimilarResult object.
Result Accessors
Accessor
Type
Description
request_id
string
Unique request identifier
results
array
Array of FindSimilarResultItem objects
FindSimilarResultItem Accessors
Accessor
Type
Description
id
string
Unique result identifier
url
string
The URL of the result
title
string
Page title
score
float
Similarity score
published_date
string
Publication date (ISO 8601)
author
string
Author name
text
string
Page text (if requested)
highlights
array
Highlight snippets (if requested)
highlight_scores
array
Scores for each highlight
summary
string
Summary text (if requested)
image
string
Image URL
favicon
string
Favicon URL
Examples
Find Similar Without Source Domain
Exa.api_keyENV['EXA_API_KEY']options=Exa::FindSimilarOptions.builddonum_results10exclude_source_domaintrueendresponse=Exa.find_similar('https://rubyonrails.org/',options)ifresponse.success?response.result.eachdo | result |
puts"#{result.title} - #{result.url}"endend
Find Similar with Summaries
options=Exa::FindSimilarOptions.builddonum_results5exclude_source_domaintruecontentsdosummary{query'Describe what this resource offers'}endendresponse=Exa.find_similar('https://www.ruby-lang.org/en/',options)ifresponse.success?response.result.eachdo | result |
puts"=" * 60putsresult.titleputsresult.urlputs"-" * 60putsresult.summaryputsendend