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
16
17
18
19
20
21
22
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.Value2?.Text;
    Console.WriteLine($"  - {result.Value1?.Url}: {text?[..Math.Min(text.Length, 100)]}...");
}