@apibara.tech/vehicle-auction-api 0.0.0-stage → 0.1.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/LICENSE +24 -0
- package/README.md +22 -2
- package/package.json +48 -4
- package/src/index.d.ts +17 -0
- package/src/index.js +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Apibara.tech
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
This software license does not grant rights to third-party auction data, images,
|
|
24
|
+
trademarks, or services accessed through the Apibara API.
|
package/README.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @apibara.tech/vehicle-auction-api
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
JavaScript / TypeScript client for the [Apibara.tech Vehicle Auction Data API](https://apibara.tech/en/products/vehicle-auction-data-api/docs).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @apibara.tech/vehicle-auction-api
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage (Node.js 18+)
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import { ApibaraVehicleAuctionClient } from "@apibara.tech/vehicle-auction-api";
|
|
15
|
+
|
|
16
|
+
const api = new ApibaraVehicleAuctionClient(process.env.APIBARA_API_KEY);
|
|
17
|
+
const listings = await api.search({ platform: "copart", year_from: 2020 });
|
|
18
|
+
console.log(listings);
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Methods: `search`, `vehicle`, `history`, `related`, `filters`, `locations`, `shipping`, `usage`. All return the JSON body as returned by the API; response schemas are documented in [OpenAPI](https://apibara.tech/openapi/v1.json).
|
|
22
|
+
|
|
23
|
+
Keep API keys on the server. Auction photos and data are subject to their own applicable rights and conditions.
|
package/package.json
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apibara.tech/vehicle-auction-api",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Official dependency-free JavaScript client for the Apibara.tech Copart and IAAI Vehicle Auction Data API",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./src/index.js",
|
|
7
|
+
"types": "./src/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./src/index.d.ts",
|
|
11
|
+
"import": "./src/index.js",
|
|
12
|
+
"default": "./src/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"test": "node --test test/*.test.js",
|
|
22
|
+
"pack:check": "npm pack --dry-run"
|
|
23
|
+
},
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=18"
|
|
26
|
+
},
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/apibaratech/vehicle-auction-sdk.git",
|
|
31
|
+
"directory": "npm"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://apibara.tech/en/products/vehicle-auction-data-api/docs",
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/apibaratech/vehicle-auction-sdk/issues"
|
|
36
|
+
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"apibara",
|
|
39
|
+
"copart",
|
|
40
|
+
"iaai",
|
|
41
|
+
"vehicle-auction",
|
|
42
|
+
"vehicle-data",
|
|
43
|
+
"api",
|
|
44
|
+
"sdk"
|
|
45
|
+
],
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public"
|
|
48
|
+
},
|
|
49
|
+
"sideEffects": false
|
|
50
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type QueryValue = string | number | boolean | null | undefined;
|
|
2
|
+
export type Query = Record<string, QueryValue | QueryValue[]>;
|
|
3
|
+
export class ApibaraVehicleAuctionClient {
|
|
4
|
+
constructor(apiKey: string, baseUrl?: string);
|
|
5
|
+
readonly apiKey: string;
|
|
6
|
+
readonly baseUrl: string;
|
|
7
|
+
search(query?: Query): Promise<unknown>;
|
|
8
|
+
vehicle(identifier: string, query?: Query): Promise<unknown>;
|
|
9
|
+
history(identifier: string): Promise<unknown>;
|
|
10
|
+
related(identifier: string, query?: Query): Promise<unknown>;
|
|
11
|
+
filters(query?: Query): Promise<unknown>;
|
|
12
|
+
locations(query?: Query): Promise<unknown>;
|
|
13
|
+
shipping(identifier: string, query?: Query): Promise<unknown>;
|
|
14
|
+
usage(): Promise<unknown>;
|
|
15
|
+
get(path: string, query?: Query): Promise<unknown>;
|
|
16
|
+
}
|
|
17
|
+
export default ApibaraVehicleAuctionClient;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export class ApibaraVehicleAuctionClient {
|
|
2
|
+
constructor(apiKey, baseUrl = "https://apibara.tech/api/v1/vehicle-auction") {
|
|
3
|
+
if (!apiKey) throw new Error("APIBARA API key is required");
|
|
4
|
+
this.apiKey = apiKey;
|
|
5
|
+
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
search(query = {}) { return this.get("/vehicles", query); }
|
|
9
|
+
vehicle(identifier, query = {}) {
|
|
10
|
+
return this.get(`/vehicles/${encodeURIComponent(identifier)}`, query);
|
|
11
|
+
}
|
|
12
|
+
history(identifier) {
|
|
13
|
+
return this.get(`/vehicles/${encodeURIComponent(identifier)}/history`);
|
|
14
|
+
}
|
|
15
|
+
related(identifier, query = {}) {
|
|
16
|
+
return this.get(`/vehicles/${encodeURIComponent(identifier)}/related`, query);
|
|
17
|
+
}
|
|
18
|
+
filters(query = {}) { return this.get("/vehicles/filters", query); }
|
|
19
|
+
locations(query = {}) { return this.get("/locations", query); }
|
|
20
|
+
shipping(identifier, query = {}) {
|
|
21
|
+
return this.get(`/vehicles/${encodeURIComponent(identifier)}/shipping`, query);
|
|
22
|
+
}
|
|
23
|
+
usage() { return this.get("/usage"); }
|
|
24
|
+
|
|
25
|
+
async get(path, query = {}) {
|
|
26
|
+
const url = new URL(this.baseUrl + path);
|
|
27
|
+
for (const [key, raw] of Object.entries(query)) {
|
|
28
|
+
const values = Array.isArray(raw) ? raw : [raw];
|
|
29
|
+
for (const value of values) {
|
|
30
|
+
if (value !== null && value !== undefined && value !== "") {
|
|
31
|
+
url.searchParams.append(key, String(value));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const response = await fetch(url, {
|
|
37
|
+
headers: {
|
|
38
|
+
Accept: "application/json",
|
|
39
|
+
"X-API-Key": this.apiKey,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const payload = await response.json().catch(() => null);
|
|
44
|
+
if (!response.ok) {
|
|
45
|
+
const message = payload?.message ?? payload?.error ?? `HTTP ${response.status}`;
|
|
46
|
+
throw new Error(`Apibara: ${message}`);
|
|
47
|
+
}
|
|
48
|
+
return payload;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default ApibaraVehicleAuctionClient;
|