@sailsai/sdk
v0.2.0
Published
TypeScript client for the Sails Developer API
Readme
Sails TypeScript SDK
Typed client for the Sails Developer API, designed for browser and Node runtimes.
Install
npm install @sailsai/sdkUsage
import { SailsClient } from "@sailsai/sdk";
const client = new SailsClient({ apiKey: "sails_sk_..." });
const response = await client.predictPrice({
image_url: "https://example.com/shoe.jpg",
description: "Black Nike Air Max 90 on a white background",
limit: 10
});
console.log(response.price_lower, response.price_upper);By default the client targets https://sails.live/api/v1. Override it if needed:
const client = new SailsClient({
apiKey: "sails_sk_...",
baseUrl: "https://sails.live/api/v1"
});Error handling
import { SailsApiError } from "@sailsai/sdk";
try {
await client.generateBasicListing({ image_urls: ["https://example.com/camera.jpg"] });
} catch (error) {
if (error instanceof SailsApiError) {
console.error(error.status, error.code, error.message);
}
}Notes
- Uses
fetch. For Node versions withoutfetch, pass afetchimplementation in the client options.
