Method: documents.annotateText

A convenience method that provides all the features that analyzeSentiment, analyzeEntities, and analyzeSyntax provide in one call.

HTTP request

POST https://language.googleapis.com/v1beta1/documents:annotateText

The URL uses Google API HTTP annotation syntax.

Request body

The request body contains data with the following structure:

JSON representation
{
  "document": {
    object(Document)
  },
  "features": {
    object(Features)
  },
  "encodingType": enum(EncodingType),
}
Fields
document

object(Document)

Input document.

features

object(Features)

The enabled features.

encodingType

enum(EncodingType)

The encoding type used by the API to calculate offsets.

Response body

If successful, the response body contains data with the following structure:

The text annotations response message.

JSON representation
{
  "sentences": [
    {
      object(Sentence)
    }
  ],
  "tokens": [
    {
      object(Token)
    }
  ],
  "entities": [
    {
      object(Entity)
    }
  ],
  "documentSentiment": {
    object(Sentiment)
  },
  "language": string,
}
Fields
sentences[]

object(Sentence)

Sentences in the input document. Populated if the user enables AnnotateTextRequest.Features.extract_syntax.

tokens[]

object(Token)

Tokens, along with their syntactic information, in the input document. Populated if the user enables AnnotateTextRequest.Features.extract_syntax.

entities[]

object(Entity)

Entities, along with their semantic information, in the input document. Populated if the user enables AnnotateTextRequest.Features.extract_entities.

documentSentiment

object(Sentiment)

The overall sentiment for the document. Populated if the user enables AnnotateTextRequest.Features.extract_document_sentiment.

language

string

The language of the text, which will be the same as the language specified in the request or, if not specified, the automatically-detected language. See Document.language field for more details.

Authorization

Requires the following OAuth scope:

  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

Features

All available features for sentiment, syntax, and semantic analysis. Setting each one to true will enable that specific analysis for the input.

JSON representation
{
  "extractSyntax": boolean,
  "extractEntities": boolean,
  "extractDocumentSentiment": boolean,
}
Fields
extractSyntax

boolean

Extract syntax information.

extractEntities

boolean

Extract entities.

extractDocumentSentiment

boolean

Extract document-level sentiment.

Send feedback about...

Google Cloud Natural Language API