encarapi 1.1.1 → 1.3.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 CHANGED
@@ -82,7 +82,18 @@ saveCursor(client.china.lastCursor);
82
82
  |---|---|---|
83
83
  | `catalog(params)` | `GET /api/catalog` | Search & list. `source`: `encar` (default), `kbc`, `kcar`, `all` |
84
84
  | `iterateCatalog(params)` | `GET /api/catalog` | Async iterator over all pages |
85
+ | `iterateCatalogById(params)` | `GET /api/catalog?sort=id` | Complete, stable traversal (keyset cursor, nothing repeated or skipped) |
85
86
  | `leasing(params)` | `GET /api/catalog/leasing` | Lease takeovers and rentals |
87
+ | `iterateLeasingById(params)` | `GET /api/catalog/leasing?sort=id` | Complete, stable traversal of lease/rental listings |
88
+ | `vehicleByVin(vin)` | `GET /api/vehicle/by-vin/{vin}` | All listings of one VIN incl. removed ones (Business/Scale) |
89
+ | `trucks(params)` | `GET /api/catalog/trucks` | Trucks, buses and special vehicles (Business/Scale) |
90
+ | `truckEnums()` | `GET /api/catalog/trucks/enums` | Truck filter values with counts |
91
+ | `trucksCsv()` | `GET /api/catalog/trucks/export` | Full truck inventory CSV (Business/Scale) |
92
+ | `iterateTrucksById(params)` | `GET /api/catalog/trucks?sort=id` | Complete, stable traversal of the truck catalog |
93
+ | `equipment(params)` | `GET /api/catalog/equipment` | Used excavators (Business/Scale) |
94
+ | `equipmentEnums()` | `GET /api/catalog/equipment/enums` | Equipment filter values with counts |
95
+ | `equipmentCsv()` | `GET /api/catalog/equipment/export` | Full equipment inventory CSV (Business/Scale) |
96
+ | `iterateEquipmentById(params)` | `GET /api/catalog/equipment?sort=id` | Complete, stable traversal of the equipment catalog |
86
97
  | `nav(params)` | `GET /api/nav` | Filter facets with counts |
87
98
  | `enums(params)` | `GET /api/enums` | Valid values for the flat filters |
88
99
  | `modelSearch(search, params)` | `GET /api/model-search` | Model autocomplete |
@@ -94,7 +105,7 @@ saveCursor(client.china.lastCursor);
94
105
  | `bulkVehicles(ids)` / `bulkInspections(ids)` / `bulkRecords(ids)` | `POST /api/.../bulk` | Up to 500 ids (Business/Scale) |
95
106
  | `inspectionVersions(id)` / `recordVersions(id)` | `GET /api/.../versions` | Report history (Business/Scale) |
96
107
  | `changes(params)` / `iterateChanges(params)` | `GET /api/catalog/changes` | Incremental sync (Business/Scale) |
97
- | `exportCsv()` | `GET /api/catalog/export` | Full catalog CSV (Business/Scale) |
108
+ | `exportCsv(params)` | `GET /api/catalog/export` | Full catalog CSV (Business/Scale); `{ sell_type: "lease,rental" }` for lease/rental |
98
109
  | `makesCsv()` / `modelsCsv()` / `badgesCsv()` | `GET /api/taxonomy/*.csv` | Reference data |
99
110
 
100
111
  ## China API (`client.china`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "encarapi",
3
- "version": "1.1.1",
3
+ "version": "1.3.0",
4
4
  "description": "Official Node.js client for EnCarAPI: Korean used car data (Encar, KB Chachacha, K Car) and Chinese used car data (Dongchedi, Che168) in one REST API.",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
package/src/index.d.ts CHANGED
@@ -65,10 +65,69 @@ export interface KoreaCatalogParams {
65
65
  exclude_prices?: string;
66
66
  exclude_duplicates?: Bool;
67
67
  min_first_seen?: string;
68
+ /** Region codes, comma = OR (seoul, gyeonggi, busan, ...). Encar listings only for now. */
69
+ region?: string;
70
+ /** Cities, comma = OR: value from korea.enums().city (e.g. "suwon"), English or Korean name. Encar only. */
71
+ city?: string;
72
+ /** Keyset cursor for sort "id": nextAfter of the previous response. */
73
+ after?: string;
68
74
  /** Raw Encar q-grammar (alternative to the flat filters). */
69
75
  q?: string;
70
76
  lang?: "en";
71
- sort?: "newest" | "price_asc" | "price_desc" | "mileage_asc" | "mileage_desc" | "year_desc" | "year_asc";
77
+ /** "id" = stable listing-id order; page with `after` (see iterateCatalogById). */
78
+ sort?: "newest" | "price_asc" | "price_desc" | "mileage_asc" | "mileage_desc" | "year_desc" | "year_asc" | "id";
79
+ page?: number;
80
+ limit?: number;
81
+ count?: Bool;
82
+ }
83
+
84
+ /** Filters for /api/catalog/trucks. Values from korea.truckEnums(). */
85
+ export interface KoreaTruckParams {
86
+ form?: "cargo" | "wing_body" | "bus" | "dump_construction" | "crane" | "tank" | "camper" | "waste_transport" | "live_fish" | "tow_transport" | "tractor" | "trailer" | (string & {});
87
+ manufacturer?: string;
88
+ /** Substring of the Korean model name, e.g. "포터". */
89
+ model?: string;
90
+ min_tons?: number;
91
+ max_tons?: number;
92
+ use?: "private" | "commercial" | "other";
93
+ fuel?: string;
94
+ transmission?: string;
95
+ color?: string;
96
+ min_price?: number;
97
+ max_price?: number;
98
+ min_year?: number;
99
+ max_year?: number;
100
+ min_mileage?: number;
101
+ max_mileage?: number;
102
+ region?: string;
103
+ sort?: "newest" | "price_asc" | "price_desc" | "mileage_asc" | "mileage_desc" | "year_desc" | "year_asc" | "id";
104
+ after?: string;
105
+ page?: number;
106
+ limit?: number;
107
+ count?: Bool;
108
+ lang?: "en";
109
+ }
110
+
111
+ /** Filters for /api/catalog/equipment. Values from korea.equipmentEnums(). */
112
+ export interface KoreaEquipmentParams {
113
+ maker?: string;
114
+ model?: string;
115
+ sub_type?: "crawler" | "wheel" | (string & {});
116
+ /** e.g. "EXC_CR_LE_6_5" (02 class crawler). */
117
+ weight_class?: string;
118
+ min_year?: number;
119
+ max_year?: number;
120
+ min_hours?: number;
121
+ max_hours?: number;
122
+ /** Price in 만원 (10,000 KRW). */
123
+ min_price?: number;
124
+ max_price?: number;
125
+ has_price?: Bool;
126
+ /** "sell" (default), "buy", "rent", a comma list or "all". */
127
+ deal_type?: string;
128
+ region?: string;
129
+ sort?: "newest" | "price_asc" | "price_desc" | "hours_asc" | "year_desc" | "year_asc" | "id";
130
+ after?: string;
72
131
  page?: number;
73
132
  limit?: number;
74
133
  count?: Bool;
@@ -77,6 +136,10 @@ export interface KoreaCatalogParams {
77
136
  export interface KoreaCatalogResponse {
78
137
  Count?: number;
79
138
  SearchResults: Json[];
139
+ /** Only with sort "id": pass as `after` for the next page; null on the last page. */
140
+ nextAfter?: string | null;
141
+ /** Only with sort "id": true while more pages follow. */
142
+ hasMore?: boolean;
80
143
  [key: string]: any;
81
144
  }
82
145
 
@@ -115,6 +178,28 @@ export class KoreaClient {
115
178
  enums(params?: { source?: KoreaSource }): Promise<Json>;
116
179
  modelSearch(search: string, params?: { limit?: number; source?: KoreaSource; exclude_duplicates?: Bool; has_photos?: Bool; exclude_prices?: string; min_price?: number }): Promise<Json>;
117
180
  iterateCatalog(params?: KoreaCatalogParams): AsyncGenerator<Json, void, unknown>;
181
+ /** Complete, stable traversal (sort=id + after): nothing repeated or skipped while the catalog changes. */
182
+ iterateCatalogById(params?: KoreaCatalogParams): AsyncGenerator<Json, void, unknown>;
183
+ /** iterateCatalogById() for lease-takeover and rental listings. */
184
+ iterateLeasingById(params?: KoreaCatalogParams): AsyncGenerator<Json, void, unknown>;
185
+ /** Encar trucks, buses and special vehicles (Business/Scale). */
186
+ trucks(params?: KoreaTruckParams): Promise<KoreaCatalogResponse>;
187
+ /** Every Encar / K Car listing of one VIN, active and removed (Business/Scale). */
188
+ vehicleByVin(vin: string): Promise<Json>;
189
+ /** Valid truck filter values with counts. */
190
+ truckEnums(): Promise<Json>;
191
+ /** Full truck inventory as CSV text (Business/Scale). */
192
+ trucksCsv(params?: { compress?: Bool }): Promise<string>;
193
+ /** Complete, stable traversal of the truck catalog (sort=id + after). */
194
+ iterateTrucksById(params?: KoreaTruckParams): AsyncGenerator<Json, void, unknown>;
195
+ /** Used excavators from 굴삭기나라 (Business/Scale). */
196
+ equipment(params?: KoreaEquipmentParams): Promise<KoreaCatalogResponse>;
197
+ /** Valid equipment filter values with counts. */
198
+ equipmentEnums(): Promise<Json>;
199
+ /** Full equipment inventory as CSV text (Business/Scale). */
200
+ equipmentCsv(params?: { compress?: Bool }): Promise<string>;
201
+ /** Complete, stable traversal of the equipment catalog (sort=id + after). */
202
+ iterateEquipmentById(params?: KoreaEquipmentParams): AsyncGenerator<Json, void, unknown>;
118
203
  /** Ids: Encar id, "kbc:<id>" or "kcar:<id>". */
119
204
  vehicle(id: string, params?: { lang?: "en" }): Promise<Json>;
120
205
  inspection(id: string): Promise<Json>;
@@ -130,7 +215,8 @@ export class KoreaClient {
130
215
  changes(params: KoreaChangesParams): Promise<KoreaChangesResponse>;
131
216
  iterateChanges(params: KoreaChangesParams): AsyncGenerator<KoreaChange, void, unknown>;
132
217
  /** CSV text. */
133
- exportCsv(params?: { source?: KoreaSource }): Promise<string>;
218
+ /** sell_type: "sale" (default), "lease", "rental", a comma list or "all". */
219
+ exportCsv(params?: { source?: KoreaSource; sell_type?: string }): Promise<string>;
134
220
  makesCsv(params?: { source?: KoreaSource }): Promise<string>;
135
221
  modelsCsv(params?: { source?: KoreaSource }): Promise<string>;
136
222
  badgesCsv(params?: { source?: KoreaSource }): Promise<string>;
package/src/korea.js CHANGED
@@ -49,11 +49,72 @@ class KoreaClient {
49
49
  }
50
50
  }
51
51
 
52
+ /**
53
+ * Complete, stable traversal via sort=id + after (keyset cursor): rows never
54
+ * shift between pages while the catalog changes, so nothing is repeated or
55
+ * skipped. Yields every matching listing once, in listing-id order.
56
+ * for await (const car of korea.iterateCatalogById({ manufacturer: "BMW" })) {}
57
+ */
58
+ async *iterateCatalogById(params = {}) {
59
+ yield* this._iterateById("/api/catalog", params);
60
+ }
61
+
62
+ /** Same as iterateCatalogById() for lease-takeover and rental listings. */
63
+ async *iterateLeasingById(params = {}) {
64
+ yield* this._iterateById("/api/catalog/leasing", params);
65
+ }
66
+
67
+ // -- trucks, buses, special vehicles (Business/Scale) ----------------------
68
+
69
+ /** Encar trucks & buses: { form: "cargo", max_tons: 1, lang: "en" }. Values from truckEnums(). */
70
+ trucks(params) { return this.http.request("GET", "/api/catalog/trucks", { params }); }
71
+
72
+ /** Valid truck filter values with counts (form, use, fuel, transmission, color, manufacturer, capacity_tons, region). */
73
+ truckEnums() { return this.http.request("GET", "/api/catalog/trucks/enums"); }
74
+
75
+ /** Full truck inventory as CSV text (Business/Scale). */
76
+ trucksCsv(params) { return this.http.request("GET", "/api/catalog/trucks/export", { params, text: true }); }
77
+
78
+ /** Complete, stable traversal of the truck catalog (sort=id + after). */
79
+ async *iterateTrucksById(params = {}) {
80
+ yield* this._iterateById("/api/catalog/trucks", params);
81
+ }
82
+
83
+ // -- construction equipment / excavators (Business/Scale) -----------------
84
+
85
+ /** Used excavators from 굴삭기나라: { sub_type: "crawler", max_hours: 5000 }. Values from equipmentEnums(). */
86
+ equipment(params) { return this.http.request("GET", "/api/catalog/equipment", { params }); }
87
+
88
+ /** Valid equipment filter values with counts (maker, sub_type, weight_class, deal_type, region). */
89
+ equipmentEnums() { return this.http.request("GET", "/api/catalog/equipment/enums"); }
90
+
91
+ /** Full equipment inventory as CSV text (Business/Scale). */
92
+ equipmentCsv(params) { return this.http.request("GET", "/api/catalog/equipment/export", { params, text: true }); }
93
+
94
+ /** Complete, stable traversal of the equipment catalog (sort=id + after). */
95
+ async *iterateEquipmentById(params = {}) {
96
+ yield* this._iterateById("/api/catalog/equipment", params);
97
+ }
98
+
99
+ async *_iterateById(path, params) {
100
+ const { page, ...rest } = params;
101
+ let query = { ...rest, sort: "id", limit: params.limit || 1000 };
102
+ for (;;) {
103
+ const res = await this.http.request("GET", path, { params: query });
104
+ for (const item of res.SearchResults || []) yield item;
105
+ if (!res.hasMore || !res.nextAfter) return;
106
+ query = { ...query, after: res.nextAfter };
107
+ }
108
+ }
109
+
52
110
  // -- one vehicle -------------------------------------------------------------
53
111
 
54
112
  /** Full vehicle detail. Ids: Encar id, "kbc:<id>" or "kcar:<id>". */
55
113
  vehicle(id, params) { return this.http.request("GET", `/api/vehicle/${enc(id)}`, { params }); }
56
114
 
115
+ /** Every Encar / K Car listing of one VIN, active and removed (Business/Scale). */
116
+ vehicleByVin(vin) { return this.http.request("GET", `/api/vehicle/by-vin/${enc(vin)}`); }
117
+
57
118
  /** Official inspection report (성능점검). */
58
119
  inspection(id) { return this.http.request("GET", `/api/inspection/${enc(id)}`); }
59
120
 
@@ -105,7 +166,10 @@ class KoreaClient {
105
166
  }
106
167
  }
107
168
 
108
- /** Full catalog as CSV text. */
169
+ /**
170
+ * Full catalog as CSV text. { sell_type: "lease,rental" } for the lease/rental
171
+ * inventory, { source: "kbc" } etc. for other marketplaces.
172
+ */
109
173
  exportCsv(params) { return this.http.request("GET", "/api/catalog/export", { params, text: true }); }
110
174
 
111
175
  // -- reference data -------------------------------------------------------------