# Listed NFT

Ternoa indexer is **a record of the Ternoa Chain data.** You can query data for some specific entities (NFT, Collection, Marketplace(...)) using graphql. *In this example, we use the graphql-request library.*

### Step 1: nftEntity query preparation

You first need to prepare a stringified query to get NFT data from a specific marketplace id. Here are detailed the parameters available for the `nftEntity` concerning the NFT listing on a marketplace:

```markdown
`isListed`: Boolean flag: true if the NFT is listed on a Marketplace, false otherwise - Boolean
`typeOfListing`: The type of listing: auction or sale - String
`marketplaceId`: The marketplace id where the NFT has been listed - String
`price`: The listing price in Big Number format - String
`priceRounded`: The listing price in a basic number format - Float
`timestampListed`: The listing timestamp. Date
```

Do not hesitate to adapt the information you require in your query. You can check all the fields queryable for the NftEntity. Replace NFT\_ID with the NFT id you want to get the information from (e.g. the NFT id from the NFT previously used in "How to list for sale an NFT on a marketplace"):

```typescript
{
      nftEntity(id: "${id}") {
        nftId
        owner
        isListed
        typeOfListing
        marketplaceId
        price
        priceRounded
        timestampListed
      }
    }
```

### Step 2: Sending the request to the Indexer

Once the query is ready, you can request our indexer by providing both the indexer endpoint and the query. To check if the NFT is listed for sale, the **marketplaceId** field should not be null, **isListed** should be true and a **timestampList** should be filled.

Replace NFT\_ID in the following code snippet with the NFT ID previously used in "How to list for sale an NFT on a marketplace":

```typescript
import { request, gql } from "graphql-request";

const NFT_ID = 0;
const query = (id: number) => gql`
    {
      nftEntity(id: "${id}") {
        nftId
        owner
        isListed
        typeOfListing
        marketplaceId
        price
        priceRounded
        timestampListed
      }
    }
`;

const getNftData = async () => {
    try {
        const response = await request<{ nftEntity: NFTType }>(
            "https://indexer-alphanet.ternoa.dev",
            query(NFT_ID)
        );
        console.log(response);
    } catch (error) {
        console.error(error);
    }
};

type NFTType = {
    nftId: string
    owner: string
    isListed: boolean
    typeOfListing: string | null;
    marketplaceId: string | null;
    price: string | null;
    priceRounded; number | null;
    timestampList: Date | null;
};
```

The `getNftData` function is an asynchronous function that sends a GraphQL request using the `request` function from the **"graphql-request"** library. The response from the server is an object with a property nftEntity that has the data of the listed NFT.

### Support

If you face any trouble, feel free to reach out to our community engineers in our [Discord](https://discord.gg/fUmBkPpnRu).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ternoa.network/build-1/javascript/indexer/featured-requests/listed-nft.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
