Skip to main content

HTTP Accept Content Negotiation API

REAL DATA

Parse RFC 9110 Accept media ranges and deterministically select the best available representation using specificity, parameters and q weights.

Authoritative reference data or standards computation

Base URL
/api/content-negotiation
Capabilities
2 routes
Last updated
July 29, 2026
Data source

GET /api/content-negotiation/parse

Live requestRuns against the public API
No key required
GET/api/content-negotiation/parse?accept=text%2Fhtml%2C+application%2Fjson%3Bq%3D0.8

Request parameters

Accept field with 1–32 media ranges.

Advanced response options4 options

Return only these fields (comma-separated). Mutually exclusive with 'exclude'.

Return all fields except these (comma-separated).

Pretty-print the JSON response.

Drop the envelope: return the raw array/object without data/meta wrapper.

Response

Example parameters are ready. Send the request to inspect the live response.

Route reference

Code samples Ready-to-copy requests in 4 languages
Choose a code sample language
curl "https://randomapi.dev/api/content-negotiation/parse?accept=text%2Fhtml%2C%20application%2Fjson%3Bq%3D0.8"
const res = await fetch("https://randomapi.dev/api/content-negotiation/parse?accept=text%2Fhtml%2C%20application%2Fjson%3Bq%3D0.8");
const { data, meta } = await res.json();
import requests

data = requests.get("https://randomapi.dev/api/content-negotiation/parse?accept=text%2Fhtml%2C%20application%2Fjson%3Bq%3D0.8").json()["data"]
$json = json_decode(file_get_contents(
  "https://randomapi.dev/api/content-negotiation/parse?accept=text%2Fhtml%2C%20application%2Fjson%3Bq%3D0.8"
), true);
$data = $json["data"];
Parameters Route-specific request inputs 1
accept string required

Accept field with 1–32 media ranges.

allowed: 3 – 2048
example: accept=text/html, application/json;q=0.8
Universal parameters Shared response and formatting options 4
fields list

Return only these fields (comma-separated). Mutually exclusive with 'exclude'.

example: fields=accept,count
exclude list

Return all fields except these (comma-separated).

example: exclude=ranges
pretty boolean

Pretty-print the JSON response.

default: false
example: pretty=true
unwrap boolean

Drop the envelope: return the raw array/object without data/meta wrapper.

default: false
example: unwrap=true
Response schema Fields returned in each record 3
accept string

Input Accept field value.

example: text/html, application/json;q=0.8

count integer

Number of parsed media ranges.

example: 2

ranges object[]

Ranges with normalized type/subtype, parameters, q, specificity and original order.

example: [{"mediaRange":"text/html","type":"text","subtype":"html","parameters":[],"q":1,"specificity":2,"order":0}]

Documented examples

Build-generated requests and complete responses
2
HTML preferred over weighted JSON
GET /api/content-negotiation/parse?accept=text%2Fhtml%2C%20application%2Fjson%3Bq%3D0.8
{
  "data": {
    "accept": "text/html, application/json;q=0.8",
    "count": 2,
    "ranges": [
      {
        "mediaRange": "text/html",
        "type": "text",
        "subtype": "html",
        "parameters": [],
        "q": 1,
        "specificity": 2,
        "order": 0
      },
      {
        "mediaRange": "application/json;q=0.8",
        "type": "application",
        "subtype": "json",
        "parameters": [],
        "q": 0.8,
        "specificity": 2,
        "order": 1
      }
    ]
  },
  "meta": {
    "endpoint": "content-negotiation",
    "route": "/parse",
    "params": {
      "accept": "text/html, application/json;q=0.8"
    },
    "generatedAt": "2026-07-29T08:13:22.000Z"
  }
}
Wildcard with a quoted profile
GET /api/content-negotiation/parse?accept=application%2Fjson%3Bprofile%3D%22compact%22%2C%20*%2F*%3Bq%3D0.1
{
  "data": {
    "accept": "application/json;profile=\"compact\", */*;q=0.1",
    "count": 2,
    "ranges": [
      {
        "mediaRange": "application/json;profile=compact",
        "type": "application",
        "subtype": "json",
        "parameters": [
          {
            "name": "profile",
            "value": "compact"
          }
        ],
        "q": 1,
        "specificity": 2,
        "order": 0
      },
      {
        "mediaRange": "*/*;q=0.1",
        "type": "*",
        "subtype": "*",
        "parameters": [],
        "q": 0.1,
        "specificity": 0,
        "order": 1
      }
    ]
  },
  "meta": {
    "endpoint": "content-negotiation",
    "route": "/parse",
    "params": {
      "accept": "application/json;profile=\"compact\", */*;q=0.1"
    },
    "generatedAt": "2026-07-29T08:13:22.000Z"
  }
}

GET /api/content-negotiation/select

Live requestRuns against the public API
No key required
GET/api/content-negotiation/select?accept=application%2Fjson%2Ctext%2Fhtml%3Bq%3D0.8&available=text%2Fhtml%2Capplication%2Fjson

Request parameters

Accept field with 1–32 weighted media ranges.

Comma-separated list of 1–32 concrete media types offered by the server.

Advanced response options4 options

Return only these fields (comma-separated). Mutually exclusive with 'exclude'.

Return all fields except these (comma-separated).

Pretty-print the JSON response.

Drop the envelope: return the raw array/object without data/meta wrapper.

Response

Example parameters are ready. Send the request to inspect the live response.

Route reference

Code samples Ready-to-copy requests in 4 languages
Choose a code sample language
curl "https://randomapi.dev/api/content-negotiation/select?accept=application%2Fjson%2Ctext%2Fhtml%3Bq%3D0.8&available=text%2Fhtml%2Capplication%2Fjson"
const res = await fetch("https://randomapi.dev/api/content-negotiation/select?accept=application%2Fjson%2Ctext%2Fhtml%3Bq%3D0.8&available=text%2Fhtml%2Capplication%2Fjson");
const { data, meta } = await res.json();
import requests

data = requests.get("https://randomapi.dev/api/content-negotiation/select?accept=application%2Fjson%2Ctext%2Fhtml%3Bq%3D0.8&available=text%2Fhtml%2Capplication%2Fjson").json()["data"]
$json = json_decode(file_get_contents(
  "https://randomapi.dev/api/content-negotiation/select?accept=application%2Fjson%2Ctext%2Fhtml%3Bq%3D0.8&available=text%2Fhtml%2Capplication%2Fjson"
), true);
$data = $json["data"];
Parameters Route-specific request inputs 2
accept string required

Accept field with 1–32 weighted media ranges.

allowed: 3 – 2048
example: accept=application/json, text/html;q=0.8
available string required

Comma-separated list of 1–32 concrete media types offered by the server.

allowed: 3 – 2048
example: available=text/html, application/json
Universal parameters Shared response and formatting options 4
fields list

Return only these fields (comma-separated). Mutually exclusive with 'exclude'.

example: fields=accept,available
exclude list

Return all fields except these (comma-separated).

example: exclude=matchedParameters
pretty boolean

Pretty-print the JSON response.

default: false
example: pretty=true
unwrap boolean

Drop the envelope: return the raw array/object without data/meta wrapper.

default: false
example: unwrap=true
Response schema Fields returned in each record 9
accept string

Input Accept field value.

example: application/json, text/html;q=0.8

available string[]

Parsed concrete representations in supplied order.

example: ["text/html","application/json"]

matched boolean

Whether at least one representation has a controlling range with q above zero.

example: true

selected string nullable

Selected canonical media type, or null when none is acceptable.

example: application/json

selectedIndex integer nullable

Zero-based position in available, or null when unmatched.

example: 1

matchedRange string nullable

Controlling canonical Accept media range, or null.

example: application/json

q float nullable

Quality assigned by the controlling range, or null.

example: 1

specificity integer nullable

Controlling wildcard specificity: 0 for */*, 1 for type/*, 2 for exact.

example: 2

matchedParameters integer nullable

Number of media parameters on the controlling range, or null.

example: 0

Documented examples

Build-generated requests and complete responses
2
Choose weighted JSON
GET /api/content-negotiation/select?accept=application%2Fjson%2Ctext%2Fhtml%3Bq%3D0.8&available=text%2Fhtml%2Capplication%2Fjson
{
  "data": {
    "accept": "application/json,text/html;q=0.8",
    "available": [
      "text/html",
      "application/json"
    ],
    "matched": true,
    "selected": "application/json",
    "selectedIndex": 1,
    "matchedRange": "application/json",
    "q": 1,
    "specificity": 2,
    "matchedParameters": 0
  },
  "meta": {
    "endpoint": "content-negotiation",
    "route": "/select",
    "params": {
      "accept": "application/json,text/html;q=0.8",
      "available": "text/html,application/json"
    },
    "generatedAt": "2026-07-29T08:13:22.000Z"
  }
}
Specific exclusion beats a broad wildcard
GET /api/content-negotiation/select?accept=*%2F*%3Bq%3D1%2Capplication%2Fjson%3Bq%3D0&available=application%2Fjson%2Ctext%2Fplain
{
  "data": {
    "accept": "*/*;q=1,application/json;q=0",
    "available": [
      "application/json",
      "text/plain"
    ],
    "matched": true,
    "selected": "text/plain",
    "selectedIndex": 1,
    "matchedRange": "*/*;q=1",
    "q": 1,
    "specificity": 0,
    "matchedParameters": 0
  },
  "meta": {
    "endpoint": "content-negotiation",
    "route": "/select",
    "params": {
      "accept": "*/*;q=1,application/json;q=0",
      "available": "application/json,text/plain"
    },
    "generatedAt": "2026-07-29T08:13:22.000Z"
  }
}

About this API

Coverage & behavior

Strict, bounded parsing and selection for the HTTP Accept request field defined by RFC 9110. The parser understands exact media types, type/* and */* wildcards, media parameters, quoted parameter values and quality weights from 0 through 1 with no more than three decimal places. It accepts at most 32 comma-separated entries and rejects malformed or duplicate parameters.

/select compares an Accept value with concrete available representations. For each representation, the most specific matching range controls its quality: exact type/subtype beats a type wildcard, which beats */*; more matching media parameters break a specificity tie; earlier field order breaks the remaining tie. This means a specific q=0 exclusion is not overridden by a broader positive wildcard.

Among acceptable representations, selection is deterministic: quality first, then controlling specificity, matched parameter count, Accept order and finally available-list order. Type, subtype and charset names compare case-insensitively; other parameter values compare exactly because their sensitivity is defined by each media type. The endpoint does not inspect response bodies, infer filename extensions or implement other negotiation dimensions such as language or content coding.

Use it for

  • Test server representation selection against complex Accept field values
  • Explain why a specific media type is excluded despite a broader wildcard
  • Validate q weights, wildcards and quoted media parameters in client fixtures

Frequently asked questions

How does the API rank matching media ranges?

For each available representation, the most specific matching range controls its q value. Exact type/subtype beats type/*, which beats /, and matching media parameters add specificity.

Can a specific q=0 exclusion override a wildcard?

Yes. If application/json;q=0 is the controlling exact range, a broader /;q=1 does not make JSON acceptable.

Are ties deterministic?

Yes. Selection uses q, specificity, parameter count, Accept order and then available-list order, in that order.

Does it negotiate language or compression?

No. This endpoint handles media types from Accept only; it does not process Accept-Language, Accept-Encoding or response bodies.

Standards & references