Chainlink Developers

Welcome to the Chainlink documentation site. You'll find comprehensive guides and documentation to help you start working with Chainlink as quickly as possible, as well as support if you get stuck. Click here for an introductory walkthrough on how to create a Chainlink request on the Ropsten test network!

Building on Chainlink? Click here to get started!

Get Started

Flightstats Chainlink (Testnet) (Etherisc)

This Chainlink has a dedicated connection to Flightstats' API. This Chainlink allows requesters to get the ratings and status of different flights.

Steps for using this oracle

Chainlink Network Details

You will need to use the following LINK token address, oracle address, and Job ID in order to create the Chainlink request.

Rinkeby

LINK Token address: 0x01BE23585060835E02B77ef475b0Cc51aA1e0709
Oracle address: 0x7AFe1118Ea78C1eae84ca8feE5C65Bc76CcF879e
JobID: d5a6d1b6dc30467790b92ff3299b8e99

Create your Chainlinked contract

Import ChainlinkClient.sol into your contract so you can inherit the Chainlinked behavior.

pragma solidity ^0.4.24;

import "chainlink/contracts/ChainlinkClient.sol";

contract FlightstatsChainlink is ChainlinkClient {

  uint256 oraclePayment;

  constructor(uint256 _oraclePayment) public {
    setPublicChainlinkToken();
    oraclePayment = _oraclePayment;
  }
  // Additional functions here:
  
}

Tasks

Request Parameters

endpoint

Required

One of:

  • ratings
  • status
  • e-ratings
  • e-status

See endpoints for more information.

Solidity example

req.add("endpoint", "ratings");

carrier

Required

The airline operating the flight
Examples: HA.

Solidity example

req.add("carrier", "HA");

flightNumber

Required

The flight number.

Solidity example

req.add("flightNumber", "25");

yearMonthDay

Required (for status/e-status)

The year, month and day for flight arrival or departure.
Status uses arrival, e-status uses departure.

Solidity example

req.add("year", "2019/11/21");

year

Required (for status/e-status)

The year for flight arrival or departure.
Status uses arrival, e-status uses departure.

Solidity example

req.add("year", "2018");

month

Required (for status/e-status)

The month for flight arrival or departure.
Status uses arrival, e-status uses departure.

Solidity example

req.add("year", "09");

day

Required (for status/e-status)

The day for flight arrival or departure.
Status uses arrival, e-status uses departure.

Solidity example

req.add("day", "21");

copyPath

Required

The path of the desired data field to return to the smart contract.

Solidity example

req.add("copyPath", "ratings.cancelled");

Endpoints

ratings

Returns Flight Ratings object. For more information, see Flightstats' docs: https://developer.flightstats.com/api-docs/ratings/v1/ratingsresponse

e-ratings

A comma delimited list of:

  • observations
  • late15
  • late30
  • late45
  • cancelled
  • diverted

...from the Flight Ratings object.

status

Returns Flight Status Response object. For more information, see Flightstats' docs: https://developer.flightstats.com/api-docs/flightstatus/v2/flightstatusresponse

e-status

A comma delimited list of:

  • status
  • arrivalGateDelayMinutes (if supplied)
  • actualGateArrival ("true" if supplied, "false" otherwise)

...from the Flight Status Response object.

Chainlink Example

This example will give you the cancellation status for a flight number and carrier.

function requestStatus
(
  address _oracle,
  bytes32 _jobId,
  string _flightNum,
  string _carrier
)
  public
  onlyOwner
{
  Chainlink.Request memory req = buildChainlinkRequest(_jobId, this, this.fulfill.selector);
  req.add("endpoint", "ratings");
  req.add("carrier", _carrier);
  req.add("flightNumber", _flightNum);
  req.add("copyPath", "ratings.cancelled");
  sendChainlinkRequestTo(_oracle, req, oraclePayment);
}

Here is an example of the fulfill method:

bytes32 public status;

function fulfill(bytes32 _requestId, bytes32 _status)
  public
  recordChainlinkFulfillment(_requestId)
{
  status = _status;
}

Updated about a month ago

Flightstats Chainlink (Testnet) (Etherisc)


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.