@vansite/ts-sharetribe-flex-sdk
Version:
This is a TypeScript SDK for Sharetribe Flex API. It reduces the complexity of the API and provides a more user-friendly interface.
55 lines (54 loc) • 1.76 kB
TypeScript
/**
* @fileoverview Client for querying public listings in the Sharetribe Marketplace API.
*
* Use this to search and fetch listing details in your frontend.
* Only returns publicly visible data — no privileged operations.
*
* @see https://www.sharetribe.com/api-reference/marketplace.html#listings
*/
import type { AxiosResponse } from "axios";
import MarketplaceApi from "./index";
import { ListingsQueryParameter, ListingsResponse, ListingsShowParameter } from "../../types";
/**
* Public Listings API client
*/
declare class Listings {
private readonly axios;
private readonly endpoint;
private readonly headers;
constructor(api: MarketplaceApi);
/**
* Fetch a single listing by ID
*
* @template P
* @param {P & ListingsShowParameter} params
* @returns {Promise<AxiosResponse<ListingsResponse<"show", P>>>}
*
* @example
* const { data } = await sdk.listings.show({ id: "listing-abc123" });
*/
show<P extends ListingsShowParameter>(params: P): Promise<AxiosResponse<ListingsResponse<"show", P, {
expand: true;
}>>>;
/**
* Search and filter public listings
*
* @template P
* @param {P & ListingsQueryParameter} params
* @returns {Promise<AxiosResponse<ListingsResponse<"query", P>>>}
*
* @example
* // Basic keyword search
* await sdk.listings.query({ keywords: "yoga class" });
*
* @example
* // Geo + price filter
* await sdk.listings.query({
* origin: "60.1699,24.9384",
* bounds: "60.2,25.0,60.1,24.8",
* price: [0, 100]
* });
*/
query<P extends ListingsQueryParameter>(params: P): Promise<AxiosResponse<ListingsResponse<"query", P>>>;
}
export default Listings;