Google Cloud Natural Language API

Analyzes text to extract entities, sentiment, syntax, and content classification using Google's machine learning models.

Documentation

Specifications

Schemas & Data

Other Resources

OpenAPI Specification

openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Google Cloud Natural Language API
  description: >-
    Provides natural language understanding technologies to extract insights
    from unstructured text including sentiment, entities, and syntax.
  version: v1
  contact:
    name: Google Cloud
    url: https://cloud.google.com/natural-language
servers:
  - url: https://language.googleapis.com/v1
paths:
  /documents:analyzeSentiment:
    post:
      operationId: analyzeSentiment
      summary: Google Cloud Natural Language Analyze sentiment
      description: Analyzes the sentiment of the provided text.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnalyzeSentimentRequest'
      responses:
        '200':
          description: Successful sentiment analysis response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnalyzeSentimentResponse'
      tags:
        - documents:analyzeSentiment
  /documents:analyzeEntities:
    post:
      operationId: analyzeEntities
      summary: Google Cloud Natural Language Analyze entities
      description: Finds named entities in the provided text.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnalyzeEntitiesRequest'
      responses:
        '200':
          description: Successful entity analysis response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnalyzeEntitiesResponse'
      tags:
        - documents:analyzeEntities
  /documents:classifyText:
    post:
      operationId: classifyText
      summary: Google Cloud Natural Language Classify text
      description: Classifies the provided document into content categories.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ClassifyTextRequest'
      responses:
        '200':
          description: Successful text classification response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClassifyTextResponse'
      tags:
        - documents:classifyText
  /documents:analyzeSyntax:
    post:
      operationId: analyzeSyntax
      summary: Google Cloud Natural Language Analyze syntax
      description: Analyzes the syntax of the provided text.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnalyzeSyntaxRequest'
      responses:
        '200':
          description: Successful syntax analysis response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnalyzeSyntaxResponse'
      tags:
        - documents:analyzeSyntax
  /documents:annotateText:
    post:
      operationId: annotateText
      summary: Google Cloud Natural Language Annotate text
      description: Provides all available text analysis features in a single call.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnnotateTextRequest'
      responses:
        '200':
          description: Successful annotation response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnnotateTextResponse'
      tags:
        - documents:annotateText
components:
  schemas:
    Document:
      type: object
      properties:
        type:
          type: string
          enum:
            - TYPE_UNSPECIFIED
            - PLAIN_TEXT
            - HTML
        content:
          type: string
        gcsContentUri:
          type: string
        language:
          type: string
    Sentiment:
      type: object
      properties:
        magnitude:
          type: number
        score:
          type: number
    Entity:
      type: object
      properties:
        name:
          type: string
        type:
          type: string
          enum:
            - UNKNOWN
            - PERSON
            - LOCATION
            - ORGANIZATION
            - EVENT
            - WORK_OF_ART
            - CONSUMER_GOOD
            - OTHER
            - PHONE_NUMBER
            - ADDRESS
            - DATE
            - NUMBER
            - PRICE
        salience:
          type: number
        sentiment:
          $ref: '#/components/schemas/Sentiment'
    AnalyzeSentimentRequest:
      type: object
      required:
        - document
      properties:
        document:
          $ref: '#/components/schemas/Document'
        encodingType:
          type: string
    AnalyzeSentimentResponse:
      type: object
      properties:
        documentSentiment:
          $ref: '#/components/schemas/Sentiment'
        language:
          type: string
        sentences:
          type: array
          items:
            type: object
    AnalyzeEntitiesRequest:
      type: object
      required:
        - document
      properties:
        document:
          $ref: '#/components/schemas/Document'
        encodingType:
          type: string
    AnalyzeEntitiesResponse:
      type: object
      properties:
        entities:
          type: array
          items:
            $ref: '#/components/schemas/Entity'
        language:
          type: string
    ClassifyTextRequest:
      type: object
      required:
        - document
      properties:
        document:
          $ref: '#/components/schemas/Document'
    ClassifyTextResponse:
      type: object
      properties:
        categories:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              confidence:
                type: number
    AnalyzeSyntaxRequest:
      type: object
      required:
        - document
      properties:
        document:
          $ref: '#/components/schemas/Document'
        encodingType:
          type: string
    AnalyzeSyntaxResponse:
      type: object
      properties:
        sentences:
          type: array
          items:
            type: object
        tokens:
          type: array
          items:
            type: object
        language:
          type: string
    AnnotateTextRequest:
      type: object
      required:
        - document
        - features
      properties:
        document:
          $ref: '#/components/schemas/Document'
        features:
          type: object
          properties:
            extractSyntax:
              type: boolean
            extractEntities:
              type: boolean
            extractDocumentSentiment:
              type: boolean
            extractEntitySentiment:
              type: boolean
            classifyText:
              type: boolean
        encodingType:
          type: string
    AnnotateTextResponse:
      type: object
      properties:
        sentences:
          type: array
          items:
            type: object
        tokens:
          type: array
          items:
            type: object
        entities:
          type: array
          items:
            $ref: '#/components/schemas/Entity'
        documentSentiment:
          $ref: '#/components/schemas/Sentiment'
        language:
          type: string
        categories:
          type: array
          items:
            type: object
tags:
  - name: documents:analyzeEntities
  - name: documents:analyzeSentiment
  - name: documents:analyzeSyntax
  - name: documents:annotateText
  - name: documents:classifyText