Retrieve page contents
Retrieves clean HTML or Markdown content from a list of URLs. Supports up to 20 URLs per request (public API limit). Specify which formats to return: html, markdown, metadata.
POST
/
web_search
/
contents
JavaScript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const response = await client.webSearch.contents({
urls: ["https://en.wikipedia.org/wiki/Artificial_intelligence"],
});
console.log(response.data);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
response = client.web_search.contents(
urls=["https://en.wikipedia.org/wiki/Artificial_intelligence"],
)
print(response.data)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.WebSearch.Contents(
context.TODO(),
telnyx.WebSearchContentsParams{
Urls: "['https://en.wikipedia.org/wiki/Artificial_intelligence']",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.webSearch.WebSearchContentsParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
WebSearchContentsParams params = WebSearchContentsParams.builder()
.urls(["https://en.wikipedia.org/wiki/Artificial_intelligence"])
.build();
var response = client.webSearch().contents(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.web_search.contents(urls: ["https://en.wikipedia.org/wiki/Artificial_intelligence"])
puts(response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$response = $client->webSearch->contents(
urls: ["https://en.wikipedia.org/wiki/Artificial_intelligence"],
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx web-search contents \
--api-key 'My API Key' \
--urls https://en.wikipedia.org/wiki/Artificial_intelligencecurl --request POST \
--url https://api.telnyx.com/v2/web_search/contents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"urls": [
"https://en.wikipedia.org/wiki/Artificial_intelligence"
],
"formats": [
"markdown",
"metadata"
],
"crawl_timeout": 10,
"max_age": null
}
'{
"data": {
"results": [
{
"url": "https://en.wikipedia.org/wiki/Artificial_intelligence",
"title": "Artificial intelligence - Wikipedia",
"markdown": "# Artificial intelligence\n\nArtificial intelligence (AI) is...",
"metadata": {
"site_name": "Wikipedia",
"favicon_url": "https://cdn.telnyx.com/favicon?domain=en.wikipedia.org&size=128"
}
}
]
}
}{
"error": {
"message": "Validation error",
"details": {}
}
}{
"errors": [
{
"code": "10009",
"title": "Authentication failed",
"detail": "Could not find any usable credentials in the request.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10009"
}
}
]
}{
"error": {
"message": "Internal server error"
}
}{
"error": {
"message": "Provider request failed"
}
}{
"error": {
"message": "Provider request timed out"
}
}Authorizations
Telnyx API key
Body
application/json
List of URLs to retrieve content from (max 20 for public API).
Required array length:
1 - 20 elementsExample:
[
"https://en.wikipedia.org/wiki/Artificial_intelligence"
]
Content formats to return. If omitted, html and metadata are returned by default. Retrieval is best-effort per URL: a format field appears only when that content could be produced, and a freshly crawled page may also include html even when not requested.
Maximum array length:
3Available options:
html, markdown, metadata Example:
["markdown", "metadata"]
Timeout for crawling each URL, in seconds (1-60).
Required range:
1 <= x <= 60Example:
10
Maximum age of cached content in seconds. null means no limit.
Required range:
x >= 0Example:
null
Response
Successful content retrieval response.
Show child attributes
Show child attributes
Was this page helpful?
⌘I
JavaScript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const response = await client.webSearch.contents({
urls: ["https://en.wikipedia.org/wiki/Artificial_intelligence"],
});
console.log(response.data);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
response = client.web_search.contents(
urls=["https://en.wikipedia.org/wiki/Artificial_intelligence"],
)
print(response.data)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.WebSearch.Contents(
context.TODO(),
telnyx.WebSearchContentsParams{
Urls: "['https://en.wikipedia.org/wiki/Artificial_intelligence']",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.webSearch.WebSearchContentsParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
WebSearchContentsParams params = WebSearchContentsParams.builder()
.urls(["https://en.wikipedia.org/wiki/Artificial_intelligence"])
.build();
var response = client.webSearch().contents(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.web_search.contents(urls: ["https://en.wikipedia.org/wiki/Artificial_intelligence"])
puts(response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$response = $client->webSearch->contents(
urls: ["https://en.wikipedia.org/wiki/Artificial_intelligence"],
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx web-search contents \
--api-key 'My API Key' \
--urls https://en.wikipedia.org/wiki/Artificial_intelligencecurl --request POST \
--url https://api.telnyx.com/v2/web_search/contents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"urls": [
"https://en.wikipedia.org/wiki/Artificial_intelligence"
],
"formats": [
"markdown",
"metadata"
],
"crawl_timeout": 10,
"max_age": null
}
'{
"data": {
"results": [
{
"url": "https://en.wikipedia.org/wiki/Artificial_intelligence",
"title": "Artificial intelligence - Wikipedia",
"markdown": "# Artificial intelligence\n\nArtificial intelligence (AI) is...",
"metadata": {
"site_name": "Wikipedia",
"favicon_url": "https://cdn.telnyx.com/favicon?domain=en.wikipedia.org&size=128"
}
}
]
}
}{
"error": {
"message": "Validation error",
"details": {}
}
}{
"errors": [
{
"code": "10009",
"title": "Authentication failed",
"detail": "Could not find any usable credentials in the request.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10009"
}
}
]
}{
"error": {
"message": "Internal server error"
}
}{
"error": {
"message": "Provider request failed"
}
}{
"error": {
"message": "Provider request timed out"
}
}