Skip to content

Get Contents

Shows how to retrieve page contents for specific URLs using Exa.

This example assumes using Exa; is in scope and apiKey contains your Exa API key.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
using var client = new ExaClient(apiKey);

// Retrieve the text content of specific web pages by URL.
var response = await client.GetContentsAsync(
    new AllOf<GetContentsRequest2, ContentsRequest>(
        value1: new GetContentsRequest2 { Urls = ["https://exa.ai"] },
        value2: new ContentsRequest { Text = true }));

Console.WriteLine($"Retrieved contents for {response.Results!.Count} URL(s)");

foreach (var result in response.Results)
{
    var text = result.ResultWithContentVariant2?.Text;
    Console.WriteLine($"  - {result.Result?.Url}: {text?[..Math.Min(text.Length, 100)]}...");
}