Profile Listings

How to retrieve a user's NFT listings from the Wayup Marketplace

Introduction

This guide demonstrates how to retrieve all active listings for a specific wallet address on the Wayup Marketplace. This endpoint is useful for building user profiles, dashboards, or portfolio trackers that show what NFTs a user currently has listed for sale.

Requirements

  • A valid Cardano wallet address

API Request Structure

Configuration

// API endpoint for Wayup Marketplace
const BASE_URL = "https://prod.api.ada-anvil.app/marketplace/api";

// Wallet address to query listings for
const WALLET_ADDRESS = "addr1qx33ycd2ymg02dxh6vnnf8dsk54l8ranr9cfjk9qrlj3309c69jc4n8h3uvnczncaqu2sm03pl99h99n75uvtl3mhv0q3z8s8m";

Type Definitions

interface ProfileListingsRequest {
  address: string;
  limit?: number;
  cursor?: string;
  policyId?: string;
  term?: string;
}

interface AssetResult {
  name: string;
  policyId: string;
  assetName: string;
  media: string;
  listing: {
    txHashIndex: string;
    price: string;
    priceCurrency: string;
    scriptHash: string;
    bundleSize?: number;
    isProcessing: boolean;
    type: string;
    version: string;
    fees: {
      service: {
        pct: number;
      };
      royalty: {
        minLovelace: number;
        pct: number;
        addr: string;
      } | null;
    };
  };
  collection?: {
    policyId: string;
    name: string;
    image?: string;
    royaltyPct?: number;
    royaltyAddress?: string;
  };
  // Additional fields omitted for brevity
}

interface ProfileListingsResponse {
  results: AssetResult[];
  pageState: string | null;
}

Implementation

Step 1: Build the Request URL

Build the URL with the required parameters:

Step 2: Execute the Request

Send the request to the API:

Step 3: Process the Response

Parse the API response:

Step 4: Display the Results

Process and display the listings data:

Step 5: Handle Pagination

Handle pagination for large result sets:

Running the Example

Example Output

The Complete File

chevron-rightget-profile-listings.tshashtag

Best Practices

  1. Input Validation: Always validate the wallet address before making the API call.

  2. Error Handling: Implement proper error handling for network issues or invalid responses.

  3. Pagination: Always handle pagination for users with many listings.

  4. Filtering: Use the policyId parameter when you want to focus on a specific collection.

  5. Search: The term parameter is useful for searching NFTs by name.

End-to-End Flow

  1. Obtain a wallet address from your user

  2. Query the /get-profile-listings endpoint with the wallet address

  3. Display the listing results (name, image, price, etc.)

  4. Implement pagination using the returned pageState if there are more results

  5. Allow filtering by collection using the policyId parameter

  6. Enable searching by name using the term parameter

Last updated

Was this helpful?