Get error rate for AWS API Gateway through CloudWatch

Top-level error rate:

aws cloudwatch get-metric-data \
    --region us-east-1 \
    --start-time 2020-08-01T00:00:00Z \
    --end-time 2020-08-02T00:00:00Z \
    --scan-by TimestampAscending \
    --metric-data-queries '
[
    {
        "Id": "m1",
        "MetricStat": {
            "Metric": {
                "Namespace": "AWS/ApiGateway",
                "MetricName": "5XXError",
                "Dimensions": [
                    {
                        "Name": "ApiName",
                        "Value": "<service-name>"
                    },
                    {
                        "Name": "Stage",
                        "Value": "<stage-name>"
                    }
                ]
            },
            "Period": 300,
            "Stat": "Average"
        }
    }
]
    '

Or, for API-level, just add relevant dimensions:

aws cloudwatch get-metric-data \
    --region us-east-1 \
    --start-time 2020-08-01T00:00:00Z \
    --end-time 2020-08-02T00:00:00Z \
    --scan-by TimestampAscending \
    --metric-data-queries '
[
    {
        "Id": "m1",
        "MetricStat": {
            "Metric": {
                "Namespace": "AWS/ApiGateway",
                "MetricName": "5XXError",
                "Dimensions": [
                    {
                        "Name": "ApiName",
                        "Value": "<service-name>"
                    },
                    {
                        "Name": "Stage",
                        "Value": "<stage-name>"
                    },
                    {
                        "Name": "Resource",
                        "Value": "<resource-name>"
                    },
                    {
                        "Name": "Method",
                        "Value": "<method-name>"
                    }
                ]
            },
            "Period": 300,
            "Stat": "Average"
        }
    }
]
        '