Added OpenSea API key to config

refs https://github.com/TryGhost/Team/issues/1237

We want to use an API key for OpenSea where possible so that we do not
run into rate limit issues.
This commit is contained in:
Fabien egg O'Carroll 2021-11-30 10:32:38 +02:00 committed by Fabien 'egg' O'Carroll
parent 2540be63c1
commit c4021b6eb4
3 changed files with 14 additions and 2 deletions

View File

@ -4,7 +4,11 @@ const externalRequest = require('../../lib/request-external');
const OEmbed = require('../../services/oembed');
const oembed = new OEmbed({config, externalRequest});
const NFT = require('../../services/nft-oembed');
const nft = new NFT();
const nft = new NFT({
config: {
apiKey: config.get('opensea').privateReadOnlyApiKey
}
});
oembed.registerProvider(nft);
module.exports = {

View File

@ -35,8 +35,13 @@ class NFTOEmbedProvider {
if (!match) {
return null;
}
const headers = {};
if (this.dependencies.config.apiKey) {
headers['X-API-KEY'] = this.dependencies.config.apiKey;
}
const result = await externalRequest(`https://api.opensea.io/api/v1/asset/${transaction}/${asset}/?format=json`, {
json: true
json: true,
headers
});
return {
version: '1.0',

View File

@ -133,5 +133,8 @@
"tenor": {
"apiKey": null,
"contentFilter": "off"
},
"opensea": {
"privateReadOnlyApiKey": null
}
}