# Citation lookup

> Draft

`GET https://paperpurr.com/v1/citations/lookup`

Find a work by DOI, arXiv ID, URL or title and get bibliographic data you can drop straight into a reference list.

## Query parameters

- `query` (string, required) — A DOI, arXiv ID, URL, or 2–300 characters of title or reference text. At most 2048 characters in total.

| Input | How it’s looked up |
| --- | --- |
| DOI (starts with `10.`, or a `doi.org` link) | Crossref first, then OpenAlex |
| arXiv ID or `arxiv.org` link | arXiv |
| Other URLs | Reads the page’s bibliographic metadata |
| Title or reference text | Searches Crossref and OpenAlex together, ranked by match |

## Examples

curl:

```bash
curl "https://paperpurr.com/v1/citations/lookup?query=Attention%20Is%20All%20You%20Need" \
  -H "Authorization: Bearer $PAPERPURR_API_KEY"
```

Python:

```python
import os
import requests

r = requests.get(
    "https://paperpurr.com/v1/citations/lookup",
    headers={"Authorization": f"Bearer {os.environ['PAPERPURR_API_KEY']}"},
    params={
        "query": "Attention Is All You Need"
    },
)
print(r.json())
```

JS:

```javascript
const r = await fetch("https://paperpurr.com/v1/citations/lookup?query=Attention%20Is%20All%20You%20Need", {
  headers: {
    Authorization: `Bearer ${process.env.PAPERPURR_API_KEY}`,
  },
});
console.log(await r.json());
```

## Response

```json
{
  "results": [
    {
      "title": "Attention Is All You Need",
      "authors": [
        "Ashish Vaswani",
        "Noam Shazeer",
        "Niki Parmar"
      ],
      "year": 2017,
      "venue": "Advances in Neural Information Processing Systems",
      "doi": "10.48550/arXiv.1706.03762",
      "url": "https://arxiv.org/abs/1706.03762",
      "source": "arxiv"
    }
  ],
  "usage": {
    "units": 1,
    "remaining": 498
  },
  "request_id": "req_c40a7e1932bd5f08a4e6c71d"
}
```

- `results` (object[], required) — Up to 8 items ranked by match. Empty when nothing is found.
  - `title` (string, required) — Title
  - `authors` (string[], required) — Authors, up to 50
  - `year` (integer | null, required) — Publication year, or `null` if unknown
  - `venue` (string, required) — Journal, conference or publisher
  - `doi` (string, required) — DOI, or an empty string
  - `url` (string, required) — Link
  - `source` (string, required) — Where the data came from: `crossref`, `openalex`, `arxiv` or `web`
- `usage.units` (integer, required) — Units this call cost, always 1
- `usage.remaining` (integer, required) — Trial units left this month after this call
- `request_id` (string, required) — Request ID

## 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` | `url_blocked` | The URL can’t be fetched (for example, a private or local address). | Use a DOI, arXiv ID or title instead. |
| `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. |
| `502` | `upstream_unavailable` | Crossref, OpenAlex and arXiv all failed to respond. | Retry later. You aren’t charged for this request. |
| `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

- Each successful lookup costs 1 unit, even with no results. Nothing is charged when upstream fails (`502`).
- Only your `query` is sent. You never upload your paper.

Next: [Reference verification](https://paperpurr.com/en/docs/verify.md)
