Convert query

Endpoint to migrate Supermetrics API version 1 queries into a version 2 queries.

POST https://api.supermetrics.com/enterprise/v2/query/convert

Parameters

  • api_key string
    Conditional. API key when not using an authorization header. See authentication for more.
  • urls string[]
    List version 1 query URLs, to be converted into version 2 queries

Request

POST /enterprise/v2/query/convert
Authorization: Bearer <your api key>
Content-Type: application/json

{
    "urls": [
        "https://supermetrics.com/api/getData?dataSource=GA&dateRangeType=...",
        "https://supermetrics.com/api/getData?dataSource=FAstart-date=..."
    ]
}

Response

PropertyTypeDescription
data > * > urlstring URL from the request
data > * > errorobject If conversion failed, error details
data > * > error > codestring Error for the error. See errors for more.
data > * > error > messagestring Short localized error message or code if not available
data > * > error > descriptionstring Detailed localized error description
data > * > resultobject If conversion succeeded, version 2 query details
data > * > result > uristring URL to the endpoint to call with GET or POST
data > * > result > paramsobject New query parameters in key-value pairs. See get data for more.
HTTP 200 OK
{
    "meta": {
        "request_id": "6_sLMK_ELN4ezNm2LLDIdMp8AoPSUAhC"
    },
    "data": [
        {
            "url": "https://supermetrics.com/api/v1/getData?",
            "error": {
                "code": "URL_INCOMPLETE",
                "message": "Incomplete query URL",
                "description": "Provided URL looks to be missing parameters."
            }
        },
        {
            "url": "https://supermetrics.com/api/v1/getData?...targetAppFormat=powerbi",
            "result": {
                "uri": "https://api.supermetrics.com/enterprise/query/data/powerbi",
                "params": {
                    "ds_id": "GA",
                    "ds_accounts": "567890",
                    "ds_user": "e_35681351584",
                    "fields": "Year,EventAction,visits",
                    "settings": {
                        "avoid_sampling": true,
                        "timezone": "America/New_York"
                    },
                    "filter": "CampaignName =~ Super AND CampaignName != Superman",
                    "order_rows": "Year asc,EventAction desc"
                }
            }
        }
    ]
}

Best practices

  • Make sure the migrated queries produce the same results as before. This endpoint only helps you transform previous query parameters into new ones — it does not perform result data comparisons.

  • When sending the version 2 query parameters, choose the method that works best for you. See making requests for details.

Last updated 2023-08-16 UTC.