Querying Passes

To query the passes in your project, you can use the GET /v0/passes endpoint.

This API offers a wide range of parameters you can filter on:

  • owner address
  • token address and/or token ID
  • chain and/or network
  • expired or active
  • last scanned time
  • created time

Fetching All Active Passes

To find all active passes in your project, you can use the GET /v0/passes endpoint as follows:

const response = await fetch(
    `$https://api.ethpass.xyz/api/v0/passes?expired=0`,
    {
        method: "GET",
        headers: new Headers({
          "content-type": "application/json",
          "x-api-key": process.env.ETHPASS_API_KEY,
        }),
    }
);

Preventing Duplicates by Checking for Existing Passes

The ethpass API will not prevent you from creating passes tied to duplicate parameters.

If a user has already created a pass tied to their wallet / NFT, you may want to prevent them from creating a second pass.

To implement this check, you can use the GET /v0/passes endpoint like below:

const ownerAddress = "0xC0156A89A159A85f3f7e832e7E2450538a70B0Ab"
const contractAddress = "0x86c1d53F15E34895D608Ff47EE56aD1f0F3F45B4"
const tokenId = "231"
const network = 1
const chain = "evm"
const expired = 0

const response = await fetch(
    `$https://api.ethpass.xyz/api/v0/passes?contractAddress=${contractAddress}&tokenId=${tokenId}&network=${network}&chain=${chain}&ownerAddress=${ownerAddress}&expired=${expired}`,
    {
        method: "GET",
        headers: new Headers({
          "content-type": "application/json",
          "x-api-key": process.env.ETHPASS_API_KEY,
        }),
    }
);

If the query returns a matching pass, we recommend returning the existing pass to the user and allowing them to download it again.