URL Fetch
Fetch the content of a URL via the /v1/tools/fetch endpoint and get the page title and body text in Markdown.
POST
/
v1
/
tools
/
fetch
URL Fetch
curl --request POST \
--url https://api.moonshot.ai/v1/tools/fetch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "<string>"
}
'import requests
url = "https://api.moonshot.ai/v1/tools/fetch"
payload = { "url": "<string>" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({url: '<string>'})
};
fetch('https://api.moonshot.ai/v1/tools/fetch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.moonshot.ai/v1/tools/fetch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'url' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.moonshot.ai/v1/tools/fetch"
payload := strings.NewReader("{\n \"url\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.moonshot.ai/v1/tools/fetch")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.ai/v1/tools/fetch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"url": "<string>",
"markdown": "<string>",
"title": "<string>"
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}Fetch the content of a URL and get the page title and body text in Markdown. Ideal for content extraction scenarios such as web reading and data curation.
Response ExampleMarkdown content exampleCommon Response Headers
All responses, including error responses, carry these two headers.
Only
http and https URLs are supported. URLs blocked by security risk control return a 403 security_risk error; pages with no extractable content return a 404 markdown_not_found error.Usage Example
Usage Example
import os
import requests
api_key = os.environ.get("MOONSHOT_API_KEY")
url = "https://api.moonshot.ai/v1/tools/fetch"
response = requests.post(
url,
headers={"Authorization": f"Bearer {api_key}"},
json={"url": "https://platform.kimi.ai/docs/api/overview"},
)
print(response.json())
curl https://api.moonshot.ai/v1/tools/fetch \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $MOONSHOT_API_KEY" \
-d '{"url": "https://platform.kimi.ai/docs/api/overview"}'
const apiKey = process.env.MOONSHOT_API_KEY;
async function main() {
const response = await fetch("https://api.moonshot.ai/v1/tools/fetch", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${apiKey}`,
},
body: JSON.stringify({
url: "https://platform.kimi.ai/docs/api/overview",
}),
});
const data = await response.json();
console.log(data);
}
main();
Response Fields
Response Fields
| Field | Type | Description |
|---|---|---|
url | string | The fetched URL |
markdown | string | Fetched content in Markdown. Text and images appear in page order; images are embedded as placeholders (see the example below), and blocks are separated by blank lines |
title | string | Page title |
{
"url": "https://platform.kimi.ai/docs/api/overview",
"markdown": "# API Overview\n\nDocumentation entry of the Kimi API open platform.",
"title": "API Overview - Kimi API Open Platform"
}
# API Overview
Documentation entry of the Kimi API open platform.

More content...
| Header | Description |
|---|---|
X-Msh-Track-Id | Request ID. If the client sends this header, its value is reused; otherwise the server generates one. Provide this ID when troubleshooting |
X-Msh-Chat-Id | Session ID, always toolgw-{X-Msh-Track-Id}; provide both IDs when troubleshooting |
Error Codes
Error Codes
| HTTP Status | error.type | Typical message | Description |
|---|---|---|---|
| 400 | invalid_request | invalid request body | The request body is not valid JSON |
| 400 | invalid_url | The provided URL is invalid: only http and https are supported | The URL is empty or uses a scheme other than http/https |
| 400 | invalid_url | The provided URL is invalid: missing host | The URL has no host |
| 401 | - | No error body | Missing or invalid API key |
| 403 | - | No error body | Account inactive or suspended |
| 403 | security_risk | We consider the current URL poses a security risk and are unable to provide fetch service at this time. | The URL was blocked by security risk control; use a different URL |
| 404 | markdown_not_found | No text/markdown content found for the current URL. | No extractable content found on the page |
| 408 | client_canceled | client canceled the request | The client disconnected before the server responded |
| 429 | rate_limited | project concurrency limit exceeded | Rate or concurrency limit exceeded; the response carries X-RateLimit-Limit and X-RateLimit-Remaining headers, plus X-RateLimit-Reset when a per-second limit is hit |
| 429 | rate_limit_unavailable | rate limit store unavailable | Rate-limit service temporarily unavailable; retry later |
| 500 | internal_error | Raw internal error text | Internal server error; retry later, and contact support with the X-Msh-Track-Id if it persists |
| 502 | upstream_failed | upstream service failed | Service temporarily unavailable; retry later |
| 504 | timeout | request timeout | The fetch timed out; retry later |
Billing: you are charged once per successful call (HTTP 200) that returns non-blank
markdown content; failed calls or pages with no extractable content are free. For pricing details, see WebSearch Pricing.Authorizations
The Authorization header expects a Bearer token. Use an MOONSHOT_API_KEY as the token. This is a server-side secret key. Generate one on the API keys page in your dashboard.
Body
application/json
URL of the page to fetch. Only http and https are supported.
Was this page helpful?
⌘I
URL Fetch
curl --request POST \
--url https://api.moonshot.ai/v1/tools/fetch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "<string>"
}
'import requests
url = "https://api.moonshot.ai/v1/tools/fetch"
payload = { "url": "<string>" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({url: '<string>'})
};
fetch('https://api.moonshot.ai/v1/tools/fetch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.moonshot.ai/v1/tools/fetch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'url' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.moonshot.ai/v1/tools/fetch"
payload := strings.NewReader("{\n \"url\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.moonshot.ai/v1/tools/fetch")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.ai/v1/tools/fetch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"url": "<string>",
"markdown": "<string>",
"title": "<string>"
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}