createOracle
The createOracle
method is designed to facilitate the creation of an oracle, which serves as a reliable source of real-time data from a specified Application Programming Interface (API). This method is particularly suited for scenarios where only a single data point is required from the API.
Usage
As an example, we will utilize the CoinGecko public API, which provides the Ethereum price in USD: CoinGecko Ethereum API.
Return values during creation process
These are the possible events iExec may send to the subscriber:
message | sent | additional entries |
---|---|---|
ENCRYPTION_KEY_CREATED | once if using apiKey | key: String |
FILE_ENCRYPTED | once if using apiKey | encryptedFile: Buffer checksum: String |
ENCRYPTED_FILE_UPLOADED | once if using apiKey | cid: String multiaddr: String |
DATASET_DEPLOYMENT_SIGN_TX_REQUEST | once if using apiKey | |
DATASET_DEPLOYMENT_SUCCESS | once if using apiKey | address: String txHash: String |
PUSH_SECRET_TO_SMS_SIGN_REQUEST | once if using apiKey | |
PUSH_SECRET_TO_SMS_SUCCESS | once if using apiKey | |
DATASET_ORDER_SIGNATURE_SIGN_REQUEST | once if using apiKey | order: Object |
DATASET_ORDER_SIGNATURE_SUCCESS | once if using apiKey | order: Object |
DATASET_ORDER_PUBLISH_SIGN_REQUEST | once if using apiKey | order: Object |
DATASET_ORDER_PUBLISH_SUCCESS | once if using apiKey | orderHash: String |
PARAM_SET_CREATED | once | paramSet: String |
ORACLE_ID_COMPUTED | once | oracleId: String |
PARAM_SET_UPLOADED | once | cid: String |
COMPLETED | once |
Parameters
url
The API URL to fetch data from.
method
The HTTP method to use when making the API request (e.g., "GET").
headers (optional)
Any headers required for the API request.
dataType
The type of data to be returned (e.g., "number").
JSONPath
The JSON path to extract the data from the API response.
apiKey (optional)
API key if required by the data source.
Last updated