opensea-js icon indicating copy to clipboard operation
opensea-js copied to clipboard

getOrders method has missing parameters in the endpoint

Open kecoco16 opened this issue 4 years ago • 3 comments

Update

Converting the params to camelCase and use the tokenIds param instead of the tokenId solved my issue.

const order = await openSea.api.getOrder({
  side: 'ask',
  protocol: 'seaport',
  assetContractAddress: contractAddress,
  tokenIds: [tokenId]
})

Description

When we use the getOrder method

await openSeaSDK.api.getOrder({
  side: 'ask',
  protocol: 'seaport',
  asset_contract_address: 'abc',
  token_id: 123
})

We are making a http request to this endpoint https://api.opensea.io/v2/orders/ethereum/seaport/listings?limit=1&order_by=created_date&order_direction=desc

but it should be this: https://api.opensea.io/v2/orders/ethereum/seaport/listings?limit=1&order_by=created_date&order_direction=desc&asset_contract_address=abc&token_ids=123

asset_contract_address and token_ids parameters are missing and we need to add them to the endpoint.

Temp Solution

A temporary solution to complete the purchase is to obtain the order directly from the api and then use the deserializeOrder function to convert the response to camel case

eg:

import { deserializeOrder } from 'opensea-js/lib/orders/utils'

const listings = await fetcher(
  `https://api.opensea.io/v2/orders/ethereum/seaport/listings?limit=1&order_by=created_date&order_direction=desc&asset_contract_address=${contractAddress}&token_ids=${tokenId}`,
  {
    method: 'GET',
    headers: {
      Accept: 'application/json',
      'X-API-KEY': 'secret'
    }
  }
)

const order = deserializeOrder(listings?.orders?.[0])
const accountAddress = await getMetaMaskAddress()
const fulfillOrder = await openSeaSDK.fulfillOrder({
  order,
  accountAddress
})

kecoco16 avatar Jul 13 '22 03:07 kecoco16

Try use camelCase params with assetContractAddress and tokenIds params goodluck!

YsingKitchen avatar Jul 13 '22 04:07 YsingKitchen

But i run into another issues image how to use this PARAM to get over two ids? can you tell me?

YsingKitchen avatar Jul 13 '22 04:07 YsingKitchen

tokenIds:idsArr but not work

YsingKitchen avatar Jul 13 '22 04:07 YsingKitchen