Created
July 4, 2021 23:06
-
-
Save StickmanNinja/7482e6347655969184a80d3cb1a761cf to your computer and use it in GitHub Desktop.
Python Example Of Project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
r = requests.get('https://matrix.adapex.io/api/kffb/siteplacementdate?token=***********************').json() | |
# DATE - Total Impressions - Paid Impressions - Fill - Revenue - CPM | |
#Date must be in YEAR-MONTH-DAY format. Only 2 digits for month and day. | |
#EXAMPLE: 2021-06-15 | |
def GetInfo(givendate, givenwebsite): | |
newdata = [] | |
for i in range(0,len(r["results"])): | |
if r["results"][i][1] == str(givendate) and r["results"][i][2] == str(givenwebsite): | |
newdata.append({ | |
"date": str(r["results"][i][1]), | |
"totalimpressions": str(r["results"][i][7]), | |
"paidimpressions": str(r["results"][i][8]), | |
"revenue": str(float(r["results"][i][9])), | |
"rpm": str(float(r["results"][i][12])) | |
}) | |
totalimpressions = 0 | |
totalpaidimpressions = 0 | |
totalrevenue = 0 | |
totalrpm = 0 | |
for i in range(0,len(newdata)): | |
totalimpressions = totalimpressions + float(newdata[i]["totalimpressions"]) | |
totalpaidimpressions = totalpaidimpressions + float(newdata[i]["paidimpressions"]) | |
totalrevenue = totalrevenue + float(newdata[i]["revenue"]) | |
totalrpm = totalrpm + float(newdata[i]["rpm"]) | |
return {"date": givendate, "totalimpressions": totalimpressions, "totalpaidimpressions": totalpaidimpressions, "revenue": totalrevenue, "rpm": totalrpm} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment