# Reference verification

> Draft

`POST https://paperpurr.com/v1/citations/verify`

Check each reference against Crossref and OpenAlex and flag whether it matches, differs or can’t be found.

## Body parameters

- `references` (string[], required) — 1–20 items, each a full reference of up to 2000 characters, in any style (APA, MLA, IEEE, GB/T 7714 and so on).

## Examples

curl:

```bash
curl -X POST "https://paperpurr.com/v1/citations/verify" \
  -H "Authorization: Bearer $PAPERPURR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"references":["Smith, J. (2020). Title. Journal, 12(3), 45-67.","Lee, K. (2018). Writing with sources. Academic Press.","张三. 学术写作导论[M]. 北京: 高等教育出版社, 2019."]}'
```

Python:

```python
import os
import requests

r = requests.post(
    "https://paperpurr.com/v1/citations/verify",
    headers={"Authorization": f"Bearer {os.environ['PAPERPURR_API_KEY']}"},
    json={
        "references": [
            "Smith, J. (2020). Title. Journal, 12(3), 45-67.",
            "Lee, K. (2018). Writing with sources. Academic Press.",
            "张三. 学术写作导论[M]. 北京: 高等教育出版社, 2019."
        ]
    },
)
print(r.json())
```

JS:

```javascript
const r = await fetch("https://paperpurr.com/v1/citations/verify", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.PAPERPURR_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "references": [
      "Smith, J. (2020). Title. Journal, 12(3), 45-67.",
      "Lee, K. (2018). Writing with sources. Academic Press.",
      "张三. 学术写作导论[M]. 北京: 高等教育出版社, 2019."
    ]
  }),
});
console.log(await r.json());
```

## Response

200:

```json
{
  "results": [
    {
      "index": 0,
      "status": "matched",
      "match": {
        "title": "Title",
        "authors": [
          "J. Smith"
        ],
        "year": 2020,
        "venue": "Journal",
        "doi": "10.1234/journal.2020.045",
        "url": "https://doi.org/10.1234/journal.2020.045",
        "source": "crossref"
      }
    },
    {
      "index": 1,
      "status": "mismatch",
      "diffs": [
        {
          "field": "year",
          "ours": "2018",
          "found": "2019"
        }
      ],
      "match": {
        "title": "Writing with Sources",
        "authors": [
          "K. Lee"
        ],
        "year": 2019,
        "venue": "Academic Press",
        "doi": "10.5555/wws.2019",
        "url": "https://doi.org/10.5555/wws.2019",
        "source": "crossref"
      }
    },
    {
      "index": 2,
      "status": "skipped",
      "reason": "cjk"
    }
  ],
  "usage": {
    "units": 2,
    "remaining": 495
  },
  "request_id": "req_51d0c8aa3e9f4b2c7d16a0e8"
}
```

400:

```json
{
  "error": {
    "type": "invalid_request_error",
    "code": "invalid_parameter",
    "message": "references 要是非空的字符串数组",
    "param": "references",
    "request_id": "req_6a2f90d4e1b7c3a85d02f9e4"
  }
}
```

402:

```json
{
  "error": {
    "type": "billing_error",
    "code": "insufficient_balance",
    "message": "本月试用额度不足：这次需要 3 单位，剩余 2",
    "param": null,
    "request_id": "req_2c7e1f0a9b3d45e6c8a1f7d2"
  }
}
```

- `results` (object[], required) — One per item in `references`, in order
  - `index` (integer, required) — Position in `references`, starting at 0
  - `status` (string, required) — `matched`, `mismatch`, `not_found`, `skipped` or `error`. See below
  - `reason` (string) — Only on `skipped`: `cjk`, `web` or `short`
  - `diffs` (object[]) — Only on `mismatch`: the fields that differ
    - `field` (string, required) — `year`, `authors`, `title` or `doi`
    - `ours` (string) — What the reference says
    - `found` (string) — What the database has
    - `other` (string) — Only on `doi`: the title of the work the cited DOI actually points to
  - `match` (object) — The closest record, with the same fields as [Citation lookup](https://paperpurr.com/en/docs/lookup) `results[]`
- `usage.units` (integer, required) — Units this call cost: the number of references actually checked
- `usage.remaining` (integer, required) — Trial units left this month after this call
- `request_id` (string, required) — Request ID

## Verification results

| status | Meaning | Charged |
| --- | --- | --- |
| `matched` | Matches the database record | Yes |
| `mismatch` | Found, but the year, authors, title or DOI differ. See `diffs` | Yes |
| `not_found` | Not found in Crossref or OpenAlex | Yes |
| `skipped` | Not checked. See `reason` | No |
| `error` | This item failed. You can retry it on its own | No |

| reason | Meaning |
| --- | --- |
| `cjk` | Chinese, Japanese or Korean entries. Coverage in these databases is too thin, so they aren’t checked yet |
| `web` | A web page with too little bibliographic information |
| `short` | Too short to be a full reference, such as a blank line or a heading |

## Possible errors

| Status | code | Cause | What to do |
| --- | --- | --- | --- |
| `400` | `missing_parameter` | A required parameter is missing. `param` names it. | Add the parameter. |
| `400` | `invalid_parameter` | A parameter has the wrong type or value. `param` names it. | Fix it to match the type and range in the reference. |
| `400` | `unknown_parameter` | The request has a query parameter or body field the endpoint doesn’t accept. | Remove it or check the spelling. |
| `400` | `invalid_json` | The request body isn’t a JSON object. | Send a single JSON object with `Content-Type: application/json`. |
| `413` | `too_many_references` | `references` has more than 20 items. | Split into batches of up to 20. |
| `413` | `body_too_large` | The request body is too large. | Send fewer or shorter items. |
| `402` | `insufficient_balance` | This month’s trial allowance doesn’t cover the units this request needs. | Check `/v1/usage`, send fewer items or wait for next month’s reset. Word packs go on sale at launch. |
| `429` | `rate_limit_exceeded` | A rate limit was hit (per IP, per key or per account). `message` says which. | Wait the number of seconds in `Retry-After`, then retry. Queue requests if several processes share one key. |
| `503` | `busy` | The service is busy. Billable calls also return this when usage can’t be recorded, and nothing is charged. | Retry with backoff. |

See [Authentication](https://paperpurr.com/en/docs/auth) for auth errors and [Errors](https://paperpurr.com/en/docs/errors) for the full list.

## Metering

- Charged per reference actually checked: 1 unit each for `matched`, `mismatch` and `not_found`. `skipped` and `error` are free.
- Units for the whole batch are reserved first. If you don’t have enough left, it returns `402` and nothing is checked. After checking, you’re charged only for what was actually checked.
- Only the entries you list are sent. You never upload your paper.

Next: [Usage](https://paperpurr.com/en/docs/usage.md)
