# Groups

> Search group practices and list their members.

Source: https://openpipe.health/docs/api/groups/

## Search groups

```http
GET /api/groups
```

Returns group practices, largest first. Costs 1 credit.

### Parameters

| Name | Type | Description |
|---|---|---|
| `q` | string | Substring of the group name. |
| `state` | string | Two-letter state code. |
| `min_members` | number | Minimum number of clinicians in the group. |
| `specialty` | string | Substring of the group's most common specialty. |
| `limit` | number | 1 to 200. Default 25. |
| `offset` | number | Rows to skip. Default 0. |

### Example

```sh
curl "$OPH_API/api/groups?state=OH&specialty=cardio&min_members=20" \
  -H "Authorization: Bearer $OPH_KEY"
```

```json
{
  "rows": [
    {
      "group_pac_id": "1234567890",
      "name": "EXAMPLE HEART PHYSICIANS INC",
      "state": "OH",
      "member_count": 148,
      "top_specialty": "Cardiovascular Disease (Cardiology)"
    }
  ],
  "sql": "SELECT group_pac_id, name, state, member_count, top_specialty FROM groups WHERE state = $1 AND member_count >= $2 AND top_specialty ILIKE $3 ORDER BY member_count DESC LIMIT 25 OFFSET 0",
  "params": ["OH", 20, "%cardio%"],
  "sources": ["groups"],
  "ms": 2,
  "usage": { "credits": 1, "creditsUsed": 9, "creditsLimit": 100, "txid": "81247" }
}
```

## Get a group

```http
GET /api/groups/:id
```

`:id` is the `group_pac_id` from a search. Costs 1 credit, charged only if the group exists.

### Response

| Field | Contents |
|---|---|
| `group` | The group record. |
| `specialties` | Up to 20 specialties with the number of members in each. |
| `members` | Up to 50 members ranked by Medicare payment: NPI, name, specialty, city, state, `tot_payment`. Members who did not bill Medicare have `null` name and payment. |
| `sql` | The three statements, keyed `group`, `specialties`, `members`. |
| `sources` | `groups`, `group_members`, `medicare_provider`. |

Unknown ids return `404` with `No group with that id.`
