Using Cloud Natural Language V2 in Python

I am using the Google API Discovery service to access the natural language API.

Everything works well for the natural language API v1 and v1beta2. Unfortunately if I try to use it with v2 it does not work because the API is unknown

 

UnknownApiNameOrVersion: name: language  version: v2

 

Can you share more details how to use v2 of that API. 

Thanks

0 2 123
2 REPLIES 2

Which python version you are using?

here is some documentation on v02
https://github.com/googleapis/google-api-python-client

Hi, 

I don't need v2 of the discovery API, instead I need v2 of the natural language API (https://cloud.google.com/natural-language/docs/reference/rpc/google.cloud.language.v2) and I want to use the discovery API to get it. When I list all API which are available via the discovery API it returns the language v2:

{
      "kind": "discovery#directoryItem",
      "id": "language:v2",
      "name": "language",
      "version": "v2",
      "title": "Cloud Natural Language API",
      "description": "Provides natural language understanding technologies, such as sentiment analysis, entity recognition, entity sentiment analysis, and other text annotations, to developers.",
      "discoveryRestUrl": "https://language.googleapis.com/$discovery/rest?version=v2",
      "icons": {
        "x16": "https://www.gstatic.com/images/branding/product/1x/googleg_16dp.png",
        "x32": "https://www.gstatic.com/images/branding/product/1x/googleg_32dp.png"
      },
      "documentationLink": "https://cloud.google.com/natural-language/",
      "preferred": true
    }

But when I run discovery.build('language', 'v2', credentials) it fails with the error message mentioned above. It works for 'v1' and 'v1beta2'. So for some reason v2 of that API is not available via discovery.build.