robots.txt Parser API

Fetch and parse the robots.txt of any site into user-agent groups, allow/disallow rules and sitemaps, and test if a path is crawlable.

GETPOSThttps://apibox.io.vn/v1/robots-txt

Give any URL of a site in url; the API fetches /robots.txt from its origin and parses it into groups (user agents with their allow, disallow and crawl_delay rules) and the list of sitemaps. The response also tells whether the file exists, its HTTP status and the raw text (first 20,000 characters).

Add a path (for example /search) and optionally a user_agent (default *) to test whether that path may be crawled: the API picks the group matching the user agent (or *), applies the longest matching rule with * wildcards and $ end anchors, and returns allowed: true or false.

The robots.txt file is read up to 512 KB with a 10 second timeout. Only public http/https hosts are allowed.

Parameters

NameInTypeRequiredDefault
urlbody|querystringyesAny URL of the site; robots.txt is read from its origin (max 4096 characters).
pathbody|querystringnoPath to test, e.g. /search. When given, the response includes allowed.
user_agentbody|querystringno*User agent used for the path test, e.g. Googlebot.

Example

curl "https://apibox.io.vn/v1/robots-txt?url=https://github.com&path=/search&user_agent=Googlebot" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response

{
  "robots_url": "https://github.com/robots.txt",
  "status": 200,
  "exists": true,
  "groups": [
    {
      "user_agents": [
        "GPTBot",
        "OAI-SearchBot",
        "ChatGPT-User",
        "ClaudeBot"
      ],
      "allow": [
        "/*?tab=achievements&achievement=*",
        "..."
      ],
      "disallow": [
        "/account-login",
        "/copilot/",
        "/gist/",
        "/search$",
        "..."
      ],
      "crawl_delay": 1
    },
    {
      "user_agents": [
        "Bytespider"
      ],
      "allow": [],
      "disallow": [
        "/"
      ]
    },
    {
      "user_agents": [
        "*"
      ],
      "allow": [
        "/*?tab=achievements&achievement=*",
        "..."
      ],
      "disallow": [
        "/account-login",
        "/copilot/",
        "/gist/",
        "/search$",
        "..."
      ]
    }
  ],
  "sitemaps": [
    "https://github.com/sitemap_marketing.xml"
  ],
  "path": "/search",
  "user_agent": "Googlebot",
  "allowed": false,
  "raw": "# If you would like to crawl GitHub contact us via https://support.github.com?tags=dotcom-robots\n# We also provide an extensive API: https://docs.github.com\nSitemap: https://github.com/sitemap_marketing.xml\n\nUser-agent: GPTBot\n..."
}

Use cases

  • Check if Googlebot or another crawler may access a page
  • Find the sitemaps declared by a website
  • Make your own crawler or scraper respect robots.txt rules
  • Audit AI bot rules (GPTBot, ClaudeBot...) of a site

FAQ

How do I test if a URL is blocked by robots.txt?

Send url (the site), path (e.g. /private/page) and user_agent (e.g. Googlebot). The response contains allowed: true or false.

Are wildcards supported in rules?

Yes. * matches any characters and a trailing $ anchors the end of the path. The longest matching rule wins, and Allow wins a tie.

What if the site has no robots.txt?

The response has exists: false, the HTTP status, empty groups, and any tested path is reported as allowed.

Related APIs

Start with 1,000 free requests every month. Get free API key →