I believe OS's OpenApi definition is invalid at version v1.0#1e41yo45l0vihg6s
. When I attempt to use it from Node using the api
package in my project I get validation errors. Simple steps to reproduce:
Create a new Node project and initialize
mkdir os-api-test cd os-api-test npm init
Per OS docs/examples, install the
api
package:npm install api --save
Create file
index.js
and populate it with the example code (address and API key omitted here, but they're valid and I can use them via the API UI):const sdk = require('api')('@opensea/v1.0#1e41yo45l0vihg6s'); sdk['retrieving-a-single-contract']({ asset_contract_address: 'REDACTED', 'X-API-KEY': 'REDACTED' }) .then(res => console.log(res)) .catch(err => console.error(err));
Run the example
node index.js
Output:
Looking at the API definition here and specifically at the /assets/get
path, there are indeed duplicate owner
parameters:
"parameters": [ { "name": "owner", "in": "query", "description": "The address of the owner of the assets", "schema": { "type": "string" } }, ... { "name": "owner", "in": "query", "schema": { "type": "string" } } ...
And per the OpenApi 3.1 spec, in reference to the path item object:
A list of parameters that are applicable for all the operations described under this path. These parameters can be overridden at the operation level, but cannot be removed there. The list MUST NOT include duplicated parameters.
Obviously I can't change the API definition but is there any way to work around this, perhaps via configuration of the api
package? I dug into its code but nothing jumped out at me. It's surprising that such a widely used API would have a bug that renders it unusable, yet I can't find any other mentions of it. I realize I may be able to use fetch to hit the API directly but I'd like to use the api
package.
Interestingly the testnet API does not suffer from this same bug.
Thank you for surfacing this. We had documented the
owner
parameter twice, which led to this issue. It is fixed it now.