UNPKG

9.41 kBMarkdownView Raw
1[//]: # "This README.md file is auto-generated, all changes to this file will be lost."
2[//]: # "To regenerate it, use `python -m synthtool`."
3<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>
4
5# [Google Cloud Vision API: Node.js Client](https://github.com/googleapis/nodejs-vision)
6
7[![release level](https://img.shields.io/badge/release%20level-general%20availability%20%28GA%29-brightgreen.svg?style=flat)](https://cloud.google.com/terms/launch-stages)
8[![npm version](https://img.shields.io/npm/v/@google-cloud/vision.svg)](https://www.npmjs.org/package/@google-cloud/vision)
9[![codecov](https://img.shields.io/codecov/c/github/googleapis/nodejs-vision/master.svg?style=flat)](https://codecov.io/gh/googleapis/nodejs-vision)
10
11
12
13
14Google Cloud Vision API client for Node.js
15
16
17A comprehensive list of changes in each version may be found in
18[the CHANGELOG](https://github.com/googleapis/nodejs-vision/blob/master/CHANGELOG.md).
19
20* [Google Cloud Vision API Node.js Client API Reference][client-docs]
21* [Google Cloud Vision API Documentation][product-docs]
22* [github.com/googleapis/nodejs-vision](https://github.com/googleapis/nodejs-vision)
23
24Read more about the client libraries for Cloud APIs, including the older
25Google APIs Client Libraries, in [Client Libraries Explained][explained].
26
27[explained]: https://cloud.google.com/apis/docs/client-libraries-explained
28
29**Table of contents:**
30
31
32* [Quickstart](#quickstart)
33 * [Before you begin](#before-you-begin)
34 * [Installing the client library](#installing-the-client-library)
35 * [Using the client library](#using-the-client-library)
36* [Samples](#samples)
37* [Versioning](#versioning)
38* [Contributing](#contributing)
39* [License](#license)
40
41## Quickstart
42
43### Before you begin
44
451. [Select or create a Cloud Platform project][projects].
461. [Enable billing for your project][billing].
471. [Enable the Google Cloud Vision API API][enable_api].
481. [Set up authentication with a service account][auth] so you can access the
49 API from your local workstation.
50
51### Installing the client library
52
53```bash
54npm install @google-cloud/vision
55```
56
57
58### Using the client library
59
60```javascript
61async function quickstart() {
62 // Imports the Google Cloud client library
63 const vision = require('@google-cloud/vision');
64
65 // Creates a client
66 const client = new vision.ImageAnnotatorClient();
67
68 // Performs label detection on the image file
69 const [result] = await client.labelDetection('./resources/wakeupcat.jpg');
70 const labels = result.labelAnnotations;
71 console.log('Labels:');
72 labels.forEach(label => console.log(label.description));
73}
74quickstart();
75
76```
77
78
79
80## Samples
81
82Samples are in the [`samples/`](https://github.com/googleapis/nodejs-vision/tree/master/samples) directory. Each sample's `README.md` has instructions for running its sample.
83
84| Sample | Source Code | Try it |
85| --------------------------- | --------------------------------- | ------ |
86| Async-batch-annotate-images | [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/async-batch-annotate-images.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/async-batch-annotate-images.js,samples/README.md) |
87| Batch-annotate-files-gcs | [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/batch-annotate-files-gcs.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/batch-annotate-files-gcs.js,samples/README.md) |
88| Batch-annotate-files | [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/batch-annotate-files.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/batch-annotate-files.js,samples/README.md) |
89| Detect | [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/detect.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/detect.js,samples/README.md) |
90| Detect.v1p1beta1 | [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/detect.v1p1beta1.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/detect.v1p1beta1.js,samples/README.md) |
91| Detect.v1p3beta1 | [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/detect.v1p3beta1.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/detect.v1p3beta1.js,samples/README.md) |
92| Face Detection | [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/faceDetection.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/faceDetection.js,samples/README.md) |
93| Cloud Vision Quickstart | [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) |
94| Cloud Vision Custom API Endpoint | [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/setEndpoint.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/setEndpoint.js,samples/README.md) |
95| Text Detection | [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/textDetection.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/textDetection.js,samples/README.md) |
96| Cloud Vision Face Detection | [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/vision-face-detection.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/vision-face-detection.js,samples/README.md) |
97
98
99
100The [Google Cloud Vision API Node.js Client API Reference][client-docs] documentation
101also contains samples.
102
103## Supported Node.js Versions
104
105Our client libraries follow the [Node.js release schedule](https://nodejs.org/en/about/releases/).
106Libraries are compatible with all current _active_ and _maintenance_ versions of
107Node.js.
108
109Client libraries targeting some end-of-life versions of Node.js are available, and
110can be installed via npm [dist-tags](https://docs.npmjs.com/cli/dist-tag).
111The dist-tags follow the naming convention `legacy-(version)`.
112
113_Legacy Node.js versions are supported as a best effort:_
114
115* Legacy versions will not be tested in continuous integration.
116* Some security patches may not be able to be backported.
117* Dependencies will not be kept up-to-date, and features will not be backported.
118
119#### Legacy tags available
120
121* `legacy-8`: install client libraries from this dist-tag for versions
122 compatible with Node.js 8.
123
124## Versioning
125
126This library follows [Semantic Versioning](http://semver.org/).
127
128
129This library is considered to be **General Availability (GA)**. This means it
130is stable; the code surface will not change in backwards-incompatible ways
131unless absolutely necessary (e.g. because of critical security issues) or with
132an extensive deprecation period. Issues and requests against **GA** libraries
133are addressed with the highest priority.
134
135
136
137
138
139More Information: [Google Cloud Platform Launch Stages][launch_stages]
140
141[launch_stages]: https://cloud.google.com/terms/launch-stages
142
143## Contributing
144
145Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/nodejs-vision/blob/master/CONTRIBUTING.md).
146
147Please note that this `README.md`, the `samples/README.md`,
148and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`)
149are generated from a central template. To edit one of these files, make an edit
150to its template in this
151[directory](https://github.com/googleapis/synthtool/tree/master/synthtool/gcp/templates/node_library).
152
153## License
154
155Apache Version 2.0
156
157See [LICENSE](https://github.com/googleapis/nodejs-vision/blob/master/LICENSE)
158
159[client-docs]: https://googleapis.dev/nodejs/vision/latest
160[product-docs]: https://cloud.google.com/vision
161[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png
162[projects]: https://console.cloud.google.com/project
163[billing]: https://support.google.com/cloud/answer/6293499#enable-billing
164[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=vision.googleapis.com
165[auth]: https://cloud.google.com/docs/authentication/getting-started