@model-match/api 3.43.1 → 3.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +121 -0
- package/RELEASE_NOTES.md +20 -0
- package/dist/{index-DUtNkw4G.d.mts → index-DMqIgBZb.d.mts} +989 -2169
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/slim/index.d.mts +482 -385
- package/dist/slim/index.mjs +4697 -5390
- package/dist/{src-B8pbncWy.mjs → src-DCqOC4qE.mjs} +845 -254
- package/openapi.json +906 -6970
- package/package.json +4 -25
package/README.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# @model-match/api
|
|
2
|
+
|
|
3
|
+
Typed TypeScript client for the ModelMatch API: US mortgage and real-estate market data covering loan officers, agents, companies, branches, lenders, loans, sales and properties, plus your ModelMatch CRM workspace.
|
|
4
|
+
|
|
5
|
+
- Generated from the API's OpenAPI 3.1 spec, so every route, request and response is typed.
|
|
6
|
+
- Uses `fetch` and runs anywhere it does: Node 18+, browsers, Bun, Deno, edge runtimes.
|
|
7
|
+
- No runtime dependencies.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @model-match/api
|
|
13
|
+
# or: pnpm add / yarn add / bun add
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Configure
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { createClient } from "@model-match/api";
|
|
20
|
+
|
|
21
|
+
createClient({
|
|
22
|
+
apiKey: process.env.MODELMATCH_API_KEY, // sent as `x-api-key`
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`createClient` configures a shared client once at startup. After that, every method uses it.
|
|
27
|
+
|
|
28
|
+
| Option | Type | Notes |
|
|
29
|
+
| --------- | ------------------------------------------- | --------------------------------------------------------------------------------- |
|
|
30
|
+
| `baseUrl` | `string` | Defaults to `https://api.modelmatch.com`, or the `MMR_API_URL` env var if set. |
|
|
31
|
+
| `apiKey` | `string` | Sent as the `x-api-key` header. |
|
|
32
|
+
| `token` | `string \| () => string \| Promise<string>` | OAuth bearer token. The function form runs per request, so it can refresh tokens. |
|
|
33
|
+
| `headers` | `Record<string, string>` | Extra headers on every request. |
|
|
34
|
+
|
|
35
|
+
## Call
|
|
36
|
+
|
|
37
|
+
Operations are grouped by resource as static methods: `Originators.list`, `Agents.get`, `Loans.analyticsSummary`, `Properties.get` and so on.
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { Originators } from "@model-match/api";
|
|
41
|
+
|
|
42
|
+
const { data: page } = await Originators.list({
|
|
43
|
+
body: {
|
|
44
|
+
flatFilters: { state: "CA" },
|
|
45
|
+
period: "last12Months",
|
|
46
|
+
sort: [{ field: "volume", order: "desc" }],
|
|
47
|
+
pagination: { size: 25 },
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Next page
|
|
52
|
+
const next = await Originators.list({
|
|
53
|
+
body: {
|
|
54
|
+
flatFilters: { state: "CA" },
|
|
55
|
+
pagination: { size: 25, cursor: page?.cursor },
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// One record
|
|
60
|
+
const { data: lo } = await Originators.get({ path: { nmlsId: "1234567" } });
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`createClient()` also returns the same classes grouped by resource (`api.originators.list(...)`), if you prefer that style.
|
|
64
|
+
|
|
65
|
+
## Per-user auth
|
|
66
|
+
|
|
67
|
+
The shared client holds one credential. When each call acts for a different user, build a client per call and pass it in:
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import { createApiClient, Originators } from "@model-match/api";
|
|
71
|
+
|
|
72
|
+
const client = createApiClient({ auth: () => userToken });
|
|
73
|
+
|
|
74
|
+
await Originators.list({ client, body: { flatFilters: { state: "CA" } } });
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
A client from `createApiClient` returns errors instead of throwing: you get `{ data, error, response }` back, and `data` is `undefined` when the call fails. Check `error`, or pass `throwOnError: true` to make it throw like the shared client:
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
const client = createApiClient({ auth: () => userToken, throwOnError: true });
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Errors
|
|
84
|
+
|
|
85
|
+
Calls through the shared client (the one `createClient` configures) throw on any non-2xx response. The thrown value is the parsed error body, for example `{ error: "not_found" }`. A `402` (out of credits) carries `{ error, balance, cost }`.
|
|
86
|
+
|
|
87
|
+
To handle errors without exceptions on a single call, pass `throwOnError: false`. You then get `{ data, error, response }` back:
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { Properties } from "@model-match/api";
|
|
91
|
+
|
|
92
|
+
const { data, error, response } = await Properties.get({
|
|
93
|
+
path: { id },
|
|
94
|
+
throwOnError: false,
|
|
95
|
+
});
|
|
96
|
+
if (error) {
|
|
97
|
+
console.warn(response?.status, error);
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Tree-shakable entry
|
|
102
|
+
|
|
103
|
+
`@model-match/api/slim` exports each operation as a standalone function named after its operationId. Bundlers can then drop whatever you don't import:
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
import { getOriginator, listOriginators } from "@model-match/api/slim";
|
|
107
|
+
|
|
108
|
+
const { data } = await listOriginators({
|
|
109
|
+
body: { flatFilters: { state: "TX" } },
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
It shares configuration with the main entry, so call `createClient` from either one.
|
|
114
|
+
|
|
115
|
+
## OpenAPI spec
|
|
116
|
+
|
|
117
|
+
The spec this version was generated from ships with the package as `@model-match/api/openapi.json`. Use it to generate a client in another language.
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
MIT
|
package/RELEASE_NOTES.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Release notes
|
|
2
|
+
|
|
3
|
+
Changes to `@model-match/api` that affect how you use it. Each version is generated from the ModelMatch API's OpenAPI spec, so new endpoints and fields appear in the [API reference](https://docs.modelmatch.com/developers) as they ship.
|
|
4
|
+
|
|
5
|
+
## 3.45.0
|
|
6
|
+
|
|
7
|
+
- **Properties: `ownerOccupancy` filter and field.** The assessor's owner-occupancy flag as `owner_occupied`, `probable_owner_occupied` or `not_flagged`, filterable in flat and advanced filters on property search, count, analytics and bulk exports. `ownerOccupied` is unchanged.
|
|
8
|
+
- **Properties: `absenteeOwner` filter and field.** `true` when the owner's mailing address differs from the property address, `false` when it matches, `null` when either is missing. Combine it with a location filter.
|
|
9
|
+
- **Properties: `ownerMailingAddress` on list results.** Previously only on the property detail response.
|
|
10
|
+
|
|
11
|
+
## 3.44.0
|
|
12
|
+
|
|
13
|
+
- **No runtime dependencies.** The fetch client is now built into the package instead of coming from `@hey-api/client-fetch`. Exported names are unchanged; `createApiClient` and the `ApiClient` type keep working.
|
|
14
|
+
- **Default `baseUrl` is now `https://api.modelmatch.com`** for both `createClient` and `createApiClient`. Before, `createClient` defaulted to `http://localhost:3001` and `createApiClient` had no default. `baseUrl` and the `MMR_API_URL` environment variable still override it; set one of them if you relied on the localhost default.
|
|
15
|
+
- **Admin-only operations removed.** A few admin endpoints and their types were published by mistake. They were never callable without an admin account and are no longer part of the package.
|
|
16
|
+
- **README and release notes** now ship with the package, and the published `package.json` no longer lists development dependencies or build scripts.
|
|
17
|
+
|
|
18
|
+
## 3.39.0
|
|
19
|
+
|
|
20
|
+
- Release notes start with the next version.
|