Opensea Auth 403 Error
Closed this issue · 3 comments
Hi,
i use this package for opensea api. Opensea share this code for api process.
const sdk = require('api')('@opensea/v1.0#118xs314kwwvl9g9');
sdk['retrieving-orders']({
bundled: 'false',
include_bundled: 'false',
limit: '20',
offset: '0',
order_by: 'created_date',
order_direction: 'desc',
'X-API-KEY': 'key'
})
.then(res => console.log(res))
.catch(err => console.error(err));
Opensea uses cloudflare and doesn't accept request if header not contain the api key. I got 403 error.
How can i use use api key in the header. I tried auth function but i couldn't work for this format code.
I read the package documentation, i couldn't see any info about manipulate header values.
Thanks for the help.
This code didn't work for you?
const sdk = require('api')('@opensea/v1.0#118xs314kwwvl9g9');
sdk.auth('your api key here');
sdk['retrieving-orders']({
bundled: 'false',
include_bundled: 'false',
limit: '20',
offset: '0',
order_by: 'created_date',
order_direction: 'desc',
})
.then(res => console.log(res))
.catch(err => console.error(err));
thank you for reply. Yes i tried this. I don't get 403 error but it is not return any data.
sdk.auth(settings.apiKey);
console.log("step1");
await sdk['retrieving-orders']({
bundled: 'false',
include_bundled: 'false',
limit: '20',
offset: '0',
order_by: 'created_date',
order_direction: 'desc'
}).then(res => console.log(res))
.catch(err => console.error(err));
console.log("step2");
step1 prints to console but step2 not print. if i delete await, step2 prints but still not return any data.
I unfortunately don't have an API key to test with them, but looking behind the curtain a bit the HAR we're generating to make the request with seems right according to what they've noted in their docs:
{
log: {
entries: [
{
request: {
cookies: [],
headers: [
{ name: 'Accept', value: 'application/json' },
{ name: 'X-API-KEY', value: 'your api key here' }
],
headersSize: 0,
queryString: [
{ name: 'bundled', value: 'false' },
{ name: 'include_bundled', value: 'false' },
{ name: 'limit', value: '20' },
{ name: 'offset', value: '0' },
{ name: 'order_by', value: 'created_date' },
{ name: 'order_direction', value: 'desc' }
],
bodySize: 0,
method: 'GET',
url: 'https://api.opensea.io/wyvern/v1/orders',
httpVersion: 'HTTP/1.1'
}
}
]
}
}
Making the request with that I get back a 401 response. Since you're getting a 403 there might be something up with your API key with them? I'd recommend reaching out to their support.
Let me know if they're able to help you out.