# Contents POST https://ydc-index.io/v1/contents Content-Type: application/json Returns the HTML or Markdown of a target webpage. Reference: https://docs.you.com/api-reference/search/returns-the-content-of-the-web-pages ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Returns the content of the web pages version: endpoint_.returnsTheContentOfTheWebPages paths: /v1/contents: post: operationId: returns-the-content-of-the-web-pages summary: Returns the content of the web pages description: Returns the HTML or Markdown of a target webpage. tags: - [] parameters: - name: X-API-Key in: header description: Header authentication of the form `undefined ` required: true schema: type: string responses: '200': description: >- An array of JSON objects containing the page content of each web page content: application/json: schema: type: array items: $ref: >- #/components/schemas/V1ContentsPostResponsesContentApplicationJsonSchemaItems '401': description: Unauthorized. Problems with API key. content: {} '403': description: Forbidden. API key lacks scope for this path. content: {} '500': description: >- Internal Server Error during authentication/authorization middleware. content: {} requestBody: content: application/json: schema: type: object properties: urls: type: array items: type: string format: uri description: Array of URLs to fetch the contents from. format: $ref: >- #/components/schemas/V1ContentsPostRequestBodyContentApplicationJsonSchemaFormat description: The format of the content to be returned. components: schemas: V1ContentsPostRequestBodyContentApplicationJsonSchemaFormat: type: string enum: - value: html - value: markdown V1ContentsPostResponsesContentApplicationJsonSchemaItemsMetadata: type: object properties: site_name: type: string description: The OpenGraph site name of the web page. favicon_url: type: string description: The URL of the favicon of the web page's domain. V1ContentsPostResponsesContentApplicationJsonSchemaItems: type: object properties: url: type: string format: uri description: The webpage URL whose content has been fetched. title: type: string description: The title of the web page. html: type: - string - 'null' description: The retrieved HTML content of the web page. markdown: type: - string - 'null' description: The retrieved Markdown content of the web page. metadata: $ref: >- #/components/schemas/V1ContentsPostResponsesContentApplicationJsonSchemaItemsMetadata ``` ## SDK Code Examples ```python # Use our official Python SDK to fetch the contents of a web page from youdotcom import You from youdotcom.types.typesafe_models import Format, print_contents with You("api_key") as you: res = you.contents.generate( urls=[ "https://en.wikipedia.org/wiki/Main_Page", ], format_=Format.HTML, ) print_contents(res) ``` ```typescript // Use our official TypeScript SDK to fetch the contents of a web page import { You } from "@youdotcom-oss/sdk"; import type { ContentsRequest } from "@youdotcom-oss/sdk/models/operations"; const you = new You({ apiKeyAuth: "api_key" }); const request: ContentsRequest = { urls: ["https://en.wikipedia.org/wiki/Main_Page"], format: "html", }; const result = await you.contents(request); console.log(result); ``` ```javascript // Use our official JavaScript SDK to fetch the contents of a web page import { You } from "@youdotcom-oss/sdk"; const you = new You({ apiKeyAuth: "api_key" }); const request = { urls: ["https://en.wikipedia.org/wiki/Main_Page"], format: "html", }; const result = await you.contents(request); console.log(result); ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://ydc-index.io/v1/contents" payload := strings.NewReader("{\n \"urls\": [\n \"https://en.wikipedia.org/wiki/Main_Page\"\n ],\n \"format\": \"html\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-API-Key", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```java HttpResponse response = Unirest.post("https://ydc-index.io/v1/contents") .header("X-API-Key", "") .header("Content-Type", "application/json") .body("{\n \"urls\": [\n \"https://en.wikipedia.org/wiki/Main_Page\"\n ],\n \"format\": \"html\"\n}") .asString(); ``` ```csharp var client = new RestClient("https://ydc-index.io/v1/contents"); var request = new RestRequest(Method.POST); request.AddHeader("X-API-Key", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"urls\": [\n \"https://en.wikipedia.org/wiki/Main_Page\"\n ],\n \"format\": \"html\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "X-API-Key": "", "Content-Type": "application/json" ] let parameters = [ "urls": ["https://en.wikipedia.org/wiki/Main_Page"], "format": "html" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://ydc-index.io/v1/contents")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```