# Accept

**Kind:** Interface

**Source:** [`src/utils/accept.ts`](https://github.com/honojs/hono/blob/main/src/utils/accept.ts#L1)

**Part of:** [Utils](subsystem-src-utils)

`Accept` represents a parsed media type from an HTTP `Accept` header. It stores the media `type`, associated parameters, and the `q` quality value used when selecting a preferred response format.

## Properties

| Property | Type |
|---|---|
| `type` | `string` |
| `params` | `Record<string, string>` |
| `q` | `number` |

## Diagram

```mermaid
graph LR
  Header[HTTP Accept header] --> Accept[Accept]
  Accept --> Type[type: string]
  Accept --> Params[params: Record&lt;string, string&gt;]
  Accept --> Quality[q: number]
```

## Usage

```ts
import type { Accept } from "./utils/accept";

const acceptedType: Accept = {
  type: "application/json",
  params: {
    charset: "utf-8",
  },
  q: 1,
};

if (acceptedType.type === "application/json" && acceptedType.q > 0) {
  console.log("Return a JSON response");
}
```

## AI Coding Instructions

- Treat `type` as the parsed media type, such as `application/json` or `text/html`.
- Store media-type parameters in `params` as string key-value pairs.
- Use `q` when comparing acceptable response formats; higher values indicate higher preference.
- Preserve parsed parameter values as strings rather than coercing them to other types.
- Keep this interface aligned with the `Accept` header parsing and response content-negotiation code.
