# Identifiers

ModelSlugs and model numbers, what a merge does to them, and when a Product returns 404.

## A Product is its model number

A Product is one exact part at the manufacturer-SKU level.
Two graphics cards built on the same chipset with different part numbers are different Products, so the model number is what identifies one.

Model numbers are written inconsistently: Retailers disagree on case, spacing and punctuation for the same part.
DropHawk derives a **ModelSlug** from each model number, which is lowercase and contains only `a-z`, `0-9` and `-`:

| Model number | ModelSlug |
| --- | --- |
| `PRIME-RTX5080-O16G` | `prime-rtx5080-o16g` |
| `Deco X1500(1-pack)` | `deco-x1500-1-pack` |
| `U-PoE+` | `u-poe-plus` |

Most variations in case, spacing and punctuation fold into one ModelSlug, so `PRIME-RTX5080-O16G` and `prime rtx5080 o16g` name the same Product.
Not every difference folds away: `+` becomes `-plus-`, because `U-PoE`, `U-PoE+` and `U-PoE++` are three different parts.
So never decide for yourself that two model numbers are the same Product - ask, and compare the `model_slug` the API returns.

The ModelSlug is the Product's identity in this API and in DropHawk's own URLs.
Store `model_slug` from the response, and use it for every later request.

## Pass either form

`GET /v1/products/{identifier}` accepts a ModelSlug or a raw model number:

```sh
curl https://api.drophawk.net/v1/products/prime-rtx5080-o16g
curl https://api.drophawk.net/v1/products/PRIME-RTX5080-O16G
curl 'https://api.drophawk.net/v1/products/Deco%20X1500(1-pack)'
```

Each returns the Product it names, with its canonical `model_slug`.
Percent-encode a model number that contains a space, `#` or another character a URL path cannot carry.
A model number containing `/` cannot be sent this way at all, even percent-encoded, because a path segment cannot carry one: look the Product up by its ModelSlug instead.
An identifier can be at most 256 bytes.

DropHawk normalises the identifier itself, so do not build a ModelSlug in your own code: the rule lives in DropHawk's database, and a copy of it will eventually disagree.

## Merged Products

Occasionally one physical part ends up recorded as two Products, because two Retailers wrote its model number differently enough to escape normalisation (`CRUXTEC-DMF-02-BK` and `DMF-02-BK`).
When DropHawk merges them, one survives, and the other's identifiers lead to it.

Over HTTP, a request for the merged Product answers with a permanent redirect to the survivor:

```http
HTTP/1.1 301 Moved Permanently
Location: /v1/products/dmf-02-bk
```

`Location` is relative to `https://api.drophawk.net`.
Follow it (`curl -L` does), and if you stored the old ModelSlug, replace it with the survivor's.
The merged Product's price history moves to the survivor, so nothing is lost by following.

A Connect client gets no redirect: the response carries the surviving Product and `is_merged: true`.
A batch cannot redirect either, so each result of a batch says `is_merged` over HTTP/JSON too.
Either way, store the `model_slug` of the Product you got back.

## Unknown Products answer 404

A `404` with the reason `PRODUCT_NOT_FOUND` means no Product DropHawk currently lists has that identifier.
That covers a model number DropHawk has never seen and a Product it no longer lists.

A 404 says nothing about whether the part exists: DropHawk covers Australian Retailers only, and a part none of them sells is not in the catalogue.
See [What DropHawk does not know](https://developers.drophawk.net/guides/catalogue-limits.md).

An identifier that is supplied but cannot name any Product - longer than 256 bytes, or containing control characters - answers `400` with `INVALID_IDENTIFIER` instead.
A request with no identifier at all (`/v1/products`) names no endpoint, and answers `404` with `NOT_FOUND`.
