🌐APIs and HTTP GET/POST
One of the core capabilities of the Witnet protocol is to enable smart contracts to securely retrieve data from conventional APIs through HTTP(S) GET and POST calls.
This is specially convenient for pieces of data that are available from multiple sources, because many of them can be queried at once and aggregated together, thus getting an increased level of decentralization and fault tolerance.
Performing HTTP GET queries right from your Solidity smart contracts
Project setup
The HTTP GET/POST capability is enabled by the Witnet Truffle Box, a Truffle template project that includes everything you need to quickly get up to speed:
Data request file
HTTP GET/POST queries are defined using a Javascript based DSL and stored in the requests
folder of your repository.
This exemplifies a data request that fetches the BTC/USD price from 2 different REST APIs:
Want to make sense of all the Javascript above? Please make sure to check out the full HTTP GET tutorial, where every step is explained in detail
Learn More About The Witnet HTTP GET/POST Oracle
You can find here the complete documentation and API reference for the Witnet HTTP GET/POST oracle, along many more examples and walkthroughs:
Last updated