UNPKG

6.18 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-beta-yellow.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
17* [Google Cloud Vision API Node.js Client API Reference][client-docs]
18* [Google Cloud Vision API Documentation][product-docs]
19* [github.com/googleapis/nodejs-vision](https://github.com/googleapis/nodejs-vision)
20
21Read more about the client libraries for Cloud APIs, including the older
22Google APIs Client Libraries, in [Client Libraries Explained][explained].
23
24[explained]: https://cloud.google.com/apis/docs/client-libraries-explained
25
26**Table of contents:**
27
28
29* [Quickstart](#quickstart)
30 * [Before you begin](#before-you-begin)
31 * [Installing the client library](#installing-the-client-library)
32 * [Using the client library](#using-the-client-library)
33* [Samples](#samples)
34* [Versioning](#versioning)
35* [Contributing](#contributing)
36* [License](#license)
37
38## Quickstart
39
40### Before you begin
41
421. [Select or create a Cloud Platform project][projects].
431. [Enable billing for your project][billing].
441. [Enable the Google Cloud Vision API API][enable_api].
451. [Set up authentication with a service account][auth] so you can access the
46 API from your local workstation.
47
48### Installing the client library
49
50```bash
51npm install @google-cloud/vision
52```
53
54
55### Using the client library
56
57```javascript
58async function quickstart() {
59 // Imports the Google Cloud client library
60 const vision = require('@google-cloud/vision');
61
62 // Creates a client
63 const client = new vision.ImageAnnotatorClient();
64
65 // Performs label detection on the image file
66 const [result] = await client.labelDetection('./resources/wakeupcat.jpg');
67 const labels = result.labelAnnotations;
68 console.log('Labels:');
69 labels.forEach(label => console.log(label.description));
70}
71
72```
73
74
75
76## Samples
77
78Samples are in the [`samples/`](https://github.com/googleapis/nodejs-vision/tree/master/samples) directory. The samples' `README.md`
79has instructions for running the samples.
80
81| Sample | Source Code | Try it |
82| --------------------------- | --------------------------------- | ------ |
83| 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) |
84| 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) |
85| 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) |
86| 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) |
87| 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) |
88| 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) |
89
90
91
92The [Google Cloud Vision API Node.js Client API Reference][client-docs] documentation
93also contains samples.
94
95## Versioning
96
97This library follows [Semantic Versioning](http://semver.org/).
98
99
100
101This library is considered to be in **beta**. This means it is expected to be
102mostly stable while we work toward a general availability release; however,
103complete stability is not guaranteed. We will address issues and requests
104against beta libraries with a high priority.
105
106
107
108
109More Information: [Google Cloud Platform Launch Stages][launch_stages]
110
111[launch_stages]: https://cloud.google.com/terms/launch-stages
112
113## Contributing
114
115Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/nodejs-vision/blob/master/CONTRIBUTING.md).
116
117## License
118
119Apache Version 2.0
120
121See [LICENSE](https://github.com/googleapis/nodejs-vision/blob/master/LICENSE)
122
123[client-docs]: https://googleapis.dev/nodejs/vision/latest#reference
124[product-docs]: https://cloud.google.com/vision
125[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png
126[projects]: https://console.cloud.google.com/project
127[billing]: https://support.google.com/cloud/answer/6293499#enable-billing
128[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=vision.googleapis.com
129[auth]: https://cloud.google.com/docs/authentication/getting-started
130
131<a name="reference"></a>