@kite-sa/sdk 0.5.0 → 0.7.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/CHANGELOG.md CHANGED
@@ -2,15 +2,54 @@
2
2
 
3
3
  Formerly `@darak-app/sdk`, which is deprecated. Versions before 0.5.0 were published under that name.
4
4
 
5
- ## 0.5.0 (unreleased)
5
+ ## 0.7.0
6
+
7
+ - Writes are safe to retry. A POST without an `Idempotency-Key` now gets one,
8
+ made once per call and reused on every retry, so a lost response can no longer
9
+ create a second API key, webhook or export. Pass your own as before
10
+ (`kite.organization.keys.create(body, { "Idempotency-Key": myKey })`); the
11
+ header name is matched case-insensitively. GET requests carry none.
12
+ - `kite.paginate(fetchPage, params)` (also exported as `paginate`) follows the
13
+ cursor of any list endpoint, e.g.
14
+ `kite.paginate((p) => kite.transactions.search(p), { city: "riyadh" })`.
15
+ `listings.searchAll` now uses it.
16
+ - `@kite-sa/sdk/webhooks` exports `verifyWebhookSignature(header, rawBody, secret)`
17
+ for the `Kite-Signature` header: HMAC-SHA256 over `t.body`, constant-time
18
+ compare, a five-minute window, and an array of secrets during a rotation. It is
19
+ a separate entry point because it needs `node:crypto`.
20
+ - New method `projects.availability(id, params)` for `GET /projects/{id}/availability`: a project's unit
21
+ count and source-reported available units over time, as daily, weekly or
22
+ monthly points with the units absorbed since the previous point.
23
+ - New webhook management methods: `organization.webhooks.update()`
24
+ (`POST /organization/webhooks/{webhook_id}/update`), `organization.webhooks.enable()`
25
+ (`.../enable`) and `organization.webhooks.rotateSecret()` (`.../rotate-secret`).
26
+ `organization.webhooks.deliveries()` takes `cursor` and its response has `pagination`.
27
+ - `verifyWebhookSignature` accepts a header with several `v1` entries, which
28
+ deliveries carry while a rotated secret's overlap lasts; any entry may match.
29
+
30
+ ## 0.6.0
31
+
32
+ - New methods for the endpoints added since 0.5.0:
33
+ `reference.coverage()` (`GET /coverage`: what the API can answer, per city and
34
+ property type), `analytics.belowMarket()` (`GET /market/below-market`: listings
35
+ priced below comparable ones) and `market.commercialRents()`
36
+ (`GET /market/commercial-rents`: commercial asking rent per m² by neighborhood).
37
+ - `analytics.deals()` (`GET /market/deals`) is deprecated in the API; use
38
+ `analytics.belowMarket()`.
39
+ - Response types follow the current spec, including `photo_features` on listings,
40
+ the price-basis labels and the constant-quality index in `/market/trends`.
41
+ - Package links point at the public docs; the issue link is `api@kite.sa`.
42
+
43
+ ## 0.5.0
6
44
 
7
45
  - **Renamed** from `@darak-app/sdk` to `@kite-sa/sdk` for the move to Kite. The client
8
46
  class is `Kite` (was `Darak`), the error class `KiteError` (was `DarakError`), the
9
47
  options type `KiteOptions`, and the key is read from `KITE_API_KEY` (was
10
48
  `DARAK_API_KEY`). The default base URL is `https://api.kite.sa/v1`;
11
49
  `https://api.darak.app/v1` keeps working, so pass it as `baseUrl` if you need it.
12
- Webhook headers (`Darak-Signature`, `Darak-Event-Id`, …) and the `darak.read`
13
- scope are part of the API and unchanged.
50
+ The `darak.read` scope is part of the API and unchanged. Webhook deliveries carry
51
+ `Kite-Signature`, `Kite-Event-Id`, … and still send the deprecated `Darak-*`
52
+ names with the same values. The SDK does not verify webhook signatures.
14
53
  - Generate endpoint types with TypeScript-7-compatible `openapi-zod-ts` instead of
15
54
  `openapi-typescript`. The SDK no longer exports the `paths` and `components`
16
55
  type maps, and its `operations` type map has a narrower shape. Update
package/README.md CHANGED
@@ -31,6 +31,9 @@ Get a key at [platform.kite.sa](https://platform.kite.sa). Keys are secret: call
31
31
 
32
32
  - Types for every parameter and response, generated from the API's OpenAPI spec.
33
33
  - Retries for `429` and `5xx` (and network errors) that honor `Retry-After`. A monthly-quota `429` isn't waited out; it throws.
34
+ - Safe write retries: a POST is sent with an `Idempotency-Key`, generated for you unless you pass one (`kite.organization.keys.create(body, { "Idempotency-Key": myKey })`), and every retry reuses it, so a lost response never creates a second key, webhook or export.
35
+ - `kite.paginate((p) => kite.transactions.search(p), { city: "riyadh" })` follows the cursor of any list endpoint (path arguments go in the closure: `(p) => kite.projects.units(42, p)`); `listings.searchAll` is the same for listings.
36
+ - Webhook verification: `import { verifyWebhookSignature } from "@kite-sa/sdk/webhooks"` and call it with the `Kite-Signature` header, the raw body and your signing secret (or an array of secrets during a rotation). It checks the HMAC in constant time and rejects signatures older than five minutes. Node only (it uses `node:crypto`).
34
37
  - `KiteError` with `status`, `code`, `message`, `param` and `requestId`. Branch on `code`; quote `requestId` to support.
35
38
 
36
39
  - Namespaces generated from the API's OpenAPI spec, so they track it exactly:
@@ -48,14 +51,3 @@ const projects = await kite.projects.search({ city: "riyadh" });
48
51
  0.1.x names for what is now `reference`.
49
52
 
50
53
  Options: `new Kite({ apiKey, baseUrl, maxRetries: 2, timeoutMs: 30000, fetch })`. Needs Node 18+ (or any runtime with `fetch`).
51
-
52
- ## Developing
53
-
54
- `src/openapi-zod/` (type source), `src/openapi.ts` (operation-type adapter),
55
- and `src/generated.ts` (the namespaces) are generated: run
56
- `bun run --filter @kite-sa/sdk generate` after the API spec changes. CI
57
- checks every generated file for drift; tests verify the spec hash, type coverage,
58
- and reachability of every `operationId` on a real client. The generated fetch
59
- client is used for types only; Kite retains its own authentication, retries,
60
- and snake_case query serialization. `bun run --filter @kite-sa/sdk build`
61
- writes `dist/`.
@@ -26,11 +26,29 @@ export declare function createEndpoints(request: Request): {
26
26
  readonly analytics: {
27
27
  /**
28
28
  * Find below-market listings. Residential listings asking noticeably less than
29
- * similar listings nearby, biggest gap first. Each listing is compared with
30
- * Darak's published nearby asking-price comparison: the same property type and
31
- * bedroom count, a similar area, within a calibrated radius and look-back
32
- * (disclosed per listing in `comparison`), one observation per distinct unit,
33
- * and the subject's own duplicates excluded.
29
+ * similar listings nearby, biggest gap first.
30
+ */
31
+ readonly belowMarket: (params: QueryOf<"analytics.below_market">) => Promise<{
32
+ data: {
33
+ listing: import("./openapi-zod/models.js").Listing;
34
+ comparison: {
35
+ median_price_sar: unknown;
36
+ p25_price_sar: unknown;
37
+ p75_price_sar: unknown;
38
+ percent_vs_median: number | null;
39
+ sample_size: number;
40
+ radius_m: unknown;
41
+ look_back_days: unknown;
42
+ price_basis: string;
43
+ price_source: string;
44
+ };
45
+ }[];
46
+ pagination: import("./openapi-zod/models.js").Pagination;
47
+ }>;
48
+ /**
49
+ * Find below-market listings (old path). **Deprecated:** use GET
50
+ * /market/below-market, which takes the same parameters and returns the same
51
+ * response.
34
52
  */
35
53
  readonly deals: (params: QueryOf<"analytics.deals">) => Promise<{
36
54
  data: {
@@ -43,6 +61,7 @@ export declare function createEndpoints(request: Request): {
43
61
  sample_size: number;
44
62
  radius_m: unknown;
45
63
  look_back_days: unknown;
64
+ price_basis: string;
46
65
  price_source: string;
47
66
  };
48
67
  }[];
@@ -234,19 +253,10 @@ export declare function createEndpoints(request: Request): {
234
253
  };
235
254
  }>;
236
255
  /**
237
- * Get price trends. Monthly median asking price over recent months (up to 36),
238
- * for a city or for up to five neighborhoods (one series each). Computed from
239
- * Darak's listing history, not from today's listings: every listing Darak has
240
- * recorded, including ones since rented, sold or removed, and every price change
241
- * (the price in force at each point in time, not the current one). - `on_market`
242
- * (default): a listing counts in a month if it was live at any point that month
243
- * (first seen before the month ended, and still active or last seen on or after
244
- * the month started), at the price it had at the end of the month, or when last
245
- * seen if it went off the market earlier. - `new_listings`: a listing counts in
246
- * the month Darak first saw it, at its first recorded asking price. Listings are
247
- * deduplicated across sources and pass the same outlier filter as the current
248
- * market (fences are today's), but not the 30-day freshness window, which
249
- * doesn't apply to history.
256
+ * Get price trends. Monthly asking prices over recent months (up to 36), for a
257
+ * city or for up to five neighborhoods (one series each): the median and
258
+ * quartiles for the price level, and a constant-quality price index
259
+ * (`price_index`) for change over time.
250
260
  */
251
261
  readonly trends: (params: QueryOf<"analytics.trends">) => Promise<{
252
262
  data: {
@@ -266,12 +276,17 @@ export declare function createEndpoints(request: Request): {
266
276
  name_en: string | null;
267
277
  name_ar: string | null;
268
278
  change_pct: number | null;
279
+ index_change_pct: number | null;
280
+ index_base_month: string | null;
269
281
  points: {
270
282
  month: string;
271
283
  sample_size: number;
272
284
  median_price_sar: unknown;
273
285
  p25_price_sar: unknown;
274
286
  p75_price_sar: unknown;
287
+ price_index: number | null;
288
+ index_cells: number;
289
+ index_sample_size: number;
275
290
  partial: boolean;
276
291
  coverage: string;
277
292
  }[];
@@ -324,7 +339,7 @@ export declare function createEndpoints(request: Request): {
324
339
  data: import("./openapi-zod/models.js").Listing;
325
340
  }>;
326
341
  /**
327
- * Get a listing's price history. Every price change Darak recorded for an active
342
+ * Get a listing's price history. Every price change Kite recorded for an active
328
343
  * listing, oldest first.
329
344
  */
330
345
  readonly priceHistory: (id: string | number) => Promise<{
@@ -342,7 +357,7 @@ export declare function createEndpoints(request: Request): {
342
357
  }>;
343
358
  /**
344
359
  * Search listings. Active, deduplicated listings in one city, quality-filtered
345
- * like darak.app.
360
+ * like kite.sa.
346
361
  */
347
362
  readonly search: (params: QueryOf<"listings.search">) => Promise<{
348
363
  data: import("./openapi-zod/models.js").Listing[];
@@ -391,9 +406,78 @@ export declare function createEndpoints(request: Request): {
391
406
  };
392
407
  };
393
408
  }>;
409
+ /**
410
+ * Commercial rent per m² by neighborhood. Asking rent per m² of commercial space
411
+ * (shops, offices, warehouses, commercial land and whole buildings) by
412
+ * neighborhood, with the city-wide figure for each type as a benchmark.
413
+ */
414
+ readonly commercialRents: (params: QueryOf<"market.commercial_rents">) => Promise<{
415
+ data: {
416
+ filters: {
417
+ city: string;
418
+ listing_type: string;
419
+ listing_category: string;
420
+ property_types: string[];
421
+ neighborhood_ids: unknown;
422
+ area_min: unknown;
423
+ area_max: unknown;
424
+ };
425
+ price_basis: string;
426
+ price_source: string;
427
+ min_sample_size: number;
428
+ city_totals: {
429
+ property_type: string;
430
+ sample_size: number;
431
+ median_rent_per_sqm_sar: unknown;
432
+ p25_rent_per_sqm_sar: unknown;
433
+ p75_rent_per_sqm_sar: unknown;
434
+ median_area_sqm: unknown;
435
+ median_rent_sar: unknown;
436
+ street_width: {
437
+ sample_size: number;
438
+ median_m: number | null;
439
+ };
440
+ exclusions: {
441
+ listings_in_scope: number;
442
+ lease_takeover: number;
443
+ implausible_area_or_price: number;
444
+ repeated_listing: number;
445
+ outside_price_per_sqm_fence: number;
446
+ };
447
+ price_per_sqm_fence_sar: {
448
+ lower: number;
449
+ upper: unknown;
450
+ };
451
+ }[];
452
+ neighborhoods: {
453
+ neighborhood_id: number;
454
+ name_ar: string;
455
+ name_en: string;
456
+ center: unknown;
457
+ property_type: string;
458
+ sample_size: number;
459
+ median_rent_per_sqm_sar: unknown;
460
+ p25_rent_per_sqm_sar: unknown;
461
+ p75_rent_per_sqm_sar: unknown;
462
+ median_area_sqm: unknown;
463
+ median_rent_sar: unknown;
464
+ street_width: {
465
+ sample_size: number;
466
+ median_m: number | null;
467
+ };
468
+ }[];
469
+ window: {
470
+ updated_within_days: number;
471
+ from: string;
472
+ to: string;
473
+ };
474
+ };
475
+ }>;
394
476
  /**
395
477
  * Land prices per m². Median registered price per m² of land plots, per quarter,
396
- * for a city or for each of up to 20 neighborhoods, with quarter-on-quarter and
478
+ * for a city, for each of up to 20 neighborhoods (`neighborhood_id`), or for
479
+ * every neighborhood in the city in one call (`group_by=neighborhood` without
480
+ * `neighborhood_id`, over at most 12 quarters), with quarter-on-quarter and
397
481
  * year-on-year change.
398
482
  */
399
483
  readonly landPrices: (params: QueryOf<"market.land_prices">) => Promise<{
@@ -401,9 +485,11 @@ export declare function createEndpoints(request: Request): {
401
485
  filters: {
402
486
  city: string;
403
487
  neighborhood_ids: unknown;
488
+ group_by: string;
404
489
  land_use: string;
405
490
  };
406
491
  asset: string;
492
+ price_basis: string;
407
493
  price_source: string;
408
494
  window: {
409
495
  quarter_from: string;
@@ -515,7 +601,7 @@ export declare function createEndpoints(request: Request): {
515
601
  * were updated, and breakdowns by property type, top neighborhoods by volume,
516
602
  * and source. Computed over the market sample: active, deduplicated listings
517
603
  * updated in the last 30 days (`updated_at`), after the same outlier filter
518
- * darak.app uses (per-tier price fences from the median and MAD of log price,
604
+ * kite.sa uses (per-tier price fences from the median and MAD of log price,
519
605
  * bedroom and area sanity checks, and a floor at 30% of the neighborhood
520
606
  * median).
521
607
  */
@@ -610,6 +696,7 @@ export declare function createEndpoints(request: Request): {
610
696
  group_by: string;
611
697
  land_use: unknown;
612
698
  };
699
+ price_basis: string;
613
700
  price_source: string;
614
701
  window: {
615
702
  quarter_from: string;
@@ -676,9 +763,11 @@ export declare function createEndpoints(request: Request): {
676
763
  };
677
764
  readonly official: {
678
765
  /**
679
- * Darak Property Index. **Free on every plan (0 units).** Series built on Saudi
766
+ * Kite Property Index. **Free on every plan (0 units).** Series built on Saudi
680
767
  * open data are served under the Saudi Open Data License v2.0 with attribution:
681
- * show `attribution.notice` wherever you display or pass on those figures.
768
+ * show `attribution.notice` wherever you display or pass on those figures. The
769
+ * Kite Property Index, as published: the series of a **published monthly
770
+ * release**, frozen when it was released.
682
771
  */
683
772
  readonly marketIndex: (params?: QueryOf<"official.market_index">) => Promise<{
684
773
  data: {
@@ -978,6 +1067,24 @@ export declare function createEndpoints(request: Request): {
978
1067
  delivered_at: unknown;
979
1068
  created_at: string;
980
1069
  }[];
1070
+ pagination: import("./openapi-zod/models.js").Pagination;
1071
+ }>;
1072
+ /**
1073
+ * Re-enable a webhook endpoint. Turns a disabled endpoint back on and resets
1074
+ * its failure count.
1075
+ */
1076
+ readonly enable: (webhookId: string | number, headers?: HeaderOf<"organization.webhooks.enable">) => Promise<{
1077
+ data: {
1078
+ id: string;
1079
+ url: string;
1080
+ event_types: string[];
1081
+ filters: Record<string, unknown>;
1082
+ description: string | null;
1083
+ status: string;
1084
+ disabled_reason: string | null;
1085
+ consecutive_failures: number;
1086
+ created_at: string;
1087
+ };
981
1088
  }>;
982
1089
  /** List webhook endpoints. Every endpoint this organization has subscribed. */
983
1090
  readonly list: () => Promise<{
@@ -1003,13 +1110,70 @@ export declare function createEndpoints(request: Request): {
1003
1110
  status: string;
1004
1111
  };
1005
1112
  }>;
1113
+ /**
1114
+ * Rotate a webhook signing secret. Issues a new signing secret, shown once in
1115
+ * the response.
1116
+ */
1117
+ readonly rotateSecret: (webhookId: string | number, body: BodyOf<"organization.webhooks.rotate_secret">, headers?: HeaderOf<"organization.webhooks.rotate_secret">) => Promise<{
1118
+ data: {
1119
+ id: string;
1120
+ secret: string;
1121
+ previous_secret_expires_at: unknown;
1122
+ };
1123
+ }>;
1124
+ /**
1125
+ * Update a webhook endpoint. Changes the URL, event types, filters or
1126
+ * description of an endpoint; send only what changes.
1127
+ */
1128
+ readonly update: (webhookId: string | number, body: BodyOf<"organization.webhooks.update">, headers?: HeaderOf<"organization.webhooks.update">) => Promise<{
1129
+ data: {
1130
+ id: string;
1131
+ url: string;
1132
+ event_types: string[];
1133
+ filters: Record<string, unknown>;
1134
+ description: string | null;
1135
+ status: string;
1136
+ disabled_reason: string | null;
1137
+ consecutive_failures: number;
1138
+ created_at: string;
1139
+ };
1140
+ }>;
1006
1141
  };
1007
1142
  };
1008
1143
  readonly projects: {
1009
1144
  /**
1010
- * List developers. Developers with active projects on Darak, most projects
1011
- * first.
1145
+ * Get a project's unit availability over time. Daily snapshots of a project's
1146
+ * unit count and the availability its source reports, as daily, weekly or
1147
+ * monthly points, each with the units absorbed since the previous point. This is
1148
+ * **listed availability**, not contracts: it comes from what the project's
1149
+ * source page showed on the day, so a unit counts as absorbed when the source
1150
+ * stops showing it, not when it is sold or leased.
1012
1151
  */
1152
+ readonly availability: (id: string | number, params?: QueryOf<"projects.availability">) => Promise<{
1153
+ data: {
1154
+ project_id: number;
1155
+ interval: string;
1156
+ from: string;
1157
+ to: string;
1158
+ unit_type: string | null;
1159
+ coverage: {
1160
+ first_snapshot: string | null;
1161
+ last_snapshot: string | null;
1162
+ snapshots: number;
1163
+ };
1164
+ points: {
1165
+ date: string;
1166
+ project_status: string | null;
1167
+ total_units: unknown;
1168
+ available_units: unknown;
1169
+ absorbed_since_previous: unknown;
1170
+ unit_types: unknown;
1171
+ starting_price: unknown;
1172
+ source: string;
1173
+ }[];
1174
+ };
1175
+ }>;
1176
+ /** List developers. Developers with active projects on Kite, most projects first. */
1013
1177
  readonly developers: (params?: QueryOf<"projects.developers">) => Promise<{
1014
1178
  data: {
1015
1179
  name: string;
@@ -1021,7 +1185,7 @@ export declare function createEndpoints(request: Request): {
1021
1185
  }>;
1022
1186
  /**
1023
1187
  * Get a project. One project with its description, boundary, amenities,
1024
- * financing banks and a summary of the units listed on Darak.
1188
+ * financing banks and a summary of the units listed on Kite.
1025
1189
  */
1026
1190
  readonly get: (id: string | number) => Promise<{
1027
1191
  data: {
@@ -1133,7 +1297,7 @@ export declare function createEndpoints(request: Request): {
1133
1297
  pagination: import("./openapi-zod/models.js").Pagination;
1134
1298
  }>;
1135
1299
  /**
1136
- * List a project's units. Active listings on Darak linked to one project: units
1300
+ * List a project's units. Active listings on Kite linked to one project: units
1137
1301
  * for sale (total price) and, for some projects, rentals (yearly rent).
1138
1302
  */
1139
1303
  readonly units: (id: string | number, params?: QueryOf<"projects.units">) => Promise<{
@@ -1225,7 +1389,7 @@ export declare function createEndpoints(request: Request): {
1225
1389
  }>;
1226
1390
  };
1227
1391
  readonly reference: {
1228
- /** List cities. Cities Darak covers. */
1392
+ /** List cities. Cities Kite covers. */
1229
1393
  readonly cities: () => Promise<{
1230
1394
  data: {
1231
1395
  slug: string;
@@ -1233,6 +1397,40 @@ export declare function createEndpoints(request: Request): {
1233
1397
  name_ar: string;
1234
1398
  }[];
1235
1399
  }>;
1400
+ /**
1401
+ * What the API covers. What the API can answer, per city: active listings by
1402
+ * listing type and kind of property, how many neighborhoods have at least 10 of
1403
+ * them, the share with a published nearby price band, the latest registered-deal
1404
+ * quarter and how much of it is placed in neighborhoods, and whether registered
1405
+ * rents exist.
1406
+ */
1407
+ readonly coverage: (params?: QueryOf<"reference.coverage">) => Promise<{
1408
+ data: {
1409
+ computed_at: string;
1410
+ cities: {
1411
+ city: string;
1412
+ name_en: string;
1413
+ name_ar: string;
1414
+ listings: {
1415
+ listing_type: string;
1416
+ property_family: string;
1417
+ property_types: string[];
1418
+ active_listings: number;
1419
+ neighborhoods_with_10_listings: number;
1420
+ price_band_ready_pct: number | null;
1421
+ }[];
1422
+ registered_deals: {
1423
+ latest_quarter: string | null;
1424
+ neighborhood_mapped_pct: number | null;
1425
+ mappable_deals: number;
1426
+ };
1427
+ registered_rents: {
1428
+ available: boolean;
1429
+ latest_quarter: string | null;
1430
+ };
1431
+ }[];
1432
+ };
1433
+ }>;
1236
1434
  /**
1237
1435
  * List city directions. Groupings of neighborhoods by part of the city (north,
1238
1436
  * east, …).
@@ -1301,6 +1499,7 @@ export declare function createEndpoints(request: Request): {
1301
1499
  readonly search: (params: QueryOf<"transactions.search">) => Promise<{
1302
1500
  data: import("./openapi-zod/models.js").Transaction[];
1303
1501
  pagination: import("./openapi-zod/models.js").Pagination;
1502
+ price_basis: string;
1304
1503
  price_source: string;
1305
1504
  coverage: import("./openapi-zod/models.js").TransactionCoverage;
1306
1505
  attribution: import("./openapi-zod/models.js").TransactionAttribution;
package/dist/generated.js CHANGED
@@ -4,11 +4,15 @@ export function createEndpoints(request) {
4
4
  analytics: {
5
5
  /**
6
6
  * Find below-market listings. Residential listings asking noticeably less than
7
- * similar listings nearby, biggest gap first. Each listing is compared with
8
- * Darak's published nearby asking-price comparison: the same property type and
9
- * bedroom count, a similar area, within a calibrated radius and look-back
10
- * (disclosed per listing in `comparison`), one observation per distinct unit,
11
- * and the subject's own duplicates excluded.
7
+ * similar listings nearby, biggest gap first.
8
+ */
9
+ belowMarket: (params) => request("GET", "/market/below-market", {
10
+ query: params,
11
+ }),
12
+ /**
13
+ * Find below-market listings (old path). **Deprecated:** use GET
14
+ * /market/below-market, which takes the same parameters and returns the same
15
+ * response.
12
16
  */
13
17
  deals: (params) => request("GET", "/market/deals", { query: params }),
14
18
  /**
@@ -50,19 +54,10 @@ export function createEndpoints(request) {
50
54
  query: params,
51
55
  }),
52
56
  /**
53
- * Get price trends. Monthly median asking price over recent months (up to 36),
54
- * for a city or for up to five neighborhoods (one series each). Computed from
55
- * Darak's listing history, not from today's listings: every listing Darak has
56
- * recorded, including ones since rented, sold or removed, and every price change
57
- * (the price in force at each point in time, not the current one). - `on_market`
58
- * (default): a listing counts in a month if it was live at any point that month
59
- * (first seen before the month ended, and still active or last seen on or after
60
- * the month started), at the price it had at the end of the month, or when last
61
- * seen if it went off the market earlier. - `new_listings`: a listing counts in
62
- * the month Darak first saw it, at its first recorded asking price. Listings are
63
- * deduplicated across sources and pass the same outlier filter as the current
64
- * market (fences are today's), but not the 30-day freshness window, which
65
- * doesn't apply to history.
57
+ * Get price trends. Monthly asking prices over recent months (up to 36), for a
58
+ * city or for up to five neighborhoods (one series each): the median and
59
+ * quartiles for the price level, and a constant-quality price index
60
+ * (`price_index`) for change over time.
66
61
  */
67
62
  trends: (params) => request("GET", "/market/trends", { query: params }),
68
63
  },
@@ -94,13 +89,13 @@ export function createEndpoints(request) {
94
89
  /** Get a listing. One active listing. */
95
90
  get: (id) => request("GET", `/listings/${encodeURIComponent(String(id))}`),
96
91
  /**
97
- * Get a listing's price history. Every price change Darak recorded for an active
92
+ * Get a listing's price history. Every price change Kite recorded for an active
98
93
  * listing, oldest first.
99
94
  */
100
95
  priceHistory: (id) => request("GET", `/listings/${encodeURIComponent(String(id))}/price-history`),
101
96
  /**
102
97
  * Search listings. Active, deduplicated listings in one city, quality-filtered
103
- * like darak.app.
98
+ * like kite.sa.
104
99
  */
105
100
  search: (params) => request("GET", "/listings", { query: params }),
106
101
  },
@@ -112,9 +107,19 @@ export function createEndpoints(request) {
112
107
  areaDistribution: (params) => request("GET", "/market/area-distribution", {
113
108
  query: params,
114
109
  }),
110
+ /**
111
+ * Commercial rent per m² by neighborhood. Asking rent per m² of commercial space
112
+ * (shops, offices, warehouses, commercial land and whole buildings) by
113
+ * neighborhood, with the city-wide figure for each type as a benchmark.
114
+ */
115
+ commercialRents: (params) => request("GET", "/market/commercial-rents", {
116
+ query: params,
117
+ }),
115
118
  /**
116
119
  * Land prices per m². Median registered price per m² of land plots, per quarter,
117
- * for a city or for each of up to 20 neighborhoods, with quarter-on-quarter and
120
+ * for a city, for each of up to 20 neighborhoods (`neighborhood_id`), or for
121
+ * every neighborhood in the city in one call (`group_by=neighborhood` without
122
+ * `neighborhood_id`, over at most 12 quarters), with quarter-on-quarter and
118
123
  * year-on-year change.
119
124
  */
120
125
  landPrices: (params) => request("GET", "/market/land-prices", {
@@ -137,7 +142,7 @@ export function createEndpoints(request) {
137
142
  * were updated, and breakdowns by property type, top neighborhoods by volume,
138
143
  * and source. Computed over the market sample: active, deduplicated listings
139
144
  * updated in the last 30 days (`updated_at`), after the same outlier filter
140
- * darak.app uses (per-tier price fences from the median and MAD of log price,
145
+ * kite.sa uses (per-tier price fences from the median and MAD of log price,
141
146
  * bedroom and area sanity checks, and a floor at 30% of the neighborhood
142
147
  * median).
143
148
  */
@@ -165,9 +170,11 @@ export function createEndpoints(request) {
165
170
  },
166
171
  official: {
167
172
  /**
168
- * Darak Property Index. **Free on every plan (0 units).** Series built on Saudi
173
+ * Kite Property Index. **Free on every plan (0 units).** Series built on Saudi
169
174
  * open data are served under the Saudi Open Data License v2.0 with attribution:
170
- * show `attribution.notice` wherever you display or pass on those figures.
175
+ * show `attribution.notice` wherever you display or pass on those figures. The
176
+ * Kite Property Index, as published: the series of a **published monthly
177
+ * release**, frozen when it was released.
171
178
  */
172
179
  marketIndex: (params) => request("GET", "/market/property-index", {
173
180
  query: (params ?? {}),
@@ -250,6 +257,11 @@ export function createEndpoints(request) {
250
257
  * answered.
251
258
  */
252
259
  deliveries: (webhookId, params) => request("GET", `/organization/webhooks/${encodeURIComponent(String(webhookId))}/deliveries`, { query: (params ?? {}) }),
260
+ /**
261
+ * Re-enable a webhook endpoint. Turns a disabled endpoint back on and resets
262
+ * its failure count.
263
+ */
264
+ enable: (webhookId, headers) => request("POST", `/organization/webhooks/${encodeURIComponent(String(webhookId))}/enable`, { headers: headers }),
253
265
  /** List webhook endpoints. Every endpoint this organization has subscribed. */
254
266
  list: () => request("GET", "/organization/webhooks"),
255
267
  /**
@@ -257,19 +269,35 @@ export function createEndpoints(request) {
257
269
  * `event_id` so a receiver that already handled it can recognise the repeat.
258
270
  */
259
271
  replay: (webhookId, deliveryId, headers) => request("POST", `/organization/webhooks/${encodeURIComponent(String(webhookId))}/deliveries/${encodeURIComponent(String(deliveryId))}/replay`, { headers: headers }),
272
+ /**
273
+ * Rotate a webhook signing secret. Issues a new signing secret, shown once in
274
+ * the response.
275
+ */
276
+ rotateSecret: (webhookId, body, headers) => request("POST", `/organization/webhooks/${encodeURIComponent(String(webhookId))}/rotate-secret`, { body, headers: headers }),
277
+ /**
278
+ * Update a webhook endpoint. Changes the URL, event types, filters or
279
+ * description of an endpoint; send only what changes.
280
+ */
281
+ update: (webhookId, body, headers) => request("POST", `/organization/webhooks/${encodeURIComponent(String(webhookId))}/update`, { body, headers: headers }),
260
282
  },
261
283
  },
262
284
  projects: {
263
285
  /**
264
- * List developers. Developers with active projects on Darak, most projects
265
- * first.
286
+ * Get a project's unit availability over time. Daily snapshots of a project's
287
+ * unit count and the availability its source reports, as daily, weekly or
288
+ * monthly points, each with the units absorbed since the previous point. This is
289
+ * **listed availability**, not contracts: it comes from what the project's
290
+ * source page showed on the day, so a unit counts as absorbed when the source
291
+ * stops showing it, not when it is sold or leased.
266
292
  */
293
+ availability: (id, params) => request("GET", `/projects/${encodeURIComponent(String(id))}/availability`, { query: (params ?? {}) }),
294
+ /** List developers. Developers with active projects on Kite, most projects first. */
267
295
  developers: (params) => request("GET", "/developers", {
268
296
  query: (params ?? {}),
269
297
  }),
270
298
  /**
271
299
  * Get a project. One project with its description, boundary, amenities,
272
- * financing banks and a summary of the units listed on Darak.
300
+ * financing banks and a summary of the units listed on Kite.
273
301
  */
274
302
  get: (id) => request("GET", `/projects/${encodeURIComponent(String(id))}`),
275
303
  /**
@@ -281,7 +309,7 @@ export function createEndpoints(request) {
281
309
  query: (params ?? {}),
282
310
  }),
283
311
  /**
284
- * List a project's units. Active listings on Darak linked to one project: units
312
+ * List a project's units. Active listings on Kite linked to one project: units
285
313
  * for sale (total price) and, for some projects, rentals (yearly rent).
286
314
  */
287
315
  units: (id, params) => request("GET", `/projects/${encodeURIComponent(String(id))}/units`, { query: (params ?? {}) }),
@@ -295,8 +323,18 @@ export function createEndpoints(request) {
295
323
  }),
296
324
  },
297
325
  reference: {
298
- /** List cities. Cities Darak covers. */
326
+ /** List cities. Cities Kite covers. */
299
327
  cities: () => request("GET", "/cities"),
328
+ /**
329
+ * What the API covers. What the API can answer, per city: active listings by
330
+ * listing type and kind of property, how many neighborhoods have at least 10 of
331
+ * them, the share with a published nearby price band, the latest registered-deal
332
+ * quarter and how much of it is placed in neighborhoods, and whether registered
333
+ * rents exist.
334
+ */
335
+ coverage: (params) => request("GET", "/coverage", {
336
+ query: (params ?? {}),
337
+ }),
300
338
  /**
301
339
  * List city directions. Groupings of neighborhoods by part of the city (north,
302
340
  * east, …).