At any time, you can list and get any product set, product, or reference image resources you have.
Listing product sets
This section describes how to retrieve a list of all your product sets.
REST & CMD LINE
Before using any of the request data below, make the following replacements:
- project-id: Your GCP project ID.
- location-id: A valid location identifier. Valid location identifiers are:
us-west1
,us-east1
,europe-west1
, andasia-east1
.
HTTP method and URL:
GET https://vision.googleapis.com/v1/projects/project-id/locations/location-id/productSets
To send your request, choose one of these options:
curl
Execute the following command:
curl -X GET \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
https://vision.googleapis.com/v1/projects/project-id/locations/location-id/productSets
PowerShell
Execute the following command:
$cred = gcloud auth application-default print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://vision.googleapis.com/v1/projects/project-id/locations/location-id/productSets" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
C#
Go
Java
Node.js
PHP
Python
Ruby
Getting a single product set
You can get a single product set to use or modify.
REST & CMD LINE
Before using any of the request data below, make the following replacements:
- project-id: Your GCP project ID.
- location-id: A valid location identifier. Valid location identifiers are:
us-west1
,us-east1
,europe-west1
, andasia-east1
. - product-set-id: The ID for the product set you want to run the operation on.
HTTP method and URL:
GET https://vision.googleapis.com/v1/projects/project-id/locations/location-id/productSets/product-set-id
To send your request, choose one of these options:
curl
Execute the following command:
curl -X GET \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
https://vision.googleapis.com/v1/projects/project-id/locations/location-id/productSets/product-set-id
PowerShell
Execute the following command:
$cred = gcloud auth application-default print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://vision.googleapis.com/v1/projects/project-id/locations/location-id/productSets/product-set-id" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "name": "projects/project-id/locations/location-id/productSets/product-set-id", "displayName": "display-name", "indexTime": "2019-09-04T15:33:43.581861690Z", "indexError": {} }
C#
Go
Java
Node.js
PHP
Python
Ruby
Listing products
You can view all products in a Google Cloud Platform project, or in a specific product set.
Listing all products in a project
The following example shows how to list products in a project.
REST & CMD LINE
Before using any of the request data below, make the following replacements:
- project-id: Your GCP project ID.
- location-id: A valid location identifier. Valid location identifiers are:
us-west1
,us-east1
,europe-west1
, andasia-east1
.
HTTP method and URL:
GET https://vision.googleapis.com/v1/projects/project-id/locations/location-id/products
To send your request, choose one of these options:
curl
Execute the following command:
curl -X GET \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
https://vision.googleapis.com/v1/projects/project-id/locations/location-id/products
PowerShell
Execute the following command:
$cred = gcloud auth application-default print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://vision.googleapis.com/v1/projects/project-id/locations/location-id/products" | Select-Object -Expand Content
If the request is successful, the server returns a 200 OK
HTTP status code and the
response in JSON format.
You should see output similar to the following. Note that the number of products returned is
limited to 10 at a time, and a nextPageToken
is provided if there are more
pages.
If a nextPageToken
is returned, you can use the token to get
the next page of product results. Use the nextPageToken
from
the response JSON (jMGjEqhXMtN95vZz2g
in this example) as a
pageToken
query appended to the request URL:
https://vision.googleapis.com/v1/projects/project-id/locations/location-id/products?pageToken=jMGjEqhXMtN95vZz2g
C#
Go
Java
Node.js
PHP
Python
Ruby
Listing all products in a product set
The following example shows how to list products in a specific product set.
REST & CMD LINE
Before using any of the request data below, make the following replacements:
- project-id: Your GCP project ID.
- location-id: A valid location identifier. Valid location identifiers are:
us-west1
,us-east1
,europe-west1
, andasia-east1
. - product-set-id: The ID for the product set you want to run the operation on.
HTTP method and URL:
GET https://vision.googleapis.com/v1/projects/project-id/locations/location-id/productSets/product-set-id/products
To send your request, choose one of these options:
curl
Execute the following command:
curl -X GET \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
https://vision.googleapis.com/v1/projects/project-id/locations/location-id/productSets/product-set-id/products
PowerShell
Execute the following command:
$cred = gcloud auth application-default print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://vision.googleapis.com/v1/projects/project-id/locations/location-id/productSets/product-set-id/products" | Select-Object -Expand Content
If the request is successful, the server returns a 200 OK
HTTP status code and the
response in JSON format.
You should see output similar to the following. Note that the number of products returned is
limited to 10 at a time, and a nextPageToken
is provided if there are more
pages.
If a nextPageToken
is returned, you can use the token to get
the next page of product results. Use the nextPageToken
from
the response JSON (e5nEGpoVEZqlBbZRhQ
in this example) as a
pageToken
query appended to the request URL:
https://vision.googleapis.com/v1/projects/project-id/locations/location-id/products?pageToken=e5nEGpoVEZqlBbZRhQ
C#
Go
Java
Node.js
PHP
Python
Ruby
Getting a single product
You can also get a single product to use or modify.
REST & CMD LINE
Before using any of the request data below, make the following replacements:
- project-id: Your GCP project ID.
- location-id: A valid location identifier. Valid location identifiers are:
us-west1
,us-east1
,europe-west1
, andasia-east1
. - product-id: The ID for the product that is associated with a reference image. This ID is either randomly set or specified by the user at product creation time.
HTTP method and URL:
GET https://vision.googleapis.com/v1/projects/project-id/locations/location-id/products/product-id
To send your request, choose one of these options:
curl
Execute the following command:
curl -X GET \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
https://vision.googleapis.com/v1/projects/project-id/locations/location-id/products/product-id
PowerShell
Execute the following command:
$cred = gcloud auth application-default print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://vision.googleapis.com/v1/projects/project-id/locations/location-id/products/product-id" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "name": "projects/project-id/locations/location-id/products/product-id", "displayName": " ", "productCategory": "apparel-v2", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }
C#
Go
Java
Node.js
PHP
Python
Ruby
Listing reference images
A product can have multiple associated reference images. The following example describes how to obtain all reference images linked to a single product.
REST & CMD LINE
Before using any of the request data below, make the following replacements:
- project-id: Your GCP project ID.
- location-id: A valid location identifier. Valid location identifiers are:
us-west1
,us-east1
,europe-west1
, andasia-east1
. - product-id: The ID for the product that is associated with a reference image. This ID is either randomly set or specified by the user at product creation time.
HTTP method and URL:
GET https://vision.googleapis.com/v1/projects/project-id/locations/location-id/products/product-id/referenceImages
To send your request, choose one of these options:
curl
Execute the following command:
curl -X GET \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
https://vision.googleapis.com/v1/projects/project-id/locations/location-id/products/product-id/referenceImages
PowerShell
Execute the following command:
$cred = gcloud auth application-default print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://vision.googleapis.com/v1/projects/project-id/locations/location-id/products/product-id/referenceImages" | Select-Object -Expand Content
If the request is successful, the server returns a 200 OK
HTTP status code and the
response in JSON format.
You should see output similar to the following. The default number of images returned is
10 at a time, and a nextPageToken
is provided if there are more
pages.
The below response is for a product with two reference images. One of these images has associated bounding box, while the other image does not have a bounding polygon.
If the response contains a nextPageToken
, there are more results. You can
repeat the request, adding a pageToken
parameter with the value of
nextPageToken
(for example, 1LqhSgZfM_uWKOxvog
):
https://vision.googleapis.com/v1/projects/project-id/locations/location-id/products/product-id/referenceImages?pageToken=1LqhSgZfM_uWKOxvog
C#
Go
Java
Node.js
PHP
Python
Ruby
Getting a single reference image
You can also get a single reference image linked to a product.
REST & CMD LINE
Before using any of the request data below, make the following replacements:
- project-id: Your GCP project ID.
- location-id: A valid location identifier. Valid location identifiers are:
us-west1
,us-east1
,europe-west1
, andasia-east1
. - product-id: The ID for the product that is associated with a reference image. This ID is either randomly set or specified by the user at product creation time.
- image-id: The ID of the target image resource.
HTTP method and URL:
GET https://vision.googleapis.com/v1/projects/project-id/locations/location-id/products/product-id/referenceImages/image-id
To send your request, choose one of these options:
curl
Execute the following command:
curl -X GET \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
https://vision.googleapis.com/v1/projects/project-id/locations/location-id/products/product-id/referenceImages/image-id
PowerShell
Execute the following command:
$cred = gcloud auth application-default print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://vision.googleapis.com/v1/projects/project-id/locations/location-id/products/product-id/referenceImages/image-id" | Select-Object -Expand Content
If the request is successful, the server returns a 200 OK
HTTP status code and the
response in JSON format.
You should see output similar to the following. The example reference image has associated bounding boxes specified.
C#
Go
Java
Node.js
PHP
Python
Ruby