resources/listings.ListingClient

The ListingClient is used to manage listings on the Spaceport marketplace. A listing is an offer made by a licensor to license one or more assets under specific terms, such as price, duration, and royalties. This client handles creating and querying these listings.

Table of contents

Methods

constructor

new ListingClient(client): ListingClient

Parameters

NameType
clientSpaceportSDK

Returns

ListingClient

Methods

getAll

getAll(params?): Promise<CoreListing[]>

Gets all listings with optional filtering parameters.

Parameters

NameTypeDescription
params?ObjectOptional filtering parameters.
params.status?string-
params.id?string | string[]-
params.listingAddress?string-
params.listingId?string-
params.organization?string-

Returns

Promise<CoreListing[]>

Array of listings or empty array if none found.

getById

getById(id): Promise<CoreListing>

Gets a single listing by ID.

Parameters

NameTypeDescription
idstringThe ID of the listing to retrieve.

Returns

Promise<CoreListing>

The listing data or throws error if not found.

create

create(params): Promise<{ success: boolean ; message: string ; jobId: string ; listingId: string }>

Creates a listing using the server-side API endpoint. This method delegates the listing creation to the backend API which handles the necessary processing and platform interactions via a job queue system.

Parameters

NameTypeDescription
paramsCreateListingApiParams & { assetIds: string[] ; userId: string ; organizationId?: string }Parameters for creating the listing.

Returns

Promise<{ success: boolean ; message: string ; jobId: string ; listingId: string }>

Object containing success status, job ID, and listing ID.

Example

const result = await sdk.listings.create({
  licensorAddress: '0x...',
  price: 1000n,
  smartLicenseHash: '0x...',
  duration: 31536000n,
  licenseRoyalties: 100000000000000000n,
  resellRoyalties: 50000000000000000n,
  assetIds: ['asset-uuid-1', 'asset-uuid-2'],
  userId: 'user-uuid',
  title: 'My Listing',
  description: 'A great listing',
  category: 'digital-asset'
})
console.log('Created listing with ID:', result.listingId);
}