I'm trying to pull data into my smart contract from an API using the approach described here:


I can get the example code at that link working just fine, but the API I need to connect to requires sending an API Key in the header of the request. I'm trying to figure out the best way to get the data into my contract. The data is publicly available already but the owner of the API requires all users to request a free API Key to use their API.

Here's what I think are my options:

  1. Make my own oracle that uses my API Key, then have my contract pull from that oracle.
  2. Scrape the data from the existing API and then make my own API to serve it in a way that doesn't require an API Key.
  3. Contact the API owner and see if they will consider allowing unauthenticated requests to the endpoint I'm using.

Am I missing something?

Further complicating things, the existing API returns numeric values enclosed in quotes, like this: "2465". In my testing, using the method described in the chainlink docs, I was not able to get the value returned from the API when it is in quotes (I've attempted using bytes32 and unit256). It's possible I messed something up somewhere, so I'd like to know if it is possible to have a number that is in quotes returned using the approach described in the chainlink docs.

1 Answer 1


In the Chainlink's blog, you can read the article OAuth and API Authentication in Smart Contracts.

It can guide you how to create and use an external adapter to get data into a contract from an API that requires authentication.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.