POST
/
v1
/
tools
/
web-search
cURL
curl --location --request POST https://api.writer.com/v1/tools/web-search \
 --header "Authorization: Bearer <token>" \
 --header "Content-Type: application/json" \
--data-raw '{"query":"How do I get an API key for the Writer API?","include_domains":["dev.writer.com"]}'
{
  "query": "How do I get an API key for the Writer API?",
  "answer": "To get an API key for the Writer API, you need to create one in the AI Studio. Here's how to do it:\n\n1. Go to the AI Studio home page.\n2. Click on \"API Keys\" in the navigation menu.\n \nOnce you've created your API key, you can use it to make API calls. It's recommended to set the API key as an environment variable named `WRITER_API_KEY` for easier access. \n\nFor example, you can store it in a `.env` file and then initialize the Writer client, which will automatically look for the `WRITER_API_KEY` environment variable.",
  "sources": [
    {
      "url": "https://dev.writer.com/home/sdks",
      "raw_content": null
    },
    {
      "url": "https://dev.writer.com/api-guides/api-reference/application-api/applications",
      "raw_content": null
    },
    {
      "url": "https://dev.writer.com/api-reference/api-keys",
      "raw_content": null
    },
    {
      "url": "https://dev.writer.com/home/quickstart",
      "raw_content": null
    },
    {
      "url": "https://dev.writer.com/framework/chat-assistant",
      "raw_content": null
    }
  ]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your Writer API key.

Body

application/json
query
string

The search query.

topic
enum<string>
default:general

The search topic category. Use news for current events and news articles, or general for broader web search.

Available options:
general,
news
search_depth
enum<string>
default:basic

Controls search comprehensiveness:

  • basic: Returns fewer but highly relevant results
  • advanced: Performs a deeper search with more results
Available options:
basic,
advanced
chunks_per_source
integer

Only applies when search_depth is advanced. Specifies how many text segments to extract from each source. Limited to 3 chunks maximum.

max_results
integer

Limits the number of search results returned. Cannot exceed 20 sources.

time_range
enum<string>

Filters results to content published within the specified time range back from the current date. For example, week or w returns results from the past 7 days.

Available options:
day,
week,
month,
year,
d,
w,
m,
y
days
integer

For news topic searches, specifies how many days of news coverage to include.

include_raw_content
default:false

Controls how raw content is included in search results:

  • text: Returns plain text without formatting markup
  • markdown: Returns structured content with markdown formatting (headers, links, bold text)
  • true: Same as markdown
  • false: Raw content is not included (default if unset)
Available options:
text,
markdown
include_answer
boolean
default:true

Whether to include a generated answer to the query in the response. If false, only search results are returned.

include_domains
string[]

Domains to include in the search. If unset, the search includes all domains.

exclude_domains
string[]

Domains to exclude from the search. If unset, the search includes all domains.

country
enum<string>

Localizes search results to a specific country. Only applies to general topic searches.

Available options:
afghanistan,
albania,
algeria,
andorra,
angola,
argentina,
armenia,
australia,
austria,
azerbaijan,
bahamas,
bahrain,
bangladesh,
barbados,
belarus,
belgium,
belize,
benin,
bhutan,
bolivia,
bosnia and herzegovina,
botswana,
brazil,
brunei,
bulgaria,
burkina faso,
burundi,
cambodia,
cameroon,
canada,
cape verde,
central african republic,
chad,
chile,
china,
colombia,
comoros,
congo,
costa rica,
croatia,
cuba,
cyprus,
czech republic,
denmark,
djibouti,
dominican republic,
ecuador,
egypt,
el salvador,
equatorial guinea,
eritrea,
estonia,
ethiopia,
fiji,
finland,
france,
gabon,
gambia,
georgia,
germany,
ghana,
greece,
guatemala,
guinea,
haiti,
honduras,
hungary,
iceland,
india,
indonesia,
iran,
iraq,
ireland,
israel,
italy,
jamaica,
japan,
jordan,
kazakhstan,
kenya,
kuwait,
kyrgyzstan,
latvia,
lebanon,
lesotho,
liberia,
libya,
liechtenstein,
lithuania,
luxembourg,
madagascar,
malawi,
malaysia,
maldives,
mali,
malta,
mauritania,
mauritius,
mexico,
moldova,
monaco,
mongolia,
montenegro,
morocco,
mozambique,
myanmar,
namibia,
nepal,
netherlands,
new zealand,
nicaragua,
niger,
nigeria,
north korea,
north macedonia,
norway,
oman,
pakistan,
panama,
papua new guinea,
paraguay,
peru,
philippines,
poland,
portugal,
qatar,
romania,
russia,
rwanda,
saudi arabia,
senegal,
serbia,
singapore,
slovakia,
slovenia,
somalia,
south africa,
south korea,
south sudan,
spain,
sri lanka,
sudan,
sweden,
switzerland,
syria,
taiwan,
tajikistan,
tanzania,
thailand,
togo,
trinidad and tobago,
tunisia,
turkey,
turkmenistan,
uganda,
ukraine,
united arab emirates,
united kingdom,
united states,
uruguay,
uzbekistan,
venezuela,
vietnam,
yemen,
zambia,
zimbabwe
stream
boolean
default:false

Enables streaming of search results as they become available.

Response

200 - application/json

Successful response

query
string
required

The search query that was submitted.

sources
object[]
required

The search results found.

answer
string

Generated answer based on the search results. Not included if include_answer is false.