developers.cloudflare.com
Open in
urlscan Pro
104.16.5.189
Public Scan
URL:
https://developers.cloudflare.com/radar/get-started/first-request/
Submission: On August 17 via api from US — Scanned from DE
Submission: On August 17 via api from US — Scanned from DE
Form analysis
0 forms found in the DOMText Content
Skip to content Cloudflare Docs SearchK Product directory Learning paths Status Support Log in GitHub Twitter YouTube Select theme DarkLightAuto Radar * Overview * Concepts * Overview * Aggregation intervals * Bot classes * Confidence levels * Normalization methods * Get started * Overview * Make your first API request * Make comparisons * Radar API Error Codes * Share a Radar chart * Configure alerts * Investigate * Overview * HTTP requests * Netflows * Application layer attacks * BGP anomalies Beta * DNS * Domains ranking * Network layer attacks * Outages * URL Scanner * Reference * Overview * Quarterly DDoS threat reports * API reference ↗ API * Glossary * Changelog Product directory Learning paths Status Support Log in GitHub Twitter YouTube Select theme DarkLightAuto On this page Overview * Overview * Example using cURL * Use Python * Notebooks * Next steps ON THIS PAGE * Overview * Example using cURL * Use Python * Notebooks * Next steps 1. Products 2. … 3. Radar 4. Get started 5. Make your first API request MAKE YOUR FIRST API REQUEST To make your first request to Cloudflare’s Radar API, you must obtain your API token first. Create a Custom Token, with User > User Details in the Permissions group, and select Read as the access level. Once you have the token, you are ready to make your first request to Radar’s API at https://api.cloudflare.com/client/v4/radar/. EXAMPLE USING CURL In the following example, we will access the global percentage distribution of device types (like mobile and desktop traffic) for the last seven days. For more information, refer to Get device types summary endpoint: Terminal window curl "https://api.cloudflare.com/client/v4/radar/http/summary/device_type?dateRange=7d&format=json" \ --header "Authorization: Bearer <API_TOKEN>" A successful response will look similar to the following: { "success": true, "errors": [], "result": { "summary_0": { "desktop": "58.223483", "mobile": "41.725833", "other": "0.050684" }, "meta": { "dateRange": { "startTime": "2022-10-26T14:00:00Z", "endTime": "2022-11-02T14:00:00Z" }, "normalization": "PERCENTAGE", ... } } } This response means that 41% of the requests are classified as coming from mobile devices, while 58% are desktop traffic. Note Cloudflare Radar attempts to provide trends and insights into general Internet usage, using the traffic that goes through Cloudflare infrastructure. As such, Cloudflare Radar only provides data on traffic coming from end-users, unless otherwise specified (for example, origin fetches are excluded). The previous example returns all traffic from bots and humans. However, you can access just the traffic classified as coming from humans (the default in Cloudflare Radar) by adding botClass=LIKELY_HUMAN. You can also access traffic coming only from bots with botClass=LIKELY_AUTOMATED (refer to bot classes for more information). For example: Terminal window curl "https://api.cloudflare.com/client/v4/radar/http/summary/device_type?dateRange=7d&botClass=LIKELY_AUTOMATED&format=json" \ --header "Authorization: Bearer <API_TOKEN>" Running the above, can you find any differences between both in the distribution of mobile versus desktop traffic? The result.meta property The result.meta property in the response includes metadata about the current request. In the example above, meta.dateRange returns the date range specified in the query, while meta.normalization returns the type of normalization applied to the data (refer to Normalization methods for more information). When querying for time series, result.meta will also include the returned aggregation interval in meta.aggInterval. When present, meta.confidenceInfo.level will also provide an indication of how much confidence Cloudflare has in the data. Confidence levels are affected either by internal issues affecting data quality or by Cloudflare not having sufficient data for a given location or Autonomous System (AS). In these cases, confidence level will be below 5 (refer to Confidence levels for more information). USE PYTHON Python has become one of the standard languages in data analysis. Here is a quick example on how to chart the same data using Requests and Pandas libraries. Here, we are using format=csv in the parameters to make it easier for Pandas to import. import io import requests import pandas as pd cf_api_url = "https://api.cloudflare.com/client/v4" params = "dateRange=7d&format=csv" my_token = "xxx" # TODO replace r = requests.get(f"{cf_api_url}/radar/http/summary/device_type?{params}", headers={"Authorization": f"Bearer {my_token}"}) df = pd.read_csv(io.StringIO(r.text)) df.plot(kind="bar", stacked=True) NOTEBOOKS A notebook is a web-based interactive computing application, where text, code, and code outputs, like charts, can be combined into a single document. Refer to Radar’s companion colaboratory notebook for more examples on how the API can be used in your own projects. NEXT STEPS Refer to Make comparisons to learn how to compare data. Edit page Cloudflare DashboardDiscordCommunityLearning CenterSupport Portal Cookie Preferences OUR SITE USES COOKIES Like most websites, we use cookies to make our site work the way you expect it to, improve your experience on our site, analyze site usage, and assist in our marketing efforts. By choosing "Accept All Cookies", you agree to the storing of all categories of cookies on your device. If you wish to accept or reject some categories of cookies, please click “Cookie Preferences.” Cookie Preferences Reject All Accept All Cookies YOUR COOKIE OPTIONS Cloudflare uses four types of cookies as described below. You can decide which categories of cookies you wish to accept to improve your experience on our website. To learn more about the cookies we use on our site, please read our Cookie Policy. Cloudflare's Cookie Policy Allow All MANAGE CONSENT PREFERENCES STRICTLY NECESSARY COOKIES Always Active Strictly Necessary cookies are essential to our website functioning as expected. You cannot turn off Strictly Necessary cookies because they are required to deliver security, enable core site functionality, and help you use our site's features and services as you would expect (including remembering your cookie consent preferences). Cloudflare does not use these cookies to track individuals across websites. Cookies Details FUNCTIONAL COOKIES Functional Cookies Functional cookies allow us to remember choices you make about the kind of experience you want on our site and to provide you with a more personalized experience. For example, a functional cookie is required to remember which language you prefer. Cookies Details PERFORMANCE COOKIES Performance Cookies Performance cookies help us learn how you use our website to help improve its performance and design. These cookies provide us with aggregated statistical information such as number of page visits, page load speeds, how long a user spends on a particular page, and the types of browsers or devices used to access our site. Cookies Details TARGETING COOKIES Targeting Cookies We use Targeting cookies to deliver advertisements relevant to you and your interests when you visit other websites that host advertisements. Cookies Details Back Button COOKIE LIST Search Icon Filter Icon Clear checkbox label label Apply Cancel Consent Leg.Interest checkbox label label checkbox label label checkbox label label Reject All Confirm My Choices