APIs and HTTP GET/POST
Last updated
Was this helpful?
Last updated
Was this helpful?
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.
The HTTP GET/POST capability is enabled by the , a template project that includes everything you need to quickly get up to speed:
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:
You can find here the complete documentation and API reference for the Witnet HTTP GET/POST oracle, along many more examples and walkthroughs:
Want to make sense of all the Javascript above? Please make sure to check out the , where every step is explained in detail