[NODERS] Aleksandr
[NODERS] Aleksandr
CDCloudflare Developers
Created by [NODERS] Aleksandr on 4/24/2024 in #workers-help
Time range can't be wider than 259200s, but it's 2592000s"
@Leo sorry for ping, could you help me?
7 replies
CDCloudflare Developers
Created by [NODERS] Aleksandr on 4/24/2024 in #workers-help
Time range can't be wider than 259200s, but it's 2592000s"
I tried changing it, but I don't get a response with request 1d, is it really supported?
7 replies
CDCloudflare Developers
Created by [NODERS] Aleksandr on 4/24/2024 in #workers-help
Time range can't be wider than 259200s, but it's 2592000s"
this is great, I just need the number of requests in the last 30 days and the number of unique visitors, for this I need to upgrade to pro too?
7 replies
CDCloudflare Developers
Created by [NODERS] Aleksandr on 4/24/2024 in #workers-help
Time range can't be wider than 259200s, but it's 2592000s"
I can't receive in the last 30 days?
7 replies
CDCloudflare Developers
Created by [NODERS] Aleksandr on 4/24/2024 in #workers-help
Time range can't be wider than 259200s, but it's 2592000s"
for last 24h its works good, but when I request for time more then 3d I get error
7 replies
CDCloudflare Developers
Created by [NODERS] Aleksandr on 4/24/2024 in #workers-help
Time range can't be wider than 259200s, but it's 2592000s"
import requests
from datetime import datetime, timedelta

headers = {
'Authorization': 'Bearer my_api_key',
'Content-Type': 'application/json'
}

# Определение временного интервала за последние 24 часа
end_time = datetime.utcnow()
start_time = end_time - timedelta(days=1)

# Преобразование временных меток в строковый формат для использования в запросе GraphQL
end_time_str = end_time.strftime('%Y-%m-%dT%H:%M:%SZ')
start_time_str = start_time.strftime('%Y-%m-%dT%H:%M:%SZ')

data = """
{
viewer {
zones(filter: {zoneTag: "my_zone_id"}) {
httpRequests1hGroups(limit: 100, filter: {datetime_geq: "%s", datetime_lt: "%s"}) {
uniq {
uniques
}
sum {
requests
}
}
}
}
}
""" % (start_time_str, end_time_str)

response = requests.post(
'https://api.cloudflare.com/client/v4/graphql',
headers=headers,
json={'query': data}
)

if response.status_code == 200:
data = response.json()
total_requests = data['data']['viewer']['zones'][0]['httpRequests1hGroups'][0]['sum']['requests']
unique_visitors = data['data']['viewer']['zones'][0]['httpRequests1hGroups'][0]['uniq']['uniques']

print("Total Requests:", total_requests)
print("Unique Visitors:", unique_visitors)
else:
print("Error:", response.status_code)
import requests
from datetime import datetime, timedelta

headers = {
'Authorization': 'Bearer my_api_key',
'Content-Type': 'application/json'
}

# Определение временного интервала за последние 24 часа
end_time = datetime.utcnow()
start_time = end_time - timedelta(days=1)

# Преобразование временных меток в строковый формат для использования в запросе GraphQL
end_time_str = end_time.strftime('%Y-%m-%dT%H:%M:%SZ')
start_time_str = start_time.strftime('%Y-%m-%dT%H:%M:%SZ')

data = """
{
viewer {
zones(filter: {zoneTag: "my_zone_id"}) {
httpRequests1hGroups(limit: 100, filter: {datetime_geq: "%s", datetime_lt: "%s"}) {
uniq {
uniques
}
sum {
requests
}
}
}
}
}
""" % (start_time_str, end_time_str)

response = requests.post(
'https://api.cloudflare.com/client/v4/graphql',
headers=headers,
json={'query': data}
)

if response.status_code == 200:
data = response.json()
total_requests = data['data']['viewer']['zones'][0]['httpRequests1hGroups'][0]['sum']['requests']
unique_visitors = data['data']['viewer']['zones'][0]['httpRequests1hGroups'][0]['uniq']['uniques']

print("Total Requests:", total_requests)
print("Unique Visitors:", unique_visitors)
else:
print("Error:", response.status_code)
7 replies
CDCloudflare Developers
Created by [NODERS] Aleksandr on 4/23/2024 in #workers-help
parsing Unique Visitors and total requests
Thank you! I have error now
Time range can't be wider than 259200s, but it's 2592000s"
Time range can't be wider than 259200s, but it's 2592000s"
I need pay premium account for resolve this?
2 replies