API Reference¶
A library for Vuforia Web Services.
- class vws.VWS(*, server_access_key: str, server_secret_key: str, base_vws_url: str = 'https://vws.vuforia.com', request_timeout_seconds: float | tuple[float, float] = 30.0, transport: Transport | None = None)¶
An interface to Vuforia Web Services APIs.
- Parameters:
server_access_key – A VWS server access key.
server_secret_key – A VWS server secret key.
base_vws_url – The base URL for the VWS API.
request_timeout_seconds – The timeout for each HTTP request. This can be a float to set both the connect and read timeouts, or a (connect, read) tuple.
transport – The HTTP transport to use for requests. Defaults to
RequestsTransport().
- make_request(*, method: str, data: bytes, request_path: str, expected_result_code: str, content_type: str, extra_headers: dict[str, str] | None = None) Response¶
Make a request to the Vuforia Target API.
- Parameters:
method – The HTTP method which will be used in the request.
data – The request body which will be used in the request.
request_path – The path to the endpoint which will be used in the request.
expected_result_code – See “VWS API Result Codes” on https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api.
content_type – The content type of the request.
extra_headers – Additional headers to include in the request.
- Returns:
The response to the request.
- Raises:
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
json.JSONDecodeError – The server did not respond with valid JSON. This may happen if the server address is not a valid Vuforia server.
- add_target(*, name: str, width: float, image: BytesIO | BinaryIO, application_metadata: str | None, active_flag: bool) str¶
Add a target to a Vuforia Web Services database.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#add for parameter details.
- Parameters:
name – The name of the target.
width – The width of the target.
image – The image of the target.
active_flag – Whether or not the target is active for query.
application_metadata –
The application metadata of the target. This must be base64 encoded, for example by using:
base64.b64encode('input_string').decode('ascii')
- Returns:
The target ID of the new target.
- Raises:
AuthenticationFailureError – The secret key is not correct.
BadImageError – There is a problem with the given image. For example, it must be a JPEG or PNG file in the grayscale or RGB color space.
FailError – There was an error with the request. For example, the given access key does not match a known database.
MetadataTooLargeError – The given metadata is too large. The maximum size is 1 MB of data when Base64 encoded.
ImageTooLargeError – The given image is too large.
TargetNameExistError – A target with the given
namealready exists.ProjectInactiveError – The project is inactive.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers. This has been seen to happen when the given name includes a bad character.
TooManyRequestsError – Vuforia is rate limiting access.
- get_target_record(target_id: str) TargetStatusAndRecord¶
Get a given target’s target record from the Target Management System.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#target-record.
- Parameters:
target_id – The ID of the target to get details of.
- Returns:
Response details of a target from Vuforia.
- Raises:
AuthenticationFailureError – The secret key is not correct.
FailError – There was an error with the request. For example, the given access key does not match a known database.
UnknownTargetError – The given target ID does not match a target in the database.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
- wait_for_target_processed(*, target_id: str, seconds_between_requests: float = 0.2, timeout_seconds: float = 300) None¶
Wait up to five minutes (arbitrary) for a target to get past the processing stage.
- Parameters:
target_id – The ID of the target to wait for.
seconds_between_requests – The number of seconds to wait between requests made while polling the target status. We wait 0.2 seconds by default, rather than less, than that to decrease the number of calls made to the API, to decrease the likelihood of hitting the request quota.
timeout_seconds – The maximum number of seconds to wait for the target to be processed.
- Raises:
AuthenticationFailureError – The secret key is not correct.
FailError – There was an error with the request. For example, the given access key does not match a known database.
TargetProcessingTimeoutError – The target remained in the processing stage for more than
timeout_secondsseconds.UnknownTargetError – The given target ID does not match a target in the database.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
- list_targets() list[str]¶
List target IDs.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#details-list.
- Returns:
The IDs of all targets in the database.
- Raises:
AuthenticationFailureError – The secret key is not correct.
FailError – There was an error with the request. For example, the given access key does not match a known database.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
- get_target_summary_report(target_id: str) TargetSummaryReport¶
Get a summary report for a target.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#summary-report.
- Parameters:
target_id – The ID of the target to get a summary report for.
- Returns:
Details of the target.
- Raises:
AuthenticationFailureError – The secret key is not correct.
FailError – There was an error with the request. For example, the given access key does not match a known database.
UnknownTargetError – The given target ID does not match a target in the database.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
- get_database_summary_report() DatabaseSummaryReport¶
Get a summary report for the database.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#summary-report.
- Returns:
Details of the database.
- Raises:
AuthenticationFailureError – The secret key is not correct.
FailError – There was an error with the request. For example, the given access key does not match a known database.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
- delete_target(target_id: str) None¶
Delete a given target.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#delete.
- Parameters:
target_id – The ID of the target to delete.
- Raises:
AuthenticationFailureError – The secret key is not correct.
FailError – There was an error with the request. For example, the given access key does not match a known database.
UnknownTargetError – The given target ID does not match a target in the database.
TargetStatusProcessingError – The given target is in the processing state.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
- get_duplicate_targets(target_id: str) list[str]¶
Get targets which may be considered duplicates of a given target.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#check.
- Parameters:
target_id – The ID of the target to delete.
- Returns:
The target IDs of duplicate targets.
- Raises:
AuthenticationFailureError – The secret key is not correct.
FailError – There was an error with the request. For example, the given access key does not match a known database.
UnknownTargetError – The given target ID does not match a target in the database.
ProjectInactiveError – The project is inactive.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
- update_target(*, target_id: str, name: str | None = None, width: float | None = None, image: BytesIO | BinaryIO | None = None, active_flag: bool | None = None, application_metadata: str | None = None) None¶
Update a target in a Vuforia Web Services database.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#update for parameter details.
- Parameters:
target_id – The ID of the target to update.
name – The name of the target.
width – The width of the target.
image – The image of the target.
active_flag – Whether or not the target is active for query.
application_metadata –
The application metadata of the target. This must be base64 encoded, for example by using:
base64.b64encode('input_string').decode('ascii')
Giving
Nonewill not change the application metadata.
- Raises:
AuthenticationFailureError – The secret key is not correct.
BadImageError – There is a problem with the given image. For example, it must be a JPEG or PNG file in the grayscale or RGB color space.
FailError – There was an error with the request. For example, the given access key does not match a known database.
MetadataTooLargeError – The given metadata is too large. The maximum size is 1 MB of data when Base64 encoded.
ImageTooLargeError – The given image is too large.
TargetNameExistError – A target with the given
namealready exists.ProjectInactiveError – The project is inactive.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
- class vws.AsyncCloudRecoService(*, client_access_key: str, client_secret_key: str, base_vwq_url: str = 'https://cloudreco.vuforia.com', request_timeout_seconds: float | tuple[float, float] = 30.0, transport: AsyncTransport | None = None)¶
An async interface to the Vuforia Cloud Recognition Web APIs.
- Parameters:
client_access_key – A VWS client access key.
client_secret_key – A VWS client secret key.
base_vwq_url – The base URL for the VWQ API.
request_timeout_seconds – The timeout for each HTTP request. This can be a float to set both the connect and read timeouts, or a (connect, read) tuple.
transport – The async HTTP transport to use for requests. Defaults to
AsyncHTTPXTransport().
- async query(*, image: BytesIO | BinaryIO, max_num_results: int = 1, include_target_data: CloudRecoIncludeTargetData = CloudRecoIncludeTargetData.TOP) list[QueryResult]¶
Use the Vuforia Web Query API to make an Image Recognition Query.
See https://developer.vuforia.com/library/web-api/vuforia-query-web-api for parameter details.
- Parameters:
image – The image to make a query against.
max_num_results – The maximum number of matching targets to be returned.
include_target_data – Indicates if target_data records shall be returned for the matched targets. Accepted values are top (default value, only return target_data for top ranked match), none (return no target_data), all (for all matched targets).
- Raises:
AuthenticationFailureError – The client access key pair is not correct.
MaxNumResultsOutOfRangeError –
max_num_resultsis not within the range (1, 50).InactiveProjectError – The project is inactive.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
BadImageError – There is a problem with the given image. For example, it must be a JPEG or PNG file in the grayscale or RGB color space.
RequestEntityTooLargeError – The given image is too large.
ServerError – There is an error with Vuforia’s servers.
- Returns:
An ordered list of target details of matching targets.
- class vws.AsyncVWS(*, server_access_key: str, server_secret_key: str, base_vws_url: str = 'https://vws.vuforia.com', request_timeout_seconds: float | tuple[float, float] = 30.0, transport: AsyncTransport | None = None)¶
An async interface to Vuforia Web Services APIs.
- Parameters:
server_access_key – A VWS server access key.
server_secret_key – A VWS server secret key.
base_vws_url – The base URL for the VWS API.
request_timeout_seconds – The timeout for each HTTP request. This can be a float to set both the connect and read timeouts, or a (connect, read) tuple.
transport – The async HTTP transport to use for requests. Defaults to
AsyncHTTPXTransport().
- async make_request(*, method: str, data: bytes, request_path: str, expected_result_code: str, content_type: str, extra_headers: dict[str, str] | None = None) Response¶
Make an async request to the Vuforia Target API.
- Parameters:
method – The HTTP method which will be used in the request.
data – The request body which will be used in the request.
request_path – The path to the endpoint which will be used in the request.
expected_result_code – See “VWS API Result Codes” on https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api.
content_type – The content type of the request.
extra_headers – Additional headers to include in the request.
- Returns:
The response to the request.
- Raises:
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
json.JSONDecodeError – The server did not respond with valid JSON. This may happen if the server address is not a valid Vuforia server.
- async add_target(*, name: str, width: float, image: BytesIO | BinaryIO, application_metadata: str | None, active_flag: bool) str¶
Add a target to a Vuforia Web Services database.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#add for parameter details.
- Parameters:
name – The name of the target.
width – The width of the target.
image – The image of the target.
active_flag – Whether or not the target is active for query.
application_metadata –
The application metadata of the target. This must be base64 encoded, for example by using:
base64.b64encode('input_string').decode('ascii')
- Returns:
The target ID of the new target.
- Raises:
AuthenticationFailureError – The secret key is not correct.
BadImageError – There is a problem with the given image. For example, it must be a JPEG or PNG file in the grayscale or RGB color space.
FailError – There was an error with the request. For example, the given access key does not match a known database.
MetadataTooLargeError – The given metadata is too large. The maximum size is 1 MB of data when Base64 encoded.
ImageTooLargeError – The given image is too large.
TargetNameExistError – A target with the given
namealready exists.ProjectInactiveError – The project is inactive.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers. This has been seen to happen when the given name includes a bad character.
TooManyRequestsError – Vuforia is rate limiting access.
- async get_target_record(target_id: str) TargetStatusAndRecord¶
Get a given target’s target record from the Target Management System.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#target-record.
- Parameters:
target_id – The ID of the target to get details of.
- Returns:
Response details of a target from Vuforia.
- Raises:
AuthenticationFailureError – The secret key is not correct.
FailError – There was an error with the request. For example, the given access key does not match a known database.
UnknownTargetError – The given target ID does not match a target in the database.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
- async wait_for_target_processed(*, target_id: str, seconds_between_requests: float = 0.2, timeout_seconds: float = 300) None¶
Wait up to five minutes (arbitrary) for a target to get past the processing stage.
- Parameters:
target_id – The ID of the target to wait for.
seconds_between_requests – The number of seconds to wait between requests made while polling the target status. We wait 0.2 seconds by default, rather than less, than that to decrease the number of calls made to the API, to decrease the likelihood of hitting the request quota.
timeout_seconds – The maximum number of seconds to wait for the target to be processed.
- Raises:
AuthenticationFailureError – The secret key is not correct.
FailError – There was an error with the request. For example, the given access key does not match a known database.
TargetProcessingTimeoutError – The target remained in the processing stage for more than
timeout_secondsseconds.UnknownTargetError – The given target ID does not match a target in the database.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
- async list_targets() list[str]¶
List target IDs.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#details-list.
- Returns:
The IDs of all targets in the database.
- Raises:
AuthenticationFailureError – The secret key is not correct.
FailError – There was an error with the request. For example, the given access key does not match a known database.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
- async get_target_summary_report(target_id: str) TargetSummaryReport¶
Get a summary report for a target.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#summary-report.
- Parameters:
target_id – The ID of the target to get a summary report for.
- Returns:
Details of the target.
- Raises:
AuthenticationFailureError – The secret key is not correct.
FailError – There was an error with the request. For example, the given access key does not match a known database.
UnknownTargetError – The given target ID does not match a target in the database.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
- async get_database_summary_report() DatabaseSummaryReport¶
Get a summary report for the database.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#summary-report.
- Returns:
Details of the database.
- Raises:
AuthenticationFailureError – The secret key is not correct.
FailError – There was an error with the request. For example, the given access key does not match a known database.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
- async delete_target(target_id: str) None¶
Delete a given target.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#delete.
- Parameters:
target_id – The ID of the target to delete.
- Raises:
AuthenticationFailureError – The secret key is not correct.
FailError – There was an error with the request. For example, the given access key does not match a known database.
UnknownTargetError – The given target ID does not match a target in the database.
TargetStatusProcessingError – The given target is in the processing state.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
- async get_duplicate_targets(target_id: str) list[str]¶
Get targets which may be considered duplicates of a given target.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#check.
- Parameters:
target_id – The ID of the target to delete.
- Returns:
The target IDs of duplicate targets.
- Raises:
AuthenticationFailureError – The secret key is not correct.
FailError – There was an error with the request. For example, the given access key does not match a known database.
UnknownTargetError – The given target ID does not match a target in the database.
ProjectInactiveError – The project is inactive.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
- async update_target(*, target_id: str, name: str | None = None, width: float | None = None, image: BytesIO | BinaryIO | None = None, active_flag: bool | None = None, application_metadata: str | None = None) None¶
Update a target in a Vuforia Web Services database.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#update for parameter details.
- Parameters:
target_id – The ID of the target to update.
name – The name of the target.
width – The width of the target.
image – The image of the target.
active_flag – Whether or not the target is active for query.
application_metadata –
The application metadata of the target. This must be base64 encoded, for example by using:
base64.b64encode('input_string').decode('ascii')
Giving
Nonewill not change the application metadata.
- Raises:
AuthenticationFailureError – The secret key is not correct.
BadImageError – There is a problem with the given image. For example, it must be a JPEG or PNG file in the grayscale or RGB color space.
FailError – There was an error with the request. For example, the given access key does not match a known database.
MetadataTooLargeError – The given metadata is too large. The maximum size is 1 MB of data when Base64 encoded.
ImageTooLargeError – The given image is too large.
TargetNameExistError – A target with the given
namealready exists.ProjectInactiveError – The project is inactive.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
- class vws.AsyncVuMarkService(*, server_access_key: str, server_secret_key: str, base_vws_url: str = 'https://vws.vuforia.com', request_timeout_seconds: float | tuple[float, float] = 30.0, transport: AsyncTransport | None = None)¶
An async interface to the Vuforia VuMark Generation Web API.
- Parameters:
server_access_key – A VWS server access key.
server_secret_key – A VWS server secret key.
base_vws_url – The base URL for the VWS API.
request_timeout_seconds – The timeout for each HTTP request. This can be a float to set both the connect and read timeouts, or a (connect, read) tuple.
transport – The async HTTP transport to use for requests. Defaults to
AsyncHTTPXTransport().
- async generate_vumark_instance(*, target_id: str, instance_id: str, accept: VuMarkAccept) bytes¶
Generate a VuMark instance image.
See https://developer.vuforia.com/library/vuforia-engine/web-api/vumark-generation-web-api/ for parameter details.
- Parameters:
target_id – The ID of the VuMark target.
instance_id – The instance ID to encode in the VuMark.
accept – The image format to return.
- Returns:
The VuMark instance image bytes.
- Raises:
AuthenticationFailureError – The secret key is not correct.
FailError – There was an error with the request. For example, the given access key does not match a known database.
InvalidAcceptHeaderError – The Accept header value is not supported.
InvalidInstanceIdError – The instance ID is invalid. For example, it may be empty.
InvalidTargetTypeError – The target is not a VuMark template target.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
TargetStatusNotSuccessError – The target is not in the success state.
UnknownTargetError – The given target ID does not match a target in the database.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
- class vws.CloudRecoService(*, client_access_key: str, client_secret_key: str, base_vwq_url: str = 'https://cloudreco.vuforia.com', request_timeout_seconds: float | tuple[float, float] = 30.0, transport: Transport | None = None)¶
An interface to the Vuforia Cloud Recognition Web APIs.
- Parameters:
client_access_key – A VWS client access key.
client_secret_key – A VWS client secret key.
base_vwq_url – The base URL for the VWQ API.
request_timeout_seconds – The timeout for each HTTP request. This can be a float to set both the connect and read timeouts, or a (connect, read) tuple.
transport – The HTTP transport to use for requests. Defaults to
RequestsTransport().
- query(*, image: BytesIO | BinaryIO, max_num_results: int = 1, include_target_data: CloudRecoIncludeTargetData = CloudRecoIncludeTargetData.TOP) list[QueryResult]¶
Use the Vuforia Web Query API to make an Image Recognition Query.
See https://developer.vuforia.com/library/web-api/vuforia-query-web-api for parameter details.
- Parameters:
image – The image to make a query against.
max_num_results – The maximum number of matching targets to be returned.
include_target_data – Indicates if target_data records shall be returned for the matched targets. Accepted values are top (default value, only return target_data for top ranked match), none (return no target_data), all (for all matched targets).
- Raises:
AuthenticationFailureError – The client access key pair is not correct.
MaxNumResultsOutOfRangeError –
max_num_resultsis not within the range (1, 50).InactiveProjectError – The project is inactive.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
BadImageError – There is a problem with the given image. For example, it must be a JPEG or PNG file in the grayscale or RGB color space.
RequestEntityTooLargeError – The given image is too large.
ServerError – There is an error with Vuforia’s servers.
- Returns:
An ordered list of target details of matching targets.
- class vws.VuMarkService(*, server_access_key: str, server_secret_key: str, base_vws_url: str = 'https://vws.vuforia.com', request_timeout_seconds: float | tuple[float, float] = 30.0, transport: Transport | None = None)¶
An interface to the Vuforia VuMark Generation Web API.
- Parameters:
server_access_key – A VWS server access key.
server_secret_key – A VWS server secret key.
base_vws_url – The base URL for the VWS API.
request_timeout_seconds – The timeout for each HTTP request. This can be a float to set both the connect and read timeouts, or a (connect, read) tuple.
transport – The HTTP transport to use for requests. Defaults to
RequestsTransport().
- generate_vumark_instance(*, target_id: str, instance_id: str, accept: VuMarkAccept) bytes¶
Generate a VuMark instance image.
See https://developer.vuforia.com/library/vuforia-engine/web-api/vumark-generation-web-api/ for parameter details.
- Parameters:
target_id – The ID of the VuMark target.
instance_id – The instance ID to encode in the VuMark.
accept – The image format to return.
- Returns:
The VuMark instance image bytes.
- Raises:
AuthenticationFailureError – The secret key is not correct.
FailError – There was an error with the request. For example, the given access key does not match a known database.
InvalidAcceptHeaderError – The Accept header value is not supported.
InvalidInstanceIdError – The instance ID is invalid. For example, it may be empty.
InvalidTargetTypeError – The target is not a VuMark template target.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
TargetStatusNotSuccessError – The target is not in the success state.
UnknownTargetError – The given target ID does not match a target in the database.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
Async tools for interacting with Vuforia APIs.
- class vws.async_vws.AsyncVWS(*, server_access_key: str, server_secret_key: str, base_vws_url: str = 'https://vws.vuforia.com', request_timeout_seconds: float | tuple[float, float] = 30.0, transport: AsyncTransport | None = None)¶
An async interface to Vuforia Web Services APIs.
- Parameters:
server_access_key – A VWS server access key.
server_secret_key – A VWS server secret key.
base_vws_url – The base URL for the VWS API.
request_timeout_seconds – The timeout for each HTTP request. This can be a float to set both the connect and read timeouts, or a (connect, read) tuple.
transport – The async HTTP transport to use for requests. Defaults to
AsyncHTTPXTransport().
- async make_request(*, method: str, data: bytes, request_path: str, expected_result_code: str, content_type: str, extra_headers: dict[str, str] | None = None) Response¶
Make an async request to the Vuforia Target API.
- Parameters:
method – The HTTP method which will be used in the request.
data – The request body which will be used in the request.
request_path – The path to the endpoint which will be used in the request.
expected_result_code – See “VWS API Result Codes” on https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api.
content_type – The content type of the request.
extra_headers – Additional headers to include in the request.
- Returns:
The response to the request.
- Raises:
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
json.JSONDecodeError – The server did not respond with valid JSON. This may happen if the server address is not a valid Vuforia server.
- async add_target(*, name: str, width: float, image: BytesIO | BinaryIO, application_metadata: str | None, active_flag: bool) str¶
Add a target to a Vuforia Web Services database.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#add for parameter details.
- Parameters:
name – The name of the target.
width – The width of the target.
image – The image of the target.
active_flag – Whether or not the target is active for query.
application_metadata –
The application metadata of the target. This must be base64 encoded, for example by using:
base64.b64encode('input_string').decode('ascii')
- Returns:
The target ID of the new target.
- Raises:
AuthenticationFailureError – The secret key is not correct.
BadImageError – There is a problem with the given image. For example, it must be a JPEG or PNG file in the grayscale or RGB color space.
FailError – There was an error with the request. For example, the given access key does not match a known database.
MetadataTooLargeError – The given metadata is too large. The maximum size is 1 MB of data when Base64 encoded.
ImageTooLargeError – The given image is too large.
TargetNameExistError – A target with the given
namealready exists.ProjectInactiveError – The project is inactive.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers. This has been seen to happen when the given name includes a bad character.
TooManyRequestsError – Vuforia is rate limiting access.
- async get_target_record(target_id: str) TargetStatusAndRecord¶
Get a given target’s target record from the Target Management System.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#target-record.
- Parameters:
target_id – The ID of the target to get details of.
- Returns:
Response details of a target from Vuforia.
- Raises:
AuthenticationFailureError – The secret key is not correct.
FailError – There was an error with the request. For example, the given access key does not match a known database.
UnknownTargetError – The given target ID does not match a target in the database.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
- async wait_for_target_processed(*, target_id: str, seconds_between_requests: float = 0.2, timeout_seconds: float = 300) None¶
Wait up to five minutes (arbitrary) for a target to get past the processing stage.
- Parameters:
target_id – The ID of the target to wait for.
seconds_between_requests – The number of seconds to wait between requests made while polling the target status. We wait 0.2 seconds by default, rather than less, than that to decrease the number of calls made to the API, to decrease the likelihood of hitting the request quota.
timeout_seconds – The maximum number of seconds to wait for the target to be processed.
- Raises:
AuthenticationFailureError – The secret key is not correct.
FailError – There was an error with the request. For example, the given access key does not match a known database.
TargetProcessingTimeoutError – The target remained in the processing stage for more than
timeout_secondsseconds.UnknownTargetError – The given target ID does not match a target in the database.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
- async list_targets() list[str]¶
List target IDs.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#details-list.
- Returns:
The IDs of all targets in the database.
- Raises:
AuthenticationFailureError – The secret key is not correct.
FailError – There was an error with the request. For example, the given access key does not match a known database.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
- async get_target_summary_report(target_id: str) TargetSummaryReport¶
Get a summary report for a target.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#summary-report.
- Parameters:
target_id – The ID of the target to get a summary report for.
- Returns:
Details of the target.
- Raises:
AuthenticationFailureError – The secret key is not correct.
FailError – There was an error with the request. For example, the given access key does not match a known database.
UnknownTargetError – The given target ID does not match a target in the database.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
- async get_database_summary_report() DatabaseSummaryReport¶
Get a summary report for the database.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#summary-report.
- Returns:
Details of the database.
- Raises:
AuthenticationFailureError – The secret key is not correct.
FailError – There was an error with the request. For example, the given access key does not match a known database.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
- async delete_target(target_id: str) None¶
Delete a given target.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#delete.
- Parameters:
target_id – The ID of the target to delete.
- Raises:
AuthenticationFailureError – The secret key is not correct.
FailError – There was an error with the request. For example, the given access key does not match a known database.
UnknownTargetError – The given target ID does not match a target in the database.
TargetStatusProcessingError – The given target is in the processing state.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
- async get_duplicate_targets(target_id: str) list[str]¶
Get targets which may be considered duplicates of a given target.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#check.
- Parameters:
target_id – The ID of the target to delete.
- Returns:
The target IDs of duplicate targets.
- Raises:
AuthenticationFailureError – The secret key is not correct.
FailError – There was an error with the request. For example, the given access key does not match a known database.
UnknownTargetError – The given target ID does not match a target in the database.
ProjectInactiveError – The project is inactive.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
- async update_target(*, target_id: str, name: str | None = None, width: float | None = None, image: BytesIO | BinaryIO | None = None, active_flag: bool | None = None, application_metadata: str | None = None) None¶
Update a target in a Vuforia Web Services database.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#update for parameter details.
- Parameters:
target_id – The ID of the target to update.
name – The name of the target.
width – The width of the target.
image – The image of the target.
active_flag – Whether or not the target is active for query.
application_metadata –
The application metadata of the target. This must be base64 encoded, for example by using:
base64.b64encode('input_string').decode('ascii')
Giving
Nonewill not change the application metadata.
- Raises:
AuthenticationFailureError – The secret key is not correct.
BadImageError – There is a problem with the given image. For example, it must be a JPEG or PNG file in the grayscale or RGB color space.
FailError – There was an error with the request. For example, the given access key does not match a known database.
MetadataTooLargeError – The given metadata is too large. The maximum size is 1 MB of data when Base64 encoded.
ImageTooLargeError – The given image is too large.
TargetNameExistError – A target with the given
namealready exists.ProjectInactiveError – The project is inactive.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
Async tools for interacting with the Vuforia Cloud Recognition Web APIs.
- class vws.async_query.AsyncCloudRecoService(*, client_access_key: str, client_secret_key: str, base_vwq_url: str = 'https://cloudreco.vuforia.com', request_timeout_seconds: float | tuple[float, float] = 30.0, transport: AsyncTransport | None = None)¶
An async interface to the Vuforia Cloud Recognition Web APIs.
- Parameters:
client_access_key – A VWS client access key.
client_secret_key – A VWS client secret key.
base_vwq_url – The base URL for the VWQ API.
request_timeout_seconds – The timeout for each HTTP request. This can be a float to set both the connect and read timeouts, or a (connect, read) tuple.
transport – The async HTTP transport to use for requests. Defaults to
AsyncHTTPXTransport().
- async query(*, image: BytesIO | BinaryIO, max_num_results: int = 1, include_target_data: CloudRecoIncludeTargetData = CloudRecoIncludeTargetData.TOP) list[QueryResult]¶
Use the Vuforia Web Query API to make an Image Recognition Query.
See https://developer.vuforia.com/library/web-api/vuforia-query-web-api for parameter details.
- Parameters:
image – The image to make a query against.
max_num_results – The maximum number of matching targets to be returned.
include_target_data – Indicates if target_data records shall be returned for the matched targets. Accepted values are top (default value, only return target_data for top ranked match), none (return no target_data), all (for all matched targets).
- Raises:
AuthenticationFailureError – The client access key pair is not correct.
MaxNumResultsOutOfRangeError –
max_num_resultsis not within the range (1, 50).InactiveProjectError – The project is inactive.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
BadImageError – There is a problem with the given image. For example, it must be a JPEG or PNG file in the grayscale or RGB color space.
RequestEntityTooLargeError – The given image is too large.
ServerError – There is an error with Vuforia’s servers.
- Returns:
An ordered list of target details of matching targets.
Async interface to the Vuforia VuMark Generation Web API.
- class vws.async_vumark_service.AsyncVuMarkService(*, server_access_key: str, server_secret_key: str, base_vws_url: str = 'https://vws.vuforia.com', request_timeout_seconds: float | tuple[float, float] = 30.0, transport: AsyncTransport | None = None)¶
An async interface to the Vuforia VuMark Generation Web API.
- Parameters:
server_access_key – A VWS server access key.
server_secret_key – A VWS server secret key.
base_vws_url – The base URL for the VWS API.
request_timeout_seconds – The timeout for each HTTP request. This can be a float to set both the connect and read timeouts, or a (connect, read) tuple.
transport – The async HTTP transport to use for requests. Defaults to
AsyncHTTPXTransport().
- async generate_vumark_instance(*, target_id: str, instance_id: str, accept: VuMarkAccept) bytes¶
Generate a VuMark instance image.
See https://developer.vuforia.com/library/vuforia-engine/web-api/vumark-generation-web-api/ for parameter details.
- Parameters:
target_id – The ID of the VuMark target.
instance_id – The instance ID to encode in the VuMark.
accept – The image format to return.
- Returns:
The VuMark instance image bytes.
- Raises:
AuthenticationFailureError – The secret key is not correct.
FailError – There was an error with the request. For example, the given access key does not match a known database.
InvalidAcceptHeaderError – The Accept header value is not supported.
InvalidInstanceIdError – The instance ID is invalid. For example, it may be empty.
InvalidTargetTypeError – The target is not a VuMark template target.
RequestTimeTooSkewedError – There is an error with the time sent to Vuforia.
TargetStatusNotSuccessError – The target is not in the success state.
UnknownTargetError – The given target ID does not match a target in the database.
ServerError – There is an error with Vuforia’s servers.
TooManyRequestsError – Vuforia is rate limiting access.
Classes for representing Vuforia reports.
- class vws.reports.DatabaseSummaryReport(active_images: int, current_month_recos: int, failed_images: int, inactive_images: int, name: str, previous_month_recos: int, processing_images: int, reco_threshold: int, request_quota: int, request_usage: int, target_quota: int, total_recos: int)¶
A database summary report.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#summary-report.
- class vws.reports.TargetStatuses(*values)¶
Constants representing VWS target statuses.
See the ‘status’ field in https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#target-record
- PROCESSING = 'processing'¶
- SUCCESS = 'success'¶
- FAILED = 'failed'¶
- class vws.reports.TargetSummaryReport(status: TargetStatuses, database_name: str, target_name: str, upload_date: date, active_flag: bool, tracking_rating: int, total_recos: int, current_month_recos: int, previous_month_recos: int)¶
A target summary report.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#summary-report.
- status: TargetStatuses¶
- class vws.reports.TargetRecord(target_id: str, active_flag: bool, name: str, width: float, tracking_rating: int, reco_rating: str)¶
A target record.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#target-record.
- class vws.reports.TargetData(name: str, application_metadata: str | None, target_timestamp: datetime)¶
The target data optionally included with a query match.
- class vws.reports.QueryResult(target_id: str, target_data: TargetData | None)¶
One query match result.
See https://developer.vuforia.com/library/web-api/vuforia-query-web-api.
- target_data: TargetData | None¶
- class vws.reports.TargetStatusAndRecord(status: TargetStatuses, target_record: TargetRecord)¶
The target status and a target record.
See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#target-record.
- status: TargetStatuses¶
- target_record: TargetRecord¶
Tools for managing CloudRecoService.query’s include_target_data.
- class vws.include_target_data.CloudRecoIncludeTargetData(*values)¶
Options for the
include_target_dataparameter ofCloudRecoService.query.- TOP = 'top'¶
- NONE = 'none'¶
- ALL = 'all'¶
Tools for managing VWS.generate_vumark_instance’s accept.
- class vws.vumark_accept.VuMarkAccept(*values)¶
Options for the
acceptparameter ofVWS.generate_vumark_instance.- PNG = 'image/png'¶
- SVG = 'image/svg+xml'¶
- PDF = 'application/pdf'¶
Responses for requests to VWS and VWQ.
- class vws.response.Response(text: str, url: str, status_code: int, headers: dict[str, str], request_body: bytes | str | None, tell_position: int, content: bytes)¶
A response from a request.
HTTP transport implementations for VWS clients.
- class vws.transports.Transport(*args, **kwargs)¶
Protocol for HTTP transports used by VWS clients.
A transport is a callable that makes an HTTP request and returns a
Response.
- class vws.transports.RequestsTransport¶
HTTP transport using the
requestslibrary.This is the default transport.
- class vws.transports.HTTPXTransport¶
HTTP transport using the
httpxlibrary.Use this transport for environments where
httpxis preferred overrequests.
- class vws.transports.AsyncTransport(*args, **kwargs)¶
Protocol for async HTTP transports used by VWS clients.
An async transport is a callable that makes an HTTP request and returns a
Response.
- class vws.transports.AsyncHTTPXTransport¶
Async HTTP transport using the
httpxlibrary.This is the default transport for async VWS clients. A single
httpx.AsyncClientis reused across requests for connection pooling.Create an
AsyncHTTPXTransport.