Skip to content

list_faces

list_faces(
    collection_id: CollectionId,
    *,
    config_overrides: Optional[RekognitionClientConfig] = None,
    next_token: Optional[PaginationToken] = None,
    max_results: Optional[PageSize] = None,
    user_id: Optional[UserId] = None,
    face_ids: Optional[FaceIdList] = None,
) -> ListFacesResponse

Returns metadata for faces in the specified collection. This metadata includes information such as the bounding box coordinates, the confidence (that the bounding box contains a face), and face ID. For an example, see Listing Faces in a Collection in the Amazon Rekognition Developer Guide.

This operation requires permissions to perform the rekognition:ListFaces action.

Parameters:

  • collection_id (CollectionId) –

    ID of the collection from which to list the faces.

  • next_token (Optional[PaginationToken], default: None ) –

    If the previous response was incomplete (because there is more data to retrieve), Amazon Rekognition returns a pagination token in the response. You can use this pagination token to retrieve the next set of faces.

  • max_results (Optional[PageSize], default: None ) –

    Maximum number of faces to return.

  • user_id (Optional[UserId], default: None ) –

    An array of user IDs to filter results with when listing faces in a collection.

  • face_ids (Optional[FaceIdList], default: None ) –

    An array of face IDs to filter results with when listing faces in a collection.

Raises:

Examples:

To list the faces in a collection This operation lists the faces in a Rekognition collection.

>>> client.list_faces(collection_id='myphotos', max_results=20)
Source code in docs_src/capo_rekognition/_services/rekognition.py
def list_faces(
    self,
    collection_id: "capo_rekognition.types.collection_id.CollectionId",
    *,
    config_overrides: Optional[RekognitionClientConfig] = None,
    next_token: Optional[
        "capo_rekognition.types.pagination_token.PaginationToken"
    ] = None,
    max_results: Optional["capo_rekognition.types.page_size.PageSize"] = None,
    user_id: Optional["capo_rekognition.types.user_id.UserId"] = None,
    face_ids: Optional["capo_rekognition.types.face_id_list.FaceIdList"] = None,
) -> "capo_rekognition.types.list_faces_response.ListFacesResponse":
    """<p>Returns metadata for faces in the specified collection. This metadata includes information such as the bounding box coordinates, the confidence (that the bounding box contains a face), and face ID. For an example, see Listing Faces in a Collection in the Amazon Rekognition Developer Guide.</p> <p>This operation requires permissions to perform the <code>rekognition:ListFaces</code> action.</p>

    Args:
        collection_id: <p>ID of the collection from which to list the faces.</p>
        next_token: <p>If the previous response was incomplete (because there is more data to retrieve), Amazon Rekognition returns a pagination token in the response. You can use this pagination token to retrieve the next set of faces.</p>
        max_results: <p>Maximum number of faces to return.</p>
        user_id: <p>An array of user IDs to filter results with when listing faces in a collection.</p>
        face_ids: <p>An array of face IDs to filter results with when listing faces in a collection.</p>

    Raises:
        capo_rekognition.errors.access_denied_exception.AccessDeniedException: <p>You are not authorized to perform the action.</p>
        capo_rekognition.errors.internal_server_error.InternalServerError: <p>Amazon Rekognition experienced a service issue. Try your call again.</p>
        capo_rekognition.errors.invalid_pagination_token_exception.InvalidPaginationTokenException: <p>Pagination token in the request is not valid.</p>
        capo_rekognition.errors.invalid_parameter_exception.InvalidParameterException: <p>Input parameter violated a constraint. Validate your parameter before calling the API operation again.</p>
        capo_rekognition.errors.provisioned_throughput_exceeded_exception.ProvisionedThroughputExceededException: <p>The number of requests exceeded your throughput limit. If you want to increase this limit, contact Amazon Rekognition.</p>
        capo_rekognition.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource specified in the request cannot be found.</p>
        capo_rekognition.errors.throttling_exception.ThrottlingException: <p>Amazon Rekognition is temporarily unable to process the request. Try your call again.</p>
        capo_rekognition.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To list the faces in a collection
        This operation lists the faces in a Rekognition collection.

        >>> client.list_faces(collection_id='myphotos', max_results=20)
    """

    def _handler(
        req: "OperationRequest[capo_rekognition.types.list_faces_request.ListFacesRequest]",
    ) -> OperationResponse[
        "capo_rekognition.types.list_faces_response.ListFacesResponse"
    ]:
        import capo_rekognition._operations.rekognition_service.list_faces

        output, http_response = (
            capo_rekognition._operations.rekognition_service.list_faces.list_faces(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListFaces")
    )
    input_: capo_rekognition.types.list_faces_request.ListFacesRequest = {
        "collection_id": collection_id
    }
    if next_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results
    if user_id is not None:
        input_["user_id"] = user_id
    if face_ids is not None:
        input_["face_ids"] = face_ids

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output