# Radar One Question

URL: /docs/experiments/radar-one-question
> Ask Cloudflare Radar one fact about a domain rank or ASN org/location - Internet intelligence API demo for agents
Tags: network, radar, asn, domain-rank, internet-intelligence, api
Markdown: /llms.mdx/experiments/radar-one-question/content.md



One-shot **Cloudflare Radar** lookup for agents and tools: ask for a domain's global rank **or** an ASN's organization and location. Useful as an Internet-intelligence building block without pulling the full Radar API surface.

## API Reference [#api-reference]

### `GET /radar` [#get-radar]

Returns one fact from Cloudflare Radar: domain ranking or ASN details.

**Parameters**

Provide **one** of:

* **`domain`** `string` - Domain name (e.g., `cloudflare.com`)
* **`asn`** `string` - ASN number with or without `AS` prefix (e.g., `13335` or `AS13335`)

**Example request (domain)**

```bash
curl https://radar-one-question.example.workers.dev/radar?domain=cloudflare.com
```

**Example response**

```json
{
  "type": "domain",
  "target": "cloudflare.com",
  "fact": "Domain rank in global top domains",
  "ranking": 150
}
```

**Example request (ASN)**

```bash
curl https://radar-one-question.example.workers.dev/radar?asn=13335
```

**Example response**

```json
{
  "type": "asn",
  "target": "AS13335",
  "fact": "ASN owned by Cloudflare, Inc. (CLOUDFLARENET) in US"
}
```

**Error responses**

* `400` - Missing both `domain` and `asn`, or both provided
* `502` - Radar API error or unreachable

**Error codes**

* `MISSING_PARAMETER` - Neither domain nor asn provided
* `INVALID_PARAMETER` - Both domain and asn provided
* `RADAR_ERROR` - Cloudflare Radar API returned an error

## Use Cases [#use-cases]

* Domain reputation and ranking lookups from the edge
* ASN ownership and geolocation queries
* Network research tools and dashboards
* Educational demos of Cloudflare Radar capabilities
* Threat intelligence and abuse investigation workflows

## Limitations [#limitations]

* Returns one fact per request (either domain ranking or ASN details)
* Domain ranking data reflects Cloudflare Radar's public dataset
* ASN details depend on Radar's entity database
* No persistent storage or caching
* Rate limits determined by Cloudflare Radar API

## Use in your project [#use-in-your-project]

<UseInYourProject experiment="radar-one-question" platform="[&#x22;Fetch API&#x22;, &#x22;Cloudflare Radar API&#x22;]" files="[&#x22;src/lib/radar.ts&#x22;, &#x22;examples/usage.ts&#x22;]" sources="[{&#x22;path&#x22;:&#x22;src/lib/radar.ts&#x22;,&#x22;title&#x22;:&#x22;radar.ts&#x22;,&#x22;lang&#x22;:&#x22;ts&#x22;,&#x22;code&#x22;:&#x22;export async function getRadarFact(\n  domain?: string,\n  asn?: string\n): Promise<{ type: string; target: string; fact: string; ranking?: number }> {\n  if (domain) {\n    const response = await fetch(\n      `https://api.cloudflare.com/client/v4/radar/ranking/domain/${encodeURIComponent(domain)}`\n    );\n\n    if (!response.ok) {\n      throw new Error(`Radar API error: ${response.status}`);\n    }\n\n    const data = (await response.json()) as {\n      success: boolean;\n      result?: { rank: number };\n    };\n\n    if (!data.success || !data.result) {\n      throw new Error(\&#x22;Radar API returned unsuccessful response\&#x22;);\n    }\n\n    return {\n      type: \&#x22;domain\&#x22;,\n      target: domain,\n      fact: `Domain rank in global top domains`,\n      ranking: data.result.rank,\n    };\n  }\n\n  if (asn) {\n    const asnNumber = asn.startsWith(\&#x22;AS\&#x22;) ? asn.substring(2) : asn;\n    const response = await fetch(\n      `https://api.cloudflare.com/client/v4/radar/entities/asns/${asnNumber}`\n    );\n\n    if (!response.ok) {\n      throw new Error(`Radar API error: ${response.status}`);\n    }\n\n    const data = (await response.json()) as {\n      success: boolean;\n      result?: { asn: { name: string; orgName: string; country: string } };\n    };\n\n    if (!data.success || !data.result) {\n      throw new Error(\&#x22;Radar API returned unsuccessful response\&#x22;);\n    }\n\n    const { name, orgName, country } = data.result.asn;\n\n    return {\n      type: \&#x22;asn\&#x22;,\n      target: `AS${asnNumber}`,\n      fact: `ASN owned by ${orgName} (${name}) in ${country}`,\n    };\n  }\n\n  throw new Error(\&#x22;No domain or ASN provided\&#x22;);\n}&#x22;},{&#x22;path&#x22;:&#x22;examples/usage.ts&#x22;,&#x22;title&#x22;:&#x22;usage.ts&#x22;,&#x22;lang&#x22;:&#x22;ts&#x22;,&#x22;code&#x22;:&#x22;/**\n * Minimal paste example for docs (\&#x22;Use in your project\&#x22;).\n * Not part of the Worker runtime — copy into your own project.\n */\nimport { getRadarFact } from \&#x22;../src/lib/radar\&#x22;;\n\nexport default {\n  async fetch(request: Request): Promise<Response> {\n    const url = new URL(request.url);\n    const domain = url.searchParams.get(\&#x22;domain\&#x22;) ?? undefined;\n    const asn = url.searchParams.get(\&#x22;asn\&#x22;) ?? undefined;\n\n    if (!domain && !asn) {\n      return Response.json(\n        { error: \&#x22;Missing domain or asn\&#x22;, code: \&#x22;MISSING_PARAMETER\&#x22; },\n        { status: 400 }\n      );\n    }\n\n    if (domain && asn) {\n      return Response.json(\n        { error: \&#x22;Provide only one of domain or asn\&#x22;, code: \&#x22;INVALID_PARAMETER\&#x22; },\n        { status: 400 }\n      );\n    }\n\n    const result = await getRadarFact(domain, asn);\n    return Response.json(result);\n  },\n};&#x22;}]" />

## Deployment [#deployment]

<Steps>
  <Step>
    ### Deploy to Cloudflare Workers [#deploy-to-cloudflare-workers]

    [![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/shrinathsnayak/cloudflare-experiments/tree/main/apps/experiments/radar-one-question)

    No bindings or secrets required.
  </Step>

  <Step>
    ### Test your deployment [#test-your-deployment]

    ```bash
    curl "https://radar-one-question.your-subdomain.workers.dev/radar?domain=cloudflare.com"
    ```

    Or query an ASN:

    ```bash
    curl "https://radar-one-question.your-subdomain.workers.dev/radar?asn=13335"
    ```
  </Step>
</Steps>

## Local Development [#local-development]

```bash
cd apps/experiments/radar-one-question
npm install
npm run dev
```

The Worker runs at `http://localhost:8787`.

**Test locally**

```bash
curl "http://localhost:8787/radar?domain=cloudflare.com"
```

## Cloudflare Features Used [#cloudflare-features-used]

* [Workers](https://developers.cloudflare.com/workers/) - Edge compute platform
* [Cloudflare Radar API](https://developers.cloudflare.com/radar/) - Internet intelligence and insights

## Next Steps [#next-steps]

<Cards>
  <Card title="URL DNS Lookup" href="/experiments/url-dns-lookup" description="DNS records via DoH" />

  <Card title="Whereami" href="/experiments/whereami" description="Request geolocation metadata" />

  <Card title="Email Auth Checker" href="/experiments/email-auth-checker" description="SPF, DMARC, and DKIM analysis" />
</Cards>
