> ## Documentation Index
> Fetch the complete documentation index at: https://vaquill.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Search and read cases

> Search US case law, look up citations, check the citations in a brief and read opinion text

Use search when you have words. Use citation lookup when you have a citation.

## Search

```bash theme={"theme":"github-light"}
curl -X POST "https://api.vaquill.ai/api/v1/us/cases/search" \
  -H "Authorization: Bearer $VAQUILL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "\"qualified immunity\" excessive force",
    "courtIds": ["US_FED_CA9"],
    "dateFrom": "2010-01-01",
    "limit": 5
  }'
```

* Every word must appear in the opinion.
* Use double quotes for an exact phrase, up to 3 phrases.
* Up to 50 words outside quotes.
* `OR`, `NOT` and wildcards are not supported.

Each result is one case, with the opinion that matched best in `opinionId`.
That opinion can be a dissent. For the main opinion, use `leadOpinionId`.

Set `passages` to 2 or 3 for more matching text at the same price.
Each passage has `start` and `end` positions in the plain text of the opinion.

A broad search can time out with a `503`. You are not charged. Narrow it by date, court or exact phrase.

### Filters

| Filter | Value |
| - | - |
| `courtIds` | Up to 50 [court codes](https://vaquill.ai/docs/api-guide/coverage/case-law.md#court-codes) |
| `state` | Two-letter code, such as `CA`. Includes federal trial and bankruptcy courts there. Add `courtSystem: "state"` for state courts only |
| `courtSystem` | `federal`, `state`, `territorial`, `tribal`, `military` |
| `courtLevel` | `supreme`, `appellate`, `trial`, `bankruptcy`, `bankruptcy_appellate`, `special`, `attorney_general`, `agency`, `other` |
| `dateFrom`, `dateTo` | `YYYY-MM-DD`, both included |
| `publicationStatus` | A list, such as `["published"]` |
| `judgeId` | A judge who wrote or sat on the case |
| `caseName`, `docketNumber` | Part of the text, 3 characters or more |
| `minCitedBy` | Fewest citing cases |
| `sort` | `relevance`, `decision_date`, `decision_date_asc`, `cited_by` |

> [!NOTE]
>
> `sort` and `minCitedBy` work on the top matches, not on every match.
> Narrow the query when order matters.

## Look up citations

`POST /us/cases/resolve` takes a list or a document.

* `citations`: up to 100 strings. Send `410 U.S. 113`, without the case name.
* `text`: up to 200,000 characters and 300 distinct citations.

```json theme={"theme":"github-light"}
{ "citations": ["410 U.S. 113", "347 U.S. 483"] }
```

| `status` | Meaning | Charged |
| - | - | - |
| `resolved` | One case matches | Yes |
| `ambiguous` | Several records match, sometimes copies of one case. See `candidates` | Yes |
| `not_found` | We hold no case with this citation | Yes |
| `unparsed` | The string is not a citation | No |

See the [citation formats](https://vaquill.ai/docs/api-guide/coverage/case-law.md#citation-formats) accepted.

## Check a brief

Send the brief as `text`. Short forms such as `Id.` get the case they point back to.

```python Python theme={"theme":"github-light"}
import os
import requests

brief = open("brief.txt", encoding="utf-8").read()
resp = requests.post(
    "https://api.vaquill.ai/api/v1/us/cases/resolve",
    headers={"Authorization": f"Bearer {os.environ['VAQUILL_API_KEY']}"},
    json={"text": brief},
    timeout=60,
)
resp.raise_for_status()
data = resp.json()

for row in data["results"]:
    name = row["case"]["caseName"] if row["case"] else "-"
    print(row["matched"], row["status"], name)

print("Not linked:", data["unresolvedShortForms"])
```

> [!WARNING]
>
> `resolved` means the citation exists. It does not check the case name or the quote.
> Compare `caseName` with the brief.
>
> `not_found` does not prove a citation is fake. We may not hold that case.

* `start` and `end` give the position of each citation in the brief.
* `pinpoint` gives the cited page, when there is one.
* `unresolvedShortForms` counts short forms left out because they could not be linked.

A repeated citation is charged once. A brief with 25 different citations costs 50 credits (\$0.50).

## Read opinions

```bash theme={"theme":"github-light"}
curl "https://api.vaquill.ai/api/v1/us/opinions/$OPINION_ID?format=text" \
  -H "Authorization: Bearer $VAQUILL_API_KEY"
```

| `format` | Use it for | What you get |
| - | - | - |
| `html` (default) | Display and links | Linked citations and footnotes |
| `text` | Models and search indexes | Plain text, footnotes at the end |

In `html`, a citation to a case we hold carries its id:

```html theme={"theme":"github-light"}
<cite data-case-id="USCASE_...">383 U.S. 663</cite>
```

Where print page breaks are known, they show as `*232` in the text.

If `bodyUnavailable` is `true`, there is no text and the call is free.

### Several at once

`POST /us/opinions/batch` takes up to 20 `opinionIds`.

* `notFound` lists unknown or withdrawn opinions.
* `bodyUnavailable` lists opinions with no text.
* `deferred` lists opinions past the 2,000,000 character limit. Send them again.

You pay only for the opinions returned.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.