Google Cloud Natural Language Cloud Natural Language Documents API

The Cloud Natural Language Documents API from Google Cloud Natural Language — 5 operation(s) for cloud natural language documents.

GitHub OpenAPI

Operations 5

POST /v2/documents:moderateText Moderate text documents #
POST /v2/documents:analyzeEntities Analyze entities documents #
POST /v2/documents:annotateText Annotate text documents #
POST /v2/documents:classifyText Classify text documents #
POST /v2/documents:analyzeSentiment Analyze sentiment documents #

Documentation

Specifications

Schemas & Data

Other Resources

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/google-cloud-natural-language:google-cloud-natural-language-documents-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

google-cloud-natural-language-documents-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Cloud Natural Language Documents API
  version: v2
  description: Generated from Google's published Discovery document for Cloud Natural Language API (language v2, revision 20261108). 5 operation(s).
  contact:
    name: Google
    url: https://developers.google.com/
  termsOfService: https://developers.google.com/terms
servers:
- url: https://language.googleapis.com
tags:
- name: Documents
paths:
  /v2/documents:moderateText:
    post:
      operationId: language.documents.moderateText
      summary: Moderate text documents
      description: Moderates a document for harmful and sensitive categories.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ModerateTextRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ModerateTextResponse'
        4XX:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GoogleRpcError'
          description: 'Client error (google.rpc.Status: INVALID_ARGUMENT, PERMISSION_DENIED, NOT_FOUND ...)'
        default:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GoogleRpcError'
          description: Error response (google.rpc.Status)
      security:
      - oauth2:
        - https://www.googleapis.com/auth/cloud-language
        - https://www.googleapis.com/auth/cloud-platform
      - apiKey: []
      tags:
      - Documents
  /v2/documents:analyzeEntities:
    post:
      operationId: language.documents.analyzeEntities
      summary: Analyze entities documents
      description: Finds named entities (currently proper names and common nouns) in the text along with entity types, probability, mentions for each entity, and other properties.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnalyzeEntitiesRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnalyzeEntitiesResponse'
        4XX:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GoogleRpcError'
          description: 'Client error (google.rpc.Status: INVALID_ARGUMENT, PERMISSION_DENIED, NOT_FOUND ...)'
        default:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GoogleRpcError'
          description: Error response (google.rpc.Status)
      security:
      - oauth2:
        - https://www.googleapis.com/auth/cloud-language
        - https://www.googleapis.com/auth/cloud-platform
      - apiKey: []
      tags:
      - Documents
  /v2/documents:annotateText:
    post:
      operationId: language.documents.annotateText
      summary: Annotate text documents
      description: A convenience method that provides all features in one call.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnnotateTextRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnnotateTextResponse'
        4XX:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GoogleRpcError'
          description: 'Client error (google.rpc.Status: INVALID_ARGUMENT, PERMISSION_DENIED, NOT_FOUND ...)'
        default:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GoogleRpcError'
          description: Error response (google.rpc.Status)
      security:
      - oauth2:
        - https://www.googleapis.com/auth/cloud-language
        - https://www.googleapis.com/auth/cloud-platform
      - apiKey: []
      tags:
      - Documents
  /v2/documents:classifyText:
    post:
      operationId: language.documents.classifyText
      summary: Classify text documents
      description: Classifies a document into categories.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ClassifyTextRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClassifyTextResponse'
        4XX:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GoogleRpcError'
          description: 'Client error (google.rpc.Status: INVALID_ARGUMENT, PERMISSION_DENIED, NOT_FOUND ...)'
        default:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GoogleRpcError'
          description: Error response (google.rpc.Status)
      security:
      - oauth2:
        - https://www.googleapis.com/auth/cloud-language
        - https://www.googleapis.com/auth/cloud-platform
      - apiKey: []
      tags:
      - Documents
  /v2/documents:analyzeSentiment:
    post:
      operationId: language.documents.analyzeSentiment
      summary: Analyze sentiment documents
      description: Analyzes the sentiment of the provided text.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnalyzeSentimentRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnalyzeSentimentResponse'
        4XX:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GoogleRpcError'
          description: 'Client error (google.rpc.Status: INVALID_ARGUMENT, PERMISSION_DENIED, NOT_FOUND ...)'
        default:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GoogleRpcError'
          description: Error response (google.rpc.Status)
      security:
      - oauth2:
        - https://www.googleapis.com/auth/cloud-language
        - https://www.googleapis.com/auth/cloud-platform
      - apiKey: []
      tags:
      - Documents
components:
  schemas:
    AnnotateTextRequestFeatures:
      type: object
      properties:
        extractEntities:
          description: Optional. Extract entities.
          type: boolean
        classifyText:
          description: Optional. Classify the full document into categories.
          type: boolean
        extractDocumentSentiment:
          description: Optional. Extract document-level sentiment.
          type: boolean
        moderateText:
          description: Optional. Moderate the document for harmful and sensitive categories.
          type: boolean
      description: All available features. Setting each one to true will enable that specific analysis for the input.
    AnalyzeSentimentRequest:
      properties:
        document:
          $ref: '#/components/schemas/Document'
          description: Required. Input document.
        encodingType:
          enum:
          - NONE
          - UTF8
          - UTF16
          - UTF32
          description: The encoding type used by the API to calculate sentence offsets.
          type: string
      description: The sentiment analysis request message.
      type: object
    AnnotateTextResponse:
      properties:
        categories:
          type: array
          items:
            $ref: '#/components/schemas/ClassificationCategory'
          description: Categories identified in the input document.
        sentences:
          description: Sentences in the input document. Populated if the user enables AnnotateTextRequest.Features.extract_document_sentiment.
          items:
            $ref: '#/components/schemas/Sentence'
          type: array
        languageSupported:
          type: boolean
          description: Whether the language is officially supported by all requested features. The API may still return a response when the language is not supported, but it is on a best effort basis.
        moderationCategories:
          type: array
          items:
            $ref: '#/components/schemas/ClassificationCategory'
          description: Harmful and sensitive categories identified in the input document.
        languageCode:
          type: string
          description: 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_code field for more details.
        documentSentiment:
          $ref: '#/components/schemas/Sentiment'
          description: The overall sentiment for the document. Populated if the user enables AnnotateTextRequest.Features.extract_document_sentiment.
        entities:
          description: Entities, along with their semantic information, in the input document. Populated if the user enables AnnotateTextRequest.Features.extract_entities .
          items:
            $ref: '#/components/schemas/Entity'
          type: array
      description: The text annotations response message.
      type: object
    AnalyzeEntitiesResponse:
      description: The entity analysis response message.
      type: object
      properties:
        entities:
          type: array
          items:
            $ref: '#/components/schemas/Entity'
          description: The recognized entities in the input document.
        languageCode:
          description: 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_code field for more details.
          type: string
        languageSupported:
          description: Whether the language is officially supported. The API may still return a response when the language is not supported, but it is on a best effort basis.
          type: boolean
    AnalyzeEntitiesRequest:
      properties:
        encodingType:
          type: string
          enum:
          - NONE
          - UTF8
          - UTF16
          - UTF32
          description: The encoding type used by the API to calculate offsets.
        document:
          $ref: '#/components/schemas/Document'
          description: Required. Input document.
      description: The entity analysis request message.
      type: object
    ClassifyTextResponse:
      type: object
      properties:
        categories:
          type: array
          items:
            $ref: '#/components/schemas/ClassificationCategory'
          description: Categories representing the input document.
        languageSupported:
          type: boolean
          description: Whether the language is officially supported. The API may still return a response when the language is not supported, but it is on a best effort basis.
        languageCode:
          description: 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_code field for more details.
          type: string
      description: The document classification response message.
    AnnotateTextRequest:
      description: The request message for the text annotation API, which can perform multiple analysis types in one call.
      type: object
      properties:
        features:
          $ref: '#/components/schemas/AnnotateTextRequestFeatures'
          description: Required. The enabled features.
        document:
          $ref: '#/components/schemas/Document'
          description: Required. Input document.
        encodingType:
          enum:
          - NONE
          - UTF8
          - UTF16
          - UTF32
          description: The encoding type used by the API to calculate offsets.
          type: string
    Sentiment:
      properties:
        magnitude:
          format: float
          type: number
          description: A non-negative number in the [0, +inf] range, which represents the absolute magnitude of sentiment regardless of score (positive or negative).
        score:
          format: float
          type: number
          description: Sentiment score between -1.0 (negative sentiment) and 1.0 (positive sentiment).
      description: Represents the feeling associated with the entire text or entities in the text.
      type: object
    Sentence:
      description: Represents a sentence in the input document.
      type: object
      properties:
        sentiment:
          $ref: '#/components/schemas/Sentiment'
          description: For calls to AnalyzeSentiment or if AnnotateTextRequest.Features.extract_document_sentiment is set to true, this field will contain the sentiment for the sentence.
        text:
          $ref: '#/components/schemas/TextSpan'
          description: The sentence text.
    AnalyzeSentimentResponse:
      description: The sentiment analysis response message.
      type: object
      properties:
        languageCode:
          description: 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_code field for more details.
          type: string
        documentSentiment:
          $ref: '#/components/schemas/Sentiment'
          description: The overall sentiment of the input document.
        languageSupported:
          description: Whether the language is officially supported. The API may still return a response when the language is not supported, but it is on a best effort basis.
          type: boolean
        sentences:
          description: The sentiment for all the sentences in the document.
          items:
            $ref: '#/components/schemas/Sentence'
          type: array
    Document:
      properties:
        type:
          enum:
          - TYPE_UNSPECIFIED
          - PLAIN_TEXT
          - HTML
          description: Required. If the type is not set or is `TYPE_UNSPECIFIED`, returns an `INVALID_ARGUMENT` error.
          type: string
        gcsContentUri:
          description: 'The Google Cloud Storage URI where the file content is located. This URI must be of the form: gs://bucket_name/object_name. For more details, see https://cloud.google.com/storage/docs/reference-uris. NOTE: Cloud Storage object versioning is not supported.'
          type: string
        languageCode:
          type: string
          description: Optional. The language of the document (if not specified, the language is automatically detected). Both ISO and BCP-47 language codes are accepted. [Language Support](https://cloud.google.com/natural-language/docs/languages) lists currently supported languages for each API method. If the language (either specified by the caller or automatically detected) is not supported by the called API method, an `INVALID_ARGUMENT` error is returned.
        content:
          type: string
          description: The content of the input in string format. Cloud audit logging exempt since it is based on user data.
      description: Represents the input to API methods.
      type: object
    GoogleRpcError:
      type: object
      description: The error envelope every Google API returns.
      properties:
        error:
          type: object
          properties:
            code:
              type: integer
            message:
              type: string
            status:
              type: string
            details:
              type: array
              items:
                type: object
    ModerateTextRequest:
      description: The document moderation request message.
      type: object
      properties:
        document:
          $ref: '#/components/schemas/Document'
          description: Required. Input document.
        modelVersion:
          type: string
          enum:
          - MODEL_VERSION_UNSPECIFIED
          - MODEL_VERSION_1
          - MODEL_VERSION_2
          description: Optional. The model version to use for ModerateText.
    TextSpan:
      type: object
      properties:
        content:
          description: The content of the text span, which is a substring of the document.
          type: string
        beginOffset:
          type: integer
          description: The API calculates the beginning offset of the content in the original document according to the EncodingType specified in the API request.
          format: int32
      description: Represents a text span in the input document.
    EntityMention:
      properties:
        text:
          $ref: '#/components/schemas/TextSpan'
          description: The mention text.
        sentiment:
          $ref: '#/components/schemas/Sentiment'
          description: For calls to AnalyzeEntitySentiment this field will contain the sentiment expressed for this mention of the entity in the provided document.
        type:
          type: string
          description: The type of the entity mention.
          enum:
          - TYPE_UNKNOWN
          - PROPER
          - COMMON
        probability:
          format: float
          description: Probability score associated with the entity. The score shows the probability of the entity mention being the entity type. The score is in (0, 1] range.
          type: number
      type: object
      description: Represents a mention for an entity in the text. Currently, proper noun mentions are supported.
    ClassificationCategory:
      type: object
      description: Represents a category returned from the text classifier.
      properties:
        confidence:
          description: The classifier's confidence of the category. Number represents how certain the classifier is that this category represents the given text.
          format: float
          type: number
        name:
          description: The name of the category representing the document.
          type: string
        severity:
          type: number
          description: Optional. The classifier's severity of the category. This is only present when the ModerateTextRequest.ModelVersion is set to MODEL_VERSION_2, and the corresponding category has a severity score.
          format: float
    Entity:
      description: Represents a phrase in the text that is a known entity, such as a person, an organization, or location. The API associates information, such as probability and mentions, with entities.
      properties:
        type:
          type: string
          description: The entity type.
          enum:
          - UNKNOWN
          - PERSON
          - LOCATION
          - ORGANIZATION
          - EVENT
          - WORK_OF_ART
          - CONSUMER_GOOD
          - OTHER
          - PHONE_NUMBER
          - ADDRESS
          - DATE
          - NUMBER
          - PRICE
        mentions:
          description: The mentions of this entity in the input document. The API currently supports proper noun mentions.
          items:
            $ref: '#/components/schemas/EntityMention'
          type: array
        name:
          description: The representative name for the entity.
          type: string
        sentiment:
          $ref: '#/components/schemas/Sentiment'
          description: For calls to AnalyzeEntitySentiment this field will contain the aggregate sentiment expressed for this entity in the provided document.
        metadata:
          description: Metadata associated with the entity. For the metadata associated with other entity types, see the Type table below.
          additionalProperties:
            type: string
          type: object
      type: object
    ClassifyTextRequest:
      type: object
      description: The document classification request message.
      properties:
        document:
          $ref: '#/components/schemas/Document'
          description: Required. Input document.
    ModerateTextResponse:
      type: object
      properties:
        moderationCategories:
          description: Harmful and sensitive categories representing the input document.
          type: array
          items:
            $ref: '#/components/schemas/ClassificationCategory'
        languageCode:
          description: 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_code field for more details.
          type: string
        languageSupported:
          description: Whether the language is officially supported. The API may still return a response when the language is not supported, but it is on a best effort basis.
          type: boolean
      description: The document moderation response message.
  securitySchemes:
    apiKey:
      type: apiKey
      in: query
      name: key
      description: API key; accepted by methods that do not need user data.
    oauth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://accounts.google.com/o/oauth2/auth
          tokenUrl: https://oauth2.googleapis.com/token
          scopes:
            https://www.googleapis.com/auth/cloud-language: Apply machine learning models to reveal the structure and meaning of text
            https://www.googleapis.com/auth/cloud-platform: See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
externalDocs:
  url: https://cloud.google.com/natural-language/
x-provenance:
  method: harvested
  publisher: Google
  source: https://language.googleapis.com/$discovery/rest?version=v2
  note: converted by discovery-to-openapi.py from Google's Discovery document (revision 20261108)