Reporting

Abstract

Describes Yahoo DSP and Native POST and reporting stats with endpoints, CURL and JSON example code. An example of reporting in Python is also included.

Campaign Performance Report

Yahoo Native

Endpoint

https://api.gemini.yahoo.com/v3/rest/reports/custom

Method: POST

Header:

Content-Type: application/json Authorization: Bearer <access_token>

Body:

{
    "cube": "performance_stats",
    "fields": [
        {
            "field": "Day"
        },
        {
            "field": "Advertiser ID"
        },
        {
            "field": "Advertiser Name"
        },
        {
            "field": "Advertiser Timezone"
        },
        {
            "field": "Advertiser Currency"
        },
        {
            "field": "Campaign ID"
        },
        {
            "field": "Campaign Name"
        },
        {
            "field": "Campaign Start Date"
        },
        {
            "field": "Campaign End Date"
        },
        {
            "field": "Campaign Status"
        },
        {
            "field": "Campaign Objective"
        },
        {
            "field": "Budget"
        },
        {
            "field": "Impressions"
        },
        {
            "field": "Clicks"
        },
        {
            "field":"CTR"
        },
        {
            "field": "Spend"
        },
        {
            "field": "Average CPC"
        },
        {
            "field": "Average Cost-per-install"
        },
        {
            "field": "Average CPM"
        },
        {
            "field": "Pricing Type"
        },
        {
            "field": "Max Bid"
        },
        {
            "field": "Post Click Conv Value"
        },
        {
            "field": "Post Impr Conv Value"
        },
        {
            "field": "Total Conversions"
        },
        {
            "field": "Device Type"
        }
    ],
    "filters": [
        {
            "field": "Advertiser ID",
            "operator": "=",
            "value": advertiser_id
        },
        {
            "field": "Campaign ID",
            "operator": "IN",
            "values": [
                campaign_id
            ]
        },
        {
            "field": "Day",
            "operator": "between",
            "from": "2021-02-10",
            "to": "2021-02-12"
        }
    ]
}

CURL

curl --location --request POST 'https://api.gemini.yahoo.com/v3/rest/reports/custom' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer access_token' \
--data-raw '{
    "cube": "performance_stats",
    "fields": [
        {
            "field": "Day"
        },
        {
            "field": "Advertiser ID"
        },
        {
            "field": "Advertiser Name"
        },
        {
            "field": "Advertiser Timezone"
        },
        {
            "field": "Advertiser Currency"
        },
        {
            "field": "Campaign ID"
        },
        {
            "field": "Campaign Name"
        },
        {
            "field": "Campaign Start Date"
        },
        {
            "field": "Campaign End Date"
        },
        {
            "field": "Campaign Status"
        },
        {
            "field": "Campaign Objective"
        },
        {
            "field": "Budget"
        },
        {
            "field": "Impressions"
        },
        {
            "field": "Clicks"
        },
        {
            "field":"CTR"
        },
        {
            "field": "Spend"
        },
        {
            "field": "Average CPC"
        },
        {
            "field": "Average Cost-per-install"
        },
        {
            "field": "Average CPM"
        },
        {
            "field": "Pricing Type"
        },
        {
            "field": "Max Bid"
        },
        {
            "field": "Post Click Conv Value"
        },
        {
            "field": "Post Impr Conv Value"
        },
        {
            "field": "Total Conversions"
        },
        {
            "field": "Device Type"
        }
    ],
    "filters": [
        {
            "field": "Advertiser ID",
            "operator": "=",
            "value": 1923781
        },
        {
            "field": "Campaign ID",
            "operator": "IN",
            "values": [
                391799602
            ]
        },
        {
            "field": "Day",
            "operator": "between",
            "from": "2021-02-10",
            "to": "2021-02-12"
        }
    ]
}'

Response

{
    "errors": null,
    "timestamp": "2021-02-13 17:53:52",
    "response": {
        "jobId": "f7b275384bf2b5efa0f88c83c280fb69e3734ed0f2b0454bfc334d0ea52c8b6cf1e46fb0",
        "status": "submitted",
        "jobResponse": null,
        "jobDisplayName": "ASYNC_REQUEST"
    }
}

Yahoo DSP

Endpoint:

http://api-sched-v3.admanagerplus.yahoo.com/yamplus_api/extreport/

Method: POST

Header:

Content-Type: application/json X-Auth-Token: access_token X-Auth-Method: OAUTH2

Body:

{
  "reportOption": {
    "timezone": "America/New_York",
    "dimensionTypeIds": [
      4,
      5,
      67,
      31,
      34,
      107,
      28,
      21,
      19,
      75,
      20,
      22
    ],
    "currency": 4,
    "metricTypeIds": [
      44,
      1,
      2,
      23,
      11,
      41,
      43,
      45,
      138,
      110,
      109,
      114,
      112,
      111,
      113,
      137,
      365,
      29,
      28,
      27,
      26,
      25
    ],
    "filterOptions": [
      {
        "dimensionTypeId": 4,
        "isExcluded": false,
        "includeValues": [
          {
            "id": 35215
          }
        ]
      }
    ],
    "having": {
      "type": "and",
      "havingSpecs": []
    }
  },

  "intervalTypeId": 1,
  "dateTypeId": 2,
  "startDate": "2021-02-12T00:00:00-05:00",
  "endDate": "2021-02-12T23:59:59-05:00"

}

CURL

curl --location --request POST 'http://api-sched-v3.admanagerplus.yahoo.com/yamplus_api/extreport/' \
--header 'X-Auth-Token: access_token' \
--header 'X-Auth-Method: OAUTH2' \
--header 'Content-Type: application/json' \
--data-raw '{
  "reportOption": {
    "timezone": "America/New_York",
    "dimensionTypeIds": [
      4,
      5,
      67,
      31,
      34,
      107,
      28,
      21,
      19,
      75,
      20,
      22
    ],
    "currency": 4,
    "metricTypeIds": [
      44,
      1,
      2,
      23,
      11,
      41,
      43,
      45,
      138,
      110,
      109,
      114,
      112,
      111,
      113,
      137,
      365,
      29,
      28,
      27,
      26,
      25
    ],
    "filterOptions": [
      {
        "dimensionTypeId": 4,
        "isExcluded": false,
        "includeValues": [
          {
            "id": 35215
          }
        ]
      }
    ],
    "having": {
      "type": "and",
      "havingSpecs": []
    }
  },

  "intervalTypeId": 1,
  "dateTypeId": 2,
  "startDate": "2021-02-12T00:00:00-05:00",
  "endDate": "2021-02-12T23:59:59-05:00"

}'

Response

{
    "customerReportId": "e1ab172a-46ea-4f3a-b034-9686356f0c61",
    "status": "Submitted",
    "requestPayload": "{\"....”
}

Domain Performance Report

Yahoo Native

Endpoint:

https://api.gemini.yahoo.com/v3/rest/reports/custom

Method: POST

Header:

Content-Type: application/json Authorization: Bearer <access_token>

Body:

{
  "cube": "domain_performance_stats",
  "fields": [
  { "field": "Advertiser ID" }
  ,
  { "field": "Impressions" }
  ,
  { "field": "Clicks" }
  ,
  { "field": "Spend" }
  ,
  { "field": "Top Domain" }
  ,
  { "field": "Package Name" }
  ],
 "filters": [
  { "field": "Advertiser ID", "operator": "=", "value": 1234 }
  ,
  { "field": "Campaign ID", "operator": "IN", "values": [ 3366778899, 3366778844, ] }
  ,
  { "field": "Day", "operator": "between", "from": "2021-05-25", "to": "2021-05-30" }
 ]
}

CURL

curl --location --request POST 'https://api.gemini.yahoo.com/v3/rest/reports/custom' \
--header 'Authorization: Bearer ' \
--header 'Content-Type: text/plain' \
--data-raw '{
  "cube": "domain_performance_stats",
  "fields": [
  { "field": "Advertiser ID" }
  ,
  { "field": "Impressions" }
  ,
  { "field": "Clicks" }
  ,
  { "field": "Spend" }
  ,
  { "field": "Top Domain" }
  ,
  { "field": "Package Name" }
  ],
 "filters": [
  { "field": "Advertiser ID", "operator": "=", "value": 1878800 }
  ,
  { "field": "Campaign ID", "operator": "IN", "values": [ 389332436 ] }
  ,
  { "field": "Day", "operator": "between", "from": "2020-06-25", "to": "2020-06-30" }
  ,
  { "field": "Top Domain", "operator": "=", "value": "www.foxnews.com" }
 ]
}'

Response:

{
    "errors": null,
    "timestamp": "2021-02-13 17:53:52",
    "response": {
        "jobId": "f7b275384bf2b5efa0f88c83c280fb69e3734ed0f2b0454bfc334d0ea52c8b6cf1e46fb0",
        "status": "submitted",
        "jobResponse": null,
        "jobDisplayName": "ASYNC_REQUEST"
    }
}

Yahoo DSP

Endpoint: http://api-sched-v3.admanagerplus.yahoo.com/yamplus_api/extreport/

Method: POST

Header:

Content-Type: application/json X-Auth-Token: access_token X-Auth-Method: OAUTH2

Body:

{
    "reportOption": {
        "timezone": "America/New_York",
        "dimensionTypeIds": [
            5,
            9,
            6,
            7,
            8
        ],
        "currency": 4,
        "metricTypeIds": [
            44,
            1,
            2,
            23,
            11,
            41,
            43
        ],
        "filterOptions": [],
        "having": {
            "type": "and",
            "havingSpecs": []
        }
    },
    "intervalTypeId": 1,
    "dateTypeId": 2,
    "startDate": "2021-06-15T00:00:00-04:00",
    "endDate": "2021-06-15T23:59:59-04:00"
}

CURL

curl --location --request POST 'http://api-sched-v3.admanagerplus.yahoo.com/yamplus_api/extreport/' \
--header 'X-Auth-Token: ' \
--header 'X-Auth-Method: OAUTH2' \
--header 'Content-Type: application/json' \
--data-raw '{
    "reportOption": {
        "timezone": "America/New_York",
        "dimensionTypeIds": [
            5,
            9,
            6,
            7,
            8
        ],
        "currency": 4,
        "metricTypeIds": [
            44,
            1,
            2,
            23,
            11,
            41,
            43
        ],
        "filterOptions": [],
        "having": {
            "type": "and",
            "havingSpecs": []
        }
    },
    "intervalTypeId": 1,
    "dateTypeId": 2,
    "startDate": "2021-06-15T00:00:00-04:00",
    "endDate": "2021-06-15T23:59:59-04:00"
}'

Response:

{
    "customerReportId": "e1ab172a-46ea-4f3a-b034-9686356f0c61",
    "status": "Submitted",
    "requestPayload": "{\"....”
}

user_stats

Yahoo Native

Endpoint:

https://api.gemini.yahoo.com/v3/rest/reports/custom

Method: POST

Header:

Content-Type: application/json Authorization: Bearer <access_token>

Body:

{
  "cube": "user_stats",
  "fields": [
      {
          "field": "Advertiser ID"
      },
      {
          "field": "Campaign ID"
      },
      {
          "field": "Source"
      },
      {
          "field": "Country"
      },
      {
          "field": "Device"
      },
      {
          "field": "Day"
      },
      {
          "field": "Impressions"
      }
  ],
  "filters": [
      {
          "field": "Advertiser ID",
          "operator": "=",
          "value": 929757
      },
      {
          "field": "Campaign ID",
          "operator": "IN",
          "values": [
              331195036,
              331273097
          ]
      },
      {
          "field": "Day",
          "operator": "between",
          "from": "2015-12-01",
          "to": "2015-12-08"
      }
  ]
}

CURL:

curl --location --request POST 'https://api.gemini.yahoo.com/v3/rest/reports/custom' \
--header 'Authorization: Bearer ' \
--header 'Content-Type: text/plain' \
--data-raw '{
  "cube": "domain_performance_stats",
  "fields": [
  { "field": "Advertiser ID" }
  ,
  { "field": "Impressions" }
  ,
  { "field": "Clicks" }
  ,
  { "field": "Spend" }
  ,
  { "field": "Top Domain" }
  ,
  { "field": "Package Name" }
  ],
 "filters": [
  { "field": "Advertiser ID", "operator": "=", "value": 123456 }
  ,
  { "field": "Campaign ID", "operator": "IN", "values": [ 234567 ] }
  ,
  { "field": "Day", "operator": "between", "from": "2020-06-25", "to": "2020-06-30" }
  ,
  { "field": "Top Domain", "operator": "=", "value": "www.foxnews.com" }
 ]
}'

Response:

{
    "errors": null,
    "timestamp": "2021-02-13 17:53:52",
    "response": {
        "jobId": "f7b275384bf2b5efa0f88c83c280fb69e3734ed0f2b0454bfc334d0ea52c8b6cf1e46fb0",
        "status": "submitted",
        "jobResponse": null,
        "jobDisplayName": "ASYNC_REQUEST"
    }
}

Yahoo DSP

Endpoint: http://api-sched-v3.admanagerplus.yahoo.com/yamplus_api/extreport/

Method: POST

Header:

Content-Type: application/json X-Auth-Token: access_token X-Auth-Method: OAUTH2

Body:

{
    "reportOption": {
        "timezone": "America/New_York",
        "dimensionTypeIds": [
            5,
            9,
            6,
            7,
            8,
            4,
            28,
            107,
            34,
            19,
            20,
            22,
            21,
            75
        ],
        "currency": 4,
        "metricTypeIds": [
            44,
            1,
            2,
            23,
            11,
            41,
            43,
            110,
            109,
            26,
            27,
            29
        ],
        "filterOptions": [],
        "having": {
            "type": "and",
            "havingSpecs": []
        }
    },

    "intervalTypeId": 1,
    "dateTypeId": 2,
    "startDate": "2021-06-15T00:00:00-04:00",
    "endDate": "2021-06-15T23:59:59-04:00"
}

CURL:

curl --location --request POST 'http://api-sched-v3.admanagerplus.yahoo.com/yamplus_api/extreport/' \
--header 'X-Auth-Token: ' \
--header 'X-Auth-Method: OAUTH2' \
--header 'Content-Type: application/json' \
--data-raw '{
    "reportOption": {
        "timezone": "America/New_York",
        "dimensionTypeIds": [
            5,
            9,
            6,
            7,
            8
        ],
        "currency": 4,
        "metricTypeIds": [
            44,
            1,
            2,
            23,
            11,
            41,
            43
        ],
        "filterOptions": [],
        "having": {
            "type": "and",
            "havingSpecs": []
        }
    },
    "intervalTypeId": 1,
    "dateTypeId": 2,
    "startDate": "2021-06-15T00:00:00-04:00",
    "endDate": "2021-06-15T23:59:59-04:00"
}'

Response:

{
    "customerReportId": "e1ab172a-46ea-4f3a-b034-9686356f0c61",
    "status": "Submitted",
    "requestPayload": "{\"....”
}

conversion_rule_stats

Yahoo Native

Endpoint:

https://api.gemini.yahoo.com/v3/rest/reports/custom

Method: POST

Header:

Content-Type: application/json Authorization: Bearer <access_token>

Body:

{
  "cube": "conversion_rules_stats",
  "fields": [
      {
          "field": "Advertiser ID"
      },
      {
          "field": "Campaign ID"
      },
      {
          "field": "Ad Group ID"
      },
      {
          "field": "Day"
      },
      {
          "field": "Rule ID"
      },
      {
          "field": "Rule Name"
      },
      {
          "field": "Conversion Device"
      },
      {
          "field": "Conversion Value"
      }
  ],
  "filters": [
      {
          "field": "Advertiser ID",
          "operator": "=",
          "value": 929757
      },
      {
          "field": "Campaign ID",
          "operator": "IN",
          "values": [
              3311225,
              3311447
          ]
      },
      {
          "field": "Day",
          "operator": "between",
          "from": "2015-05-24",
          "to": "2015-05-27"
      }
  ]
}

CURL:

curl --location --request POST 'https://api.gemini.yahoo.com/v3/rest/reports/custom' \
--header 'Authorization: Bearer ' \
--header 'Content-Type: text/plain' \
--data-raw '{
  "cube": "domain_performance_stats",
  "fields": [
  { "field": "Advertiser ID" }
  ,
  { "field": "Impressions" }
  ,
  { "field": "Clicks" }
  ,
  { "field": "Spend" }
  ,
  { "field": "Top Domain" }
  ,
  { "field": "Package Name" }
  ],
 "filters": [
  { "field": "Advertiser ID", "operator": "=", "value": 123456 }
  ,
  { "field": "Campaign ID", "operator": "IN", "values": [ 234567 ] }
  ,
  { "field": "Day", "operator": "between", "from": "2020-06-25", "to": "2020-06-30" }
  ,
  { "field": "Top Domain", "operator": "=", "value": "www.foxnews.com" }
 ]
}'

Response:

{
    "errors": null,
    "timestamp": "2021-02-13 17:53:52",
    "response": {
        "jobId": "f7b275384bf2b5efa0f88c83c280fb69e3734ed0f2b0454bfc334d0ea52c8b6cf1e46fb0",
        "status": "submitted",
        "jobResponse": null,
        "jobDisplayName": "ASYNC_REQUEST"
    }
}

Yahoo DSP

Endpoint: http://api-sched-v3.admanagerplus.yahoo.com/yamplus_api/extreport/

Method: POST

Header:

Content-Type: application/json X-Auth-Token: access_token X-Auth-Method: OAUTH2

Body:

{
    "reportOption": {
        "timezone": "America/New_York",
        "dimensionTypeIds": [
            5,
      4,
      6,
      7,
      151,
      34,
      103,
      67

        ],
        "currency": 4,
        "metricTypeIds": [
            44,
      1,
      2,
      23,
      11,
      41,
      43,
      109,
      110

        ],
        "filterOptions": [],
        "having": {
            "type": "and",
            "havingSpecs": []
        }
    },

    "intervalTypeId": 1,
    "dateTypeId": 2,
    "startDate": "2021-06-15T00:00:00-04:00",
    "endDate": "2021-06-15T23:59:59-04:00"
}

CURL:

curl --location --request POST 'http://api-sched-v3.admanagerplus.yahoo.com/yamplus_api/extreport/' \
--header 'X-Auth-Token: ' \
--header 'X-Auth-Method: OAUTH2' \
--header 'Content-Type: application/json' \
--data-raw '{
    "reportOption": {
        "timezone": "America/New_York",
        "dimensionTypeIds": [
            5,
            9,
            6,
            7,
            8
        ],
        "currency": 4,
        "metricTypeIds": [
            44,
            1,
            2,
            23,
            11,
            41,
            43
        ],
        "filterOptions": [],
        "having": {
            "type": "and",
            "havingSpecs": []
        }
    },
    "intervalTypeId": 1,
    "dateTypeId": 2,
    "startDate": "2021-06-15T00:00:00-04:00",
    "endDate": "2021-06-15T23:59:59-04:00"
}'

Response:

{
    "customerReportId": "e1ab172a-46ea-4f3a-b034-9686356f0c61",
    "status": "Submitted",
    "requestPayload": "{\"....”
}

product_ad_stats

Yahoo Native

Endpoint:

https://api.gemini.yahoo.com/v3/rest/reports/custom

Method: POST

Header:

Content-Type: application/json Authorization: Bearer <access_token>

Body:

{
  "cube": "product_ad_stats",
  "fields": [
      {
          "field": "Advertiser ID"
      },
      {
          "field": "Campaign ID"
      },
      {
          "field": "Ad Group ID"
      },
      {
          "field": "Day"
      },
      {
          "field": "Rule ID"
      },
      {
          "field": "Rule Name"
      },
      {
          "field": "Conversion Device"
      },
      {
          "field": "Conversion Value"
      }
  ],
  "filters": [
      {
          "field": "Advertiser ID",
          "operator": "=",
          "value": 929757
      },
      {
          "field": "Campaign ID",
          "operator": "IN",
          "values": [
              3311225,
              3311447
          ]
      },
      {
          "field": "Day",
          "operator": "between",
          "from": "2015-05-24",
          "to": "2015-05-27"
      }
  ]
}

CURL:

curl --location --request POST 'https://api.gemini.yahoo.com/v3/rest/reports/custom' \
--header 'Authorization: Bearer ' \
--header 'Content-Type: text/plain' \
--data-raw '{
  "cube": "domain_performance_stats",
  "fields": [
  { "field": "Advertiser ID" }
  ,
  { "field": "Impressions" }
  ,
  { "field": "Clicks" }
  ,
  { "field": "Spend" }
  ,
  { "field": "Top Domain" }
  ,
  { "field": "Package Name" }
  ],
 "filters": [
  { "field": "Advertiser ID", "operator": "=", "value": 123456 }
  ,
  { "field": "Campaign ID", "operator": "IN", "values": [ 234567 ] }
  ,
  { "field": "Day", "operator": "between", "from": "2020-06-25", "to": "2020-06-30" }
  ,
  { "field": "Top Domain", "operator": "=", "value": "www.foxnews.com" }
 ]
}'

Response:

{
    "errors": null,
    "timestamp": "2021-02-13 17:53:52",
    "response": {
        "jobId": "f7b275384bf2b5efa0f88c83c280fb69e3734ed0f2b0454bfc334d0ea52c8b6cf1e46fb0",
        "status": "submitted",
        "jobResponse": null,
        "jobDisplayName": "ASYNC_REQUEST"
    }
}

Yahoo DSP

Endpoint: http://api-sched-v3.admanagerplus.yahoo.com/yamplus_api/extreport/

Method: POST

Header:

Content-Type: application/json X-Auth-Token: access_token X-Auth-Method: OAUTH2

Body:

{
    "reportOption": {
        "timezone": "America/New_York",
        "dimensionTypeIds": [
            5,
      4,
      6,
      7,
      151,
      34,
      103,
      67

        ],
        "currency": 4,
        "metricTypeIds": [
            44,
      1,
      2,
      23,
      11,
      41,
      43,
      109,
      110

        ],
        "filterOptions": [],
        "having": {
            "type": "and",
            "havingSpecs": []
        }
    },

    "intervalTypeId": 1,
    "dateTypeId": 2,
    "startDate": "2021-06-15T00:00:00-04:00",
    "endDate": "2021-06-15T23:59:59-04:00"
}

CURL:

curl --location --request POST 'http://api-sched-v3.admanagerplus.yahoo.com/yamplus_api/extreport/' \
--header 'X-Auth-Token: ' \
--header 'X-Auth-Method: OAUTH2' \
--header 'Content-Type: application/json' \
--data-raw '{
    "reportOption": {
        "timezone": "America/New_York",
        "dimensionTypeIds": [
            5,
            9,
            6,
            7,
            8
        ],
        "currency": 4,
        "metricTypeIds": [
            44,
            1,
            2,
            23,
            11,
            41,
            43
        ],
        "filterOptions": [],
        "having": {
            "type": "and",
            "havingSpecs": []
        }
    },
    "intervalTypeId": 1,
    "dateTypeId": 2,
    "startDate": "2021-06-15T00:00:00-04:00",
    "endDate": "2021-06-15T23:59:59-04:00"
}'

Response:

{
    "customerReportId": "e1ab172a-46ea-4f3a-b034-9686356f0c61",
    "status": "Submitted",
    "requestPayload": "{\"....”
}

Python Example

The following is a reporting example in Python:

import configparser
import base64
import hashlib
import hmac
import json
import time
import requests
from urllib.parse import urljoin
import pandas as pd
import io

# Enter client id and secret here
client_config = {
    "CLIENT_ID": "",
    "CLIENT_SECRET": "",
    "REALM": "dsp",
    "BASE_URL": "https://id.b2b.verizonmedia.com/identity",
    "SCOPE": "dsp-api-access"
}


class Report:
    def __init__(self):
        self.i_f = None
        self.authorization = ''
        self.hed = None
        self.report_id = ''
        self.config = configparser.ConfigParser()

    def hmac_sha256(self, key, msg, encode_output=False):
        message = bytes(msg, 'utf-8')
        secret = bytes(key, 'utf-8')

        signature = hmac.new(secret, message, digestmod=hashlib.sha256).digest()
        return base64.b64encode(signature) if encode_output else signature

    def get_access_token(self):
        client_id = client_config['CLIENT_ID']
        client_secret = client_config['CLIENT_SECRET']
        realm = client_config['REALM']
        base_url = client_config['BASE_URL']
        scope = client_config['SCOPE']
        access_token_url_path = 'identity/oauth2/access_token'

        jwt_header = json.dumps({
            "typ": "JWT",
            "alg": "HS256",
        })

        issue_time = int(time.time())  # Seconds since epoch
        expiry_time = issue_time + 600
        aud = urljoin(base_url, '{path}?realm={realm}'.format(path=access_token_url_path, realm=realm))

        jwt_body = {
            "iss": client_id,
            "sub": client_id,
            "aud": aud,
            "exp": expiry_time,
            "iat": issue_time,
        }

        jwt_body = json.dumps(jwt_body)
        jwt_signing_string = (base64.b64encode(jwt_header.encode(encoding='utf-8'))).decode(encoding='utf-8') + '.' + (
            base64.b64encode(jwt_body.encode(encoding='utf-8')).decode(encoding='utf-8'))

        signature = self.hmac_sha256(client_secret, jwt_signing_string)

        jwt_signature = base64.b64encode(signature)
        client_assertion = str(jwt_signing_string) + '.' + str(jwt_signature.decode(encoding='utf-8'))

        data = {
            'grant_type': 'client_credentials',
            'scope': scope,
            'client_assertion_type': 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
            'client_assertion': client_assertion,
            'realm': realm,
        }
        hed = {
            'Content-Type': 'application/x-www-form-urlencoded',
            'Accept': 'application/json'
        }

        resp = requests.post(urljoin(base_url, access_token_url_path), data=data, headers=hed)

        result = resp.json()
        print(str(result))
        print('Access Token: ' + str(result['access_token']))
        self.authorization = result['access_token']
        self.hed = {'X-Auth-Token': '' + result['access_token'],
                    'X-Auth-Method': 'OAUTH2',
                    'Content-Type': 'application/json'}

    def get_report(self):
        body = {"reportOption": {"timezone": "America/New_York", "currency": 4, "dimensionTypeIds": [5, 6, 7],
                                 "metricTypeIds": [44, 1, 2, 23, 11, 41, 43]}, "intervalTypeId": 1, "dateTypeId": 11,
                "startDate": "2021-06-10T00:00:00-05:00", "endDate": "2021-06-10T11:59:59-05:00"}

        url = 'https://api-sched-v3.admanagerplus.yahoo.com/yamplus_api/extreport/'
        response = requests.post(url, headers=self.hed, json=body)
        print('Response from POST request: ' + json.dumps(response.json(), indent=2))
        self.report_id = response.json()['customerReportId']

    def get_status(self):
        url = 'https://api-sched-v3.admanagerplus.yahoo.com/yamplus_api/extreport/'
        url += self.report_id
        response = requests.get(url, headers=self.hed)
        print('Response from GET status: ' + json.dumps(response.json(), indent=2))
        if response.json()['status'] in ['Processing', 'Submitted']:
            return False
        self.get_csv(response.json()['url'])
        return True

    def get_csv(self, csvurl):
        print('url: ' + csvurl)
        s = requests.get(csvurl).content
        df = pd.read_csv(io.StringIO(s.decode('utf-8')))
        print(df.head())


if __name__ == '__main__':
    r = Report()
    r.get_access_token()
    r.get_report()
    while not r.get_status():
        time.sleep(15)