# How to write a scraper user agent that names you | Spider

What a server sees in your scraper's User-Agent header, how to build one with a name, a version and a contact, and one dated request that shows it arriving.

Canonical: https://spider.cloud/learn/user-agent/

A scraper's user agent is the User-Agent header it sends with each request, the one line that tells a server which software is asking. Give it your scraper's name and version first, then a URL and a contact address in a comment, as in `examplebot/1.0 (+https://example.com/bot; bot@example.com)`.

That is the whole format. Every request in a [web scraping](/web-scraping/) job carries this one line, so settle it before the first request goes out. Below are the rules each part comes from, what a test server received when we sent that exact string on 2026-11-20, and what to put on the page the URL points to.

## What the header is made of

The rules sit in RFC 9110, the HTTP standard. Its grammar for the field is one line, `User-Agent = product *( RWS ( product / comment ) )`, and the prose explains it: "The User-Agent field value consists of one or more product identifiers, each followed by zero or more comments". A product is a name with an optional version after a slash. A comment is any text inside round brackets.

So a header has two kinds of parts. The product, `examplebot/1.0`, is the part a program matches against. The comment, `(+https://example.com/bot; bot@example.com)`, is the part a person reads. MDN's reference describes the same layout as `<product> / <product-version> <comment>` and says the comment holds "Zero or more comments containing more details."

The standard also says what does not belong. RFC 9110 states that "a sender MUST NOT generate advertising or other nonessential information within the product identifier." A tagline, a list of features or a marketing URL in the product part breaks that rule. Put the URL in the comment, where readers expect it.

This clip builds one User-Agent string part by part, then checks what an echo page received.

How to write a scraper's User-Agent. 54 s, no sound. The words are on screen, and the captions button shows them at your own text size.

Read the transcript

How to write a scraper's User-Agent. A name, a version, a URL and a contact, in one line.

Start with a product: your scraper's name, a slash and a version. The line so far reads examplebot/1.0. examplebot is the product token: the name a site sees and matches. 1.0 is the version: changes when the scraper's behaviour does.

Add a comment in brackets: a URL about the bot and a contact address. The whole line reads examplebot/1.0 (+https\://example.com/bot; bot\@example.com). +https\://example.com/bot is the URL, in the comment: a page that says what the scraper does. bot\@example.com is the contact, in the comment: reaches a person who can stop the job.

Send it to an echo page once and check that it arrived as written. Sent: examplebot/1.0 (+https\://example.com/bot; bot\@example.com). The test server received: examplebot/1.0 (+https\://example.com/bot; bot\@example.com). Compared character by character, the two are the same value: it arrived as written. 58 characters sent. 58 arrived the same.

A site can only act on a name that is yours. Other choices: User-Agent: ?. unset: The library's name, not yours. browser: Reads as a person. yours: A site can match it.

Read the full page. The page is at spider.cloud/learn/user-agent.

## Write one for your scraper

Work through four choices, in this order.

1. Pick a product token. This is the name a site owner will see in their logs and write into robots.txt. RFC 9309 limits it to letters, the `_` character and hyphens, and says that for HTTP "the product token SHOULD be a substring in the User-Agent header." Choose a name nobody else uses, such as your project name followed by `bot`, and keep it the same for the life of the project.
2. Add a version after a slash. Bump it when the scraper's behaviour changes, so an owner who sees trouble in a log can tell which build caused it. RFC 9110 asks that the version part hold nothing but a version, so that "successive versions of the same product name ought to differ only in the product-version portion".
3. Add a URL in the comment. Point it at a page you control that says what the scraper does. RFC 9309 asks for the same thing: "The identification string SHOULD describe the purpose of the crawler." The leading `+` before the URL is a common convention and costs nothing.
4. Add a contact in the comment. An email address that reaches a person who can stop the job. Use a role address such as `bot@` or `crawler@` on your own domain, not someone's personal inbox, because the header is visible to every server you visit.

Keep it short. RFC 9110 warns that "Overly long and detailed User-Agent field values increase request latency". One product and one comment are enough.

The same RFC describes a second header for the contact. It says that "A robotic user agent SHOULD send a valid From header field so that the person responsible for running the robot can be contacted if problems occur on servers". If your HTTP client lets you set headers, send `From: bot@example.com` as well. With the Spider API, the `headers` field sends it, as in `"headers": {"From": "bot@example.com"}`. The reference describes that field as "HTTP headers to send with every request, as a map of name to value." The address in the User-Agent comment is the one that survives in logs that record only that line.

## What a test server received

The target here is a public practice page that echoes back whatever User-Agent header reaches it. The `user_agent` field in the body sets that header. Export your key as `SPIDER_API_KEY` before you paste the command.

```bash
curl -s https://api.spider.cloud/scrape \
  -H "Authorization: Bearer $SPIDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://httpbin.org/user-agent", "request": "http", "return_format": "raw", "user_agent": "examplebot/1.0 (+https://example.com/bot; bot@example.com)"}'
```

The echo page answered at 15:39 UTC on 2026-11-20. One page came back with status 200 and no error, and this is its whole `content` field.

```json
{
  "user-agent": "examplebot/1.0 (+https://example.com/bot; bot@example.com)"
}
```

The string arrived as written, with the brackets, the plus sign, the semicolon and the address intact. That is the check worth doing before any real job. Point your scraper at an echo page once, read what came back, and confirm the server sees the name and contact you meant to send. A typo here means every site you visit logs the typo.

Try it with your own name and address in place of `examplebot` and `bot@example.com`.

## When you leave it unset

Most HTTP libraries send a User-Agent of their own when you set none, usually the library's name and version. That tells a site which library you use and nothing about who you are. An API you call may set the header for you, so read its reference. With the Spider API, set `user_agent` on every request when you want site owners to see your name, as the run above did.

## Why not copy a browser's string

A browser's header is long and starts with `Mozilla/5.0`. MDN gives the reason for that token: "For historical reasons, almost every browser today sends it." Copying the whole string into a scraper makes your traffic look like a person reading the site.

RFC 9110 says what that does: "If a user agent masquerades as a different user agent, recipients can assume that the user intentionally desires to see responses tailored for that identified user agent". The site may send you a layout built for that browser. And it loses the one way it had to tell your requests apart from its readers, so it can neither apply the robots.txt group written for you nor email you when your request rate is too high.

Some crawlers keep a browser-style shell and add their own name inside it. RFC 9309 gives one as its example, `Mozilla/5.0 (compatible; ExampleBot/0.1; https://www.example.com/bot.html)`. That form still names the client and still carries a URL, which is what matters. A plain `examplebot/1.0` is easier to read and easier to match.

## Make the name mean something

A name is only useful if the site can act on it.

Read robots.txt with the same token you send. A site that writes `User-agent: examplebot` has written rules for you, and the [robots.txt page](/learn/robots-txt/) explains how to find that group and apply it. If you change the token in your header, change it in your robots.txt matching too.

Put real content on the page your URL points to. Say in a few lines what the scraper collects and why, how often it visits, the robots.txt token that controls it, and the address to write to. An owner who arrives there from a log line is deciding whether to block you or let you continue, and a clear page helps them decide.

Answer the mail. A contact nobody reads is worse than none, because it tells the owner you are not listening. When someone asks you to slow down or stop, do it, and reply to say so. If a site's terms forbid automated access, a polite user agent does not change that. Ask the owner for permission instead.

## Do this, avoid this

### Do this

- Send a User-Agent with your own product token, a version, a URL and a contact address.
- Fetch an echo page once and check the header arrived exactly as you wrote it.
- Use the same token in your header and when you match robots.txt groups.
- Publish a short page at the URL that says what the scraper does and how to reach you.
- Slow down or stop when an owner writes to the address, and reply.

### Avoid this

- Leaving the header unset on a job that site owners should be able to recognise.
- Copying a browser's string so the scraper reads as a person.
- Putting a personal inbox in a header every server can read.
- Changing the token between runs to land in a looser robots.txt group.

Before your first real job, send the echo request above with your own token and address in it, and read the line that comes back. If it is not exactly what you typed, fix that first.

## Sources

1. [RFC 9110, HTTP Semantics, sections 10.1.2 and 10.1.5, IETF, June 2022](https://www.rfc-editor.org/rfc/rfc9110.html) Read November 20, 2026
2. [RFC 9309, Robots Exclusion Protocol, section 2.2.1, IETF, September 2022](https://www.rfc-editor.org/rfc/rfc9309.html) Read November 20, 2026
3. [MDN Web Docs, User-Agent header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/User-Agent) Read November 20, 2026
4. [Spider OpenAPI file, the user_agent and headers parameters](https://spider.cloud/openapi.yaml) Read November 20, 2026
