pragma solidity ^0.6.0; import "@chainlink/contracts/src/v0.6/ChainlinkClient.sol"; contract APIConsumer is ChainlinkClient { uint256 public volume; address private oracle; bytes32 private jobId; uint256 private fee; /** Example Request to query and save off-chain bird rating from address (0x6f92a213D338470a3fB9E8543A121ecAA5a9e1fA) on-chain using chainlink Native BirdOracle to be released soon * Network: Kovan * Oracle: Chainlink - 0x2f90A6D021db21e1B2A077c5a37B3C7E75D15b7e * Job ID: Chainlink - 29fa9aa13bf1468788b7cc4a500a45b8 * Fee: 0.1 LINK */ constructor() public { setPublicChainlinkToken(); oracle = 0x2f90A6D021db21e1B2A077c5a37B3C7E75D15b7e; jobId = "29fa9aa13bf1468788b7cc4a500a45b8"; fee = 0.1 * 10 ** 18; // 0.1 LINK } /** * Create a Chainlink request to retrieve API response, find the target * data, then multiply by 1000000000000000000 (to remove decimal places from data). */ function requestVolumeData() public returns (bytes32 requestId) { Chainlink.Request memory request = buildChainlinkRequest(jobId, address(this), this.fulfill.selector); // Set the URL to perform the GET request on request.add("get", "https://www.bird.money/analytics/address/0x6f92a213D338470a3fB9E8543A121ecAA5a9e1fA"); // Set the path to find the desired data in the API response, where the response format is: // { // "bird_rating": x.xxx // } request.add("path", "bird_rating"); // Sends the request return sendChainlinkRequestTo(oracle, request, fee); } /** * Receive the response in the form of uint256 */ function fulfill(bytes32 _requestId, uint256 _volume) public recordChainlinkFulfillment(_requestId) { volume = _volume; } }