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

OpenSky Network Chainlink (Testnet)

This Chainlink has a dedicated connection to OpenSky Network's API. The OpenSky Network is a community-based receiver network which continuously collects air traffic surveillance data. Unlike other networks, OpenSky keeps the collected raw data forever and makes it accessible to researchers. With over ten trillion ADS-B and Mode S messages collected from more than 1000 sensors around the world, the OpenSky Network exhibits the largest air traffic surveillance dataset of its kind.

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.

Ropsten

LINK Token address: 0x20fE562d797A42Dcb3399062AE9546cd06f63280
Oracle address: 0xc99B3D447826532722E41bc36e644ba3479E4365
JobID: b9133103bce04386a39a4d5692d8d526

Create your Chainlinked contract

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

pragma solidity ^0.4.24;

import "chainlink/contracts/ChainlinkClient.sol";

contract OpenSkyChainlink is ChainlinkClient {

  uint256 oraclePayment;

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

Tasks

Request Parameters

endpoint

Required

The endpoint to use from OpenSky Network's API. Currently supported values are:

  • states
  • flights
  • tracks

Solidity example

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

action

Required

Currently supported values are:

  • all
  • aircraft
  • arrival
  • departure

Solidity example

req.add("action", "all");

time

The time in seconds since epoch (Unix time stamp to retrieve states for. Current time will be used if omitted.

Solidity example

req.addInt("time", now - 1 hours);

airport

ICAO identifier for the airport (usually upper case).

Solidity example

req.add("airport", "EDDF");

icao24

Unique ICAO 24-bit address of the transponder in hex string representation. All letters need to be lower case.

Solidity example

req.add("icao24", "3c675a");

serials

Retrieve only states of a subset of your receivers. You can pass this argument several time to filter state of more than one of your receivers. In this case, the API returns all states of aircraft that are visible to at least one of the given receivers.

Solidity example

req.add("serials", "123456");

begin

Start of time interval to retrieve flights for as Unix time (seconds since epoch).

Solidity example

req.addInt("begin", now - 1 days);

end

End of time interval to retrieve flights for as Unix time (seconds since epoch).

Solidity example

req.addInt("end", now);

copyPath

Required

The path of the desired data field to return to the smart contract. Examples of returned data format for their given endpoint and action are below:

{
	"time": 1458564121,
	"states": [
		[
			"3c6444", // icao24
			"DLH9LF  ", // callsign
			"Germany", // origin_country
			1458564120, // time_position
			1458564120, // last_contact
			6.1546, // longitude
			50.1964, // latitude
			9639.3, // baro_altitude
			false, // on_ground
			232.88, // velocity
			98.26, // true_track
			4.55, // vertical_rate
			null, // sensors
			9547.86, // geo_altitude
			"1000", // squawk
			false, // spi
			0 // position_source
		],
    /* ... */
	]
}
[
	{
		"icao24": "800547",
		"firstSeen": 1517227477,
		"estDepartureAirport": "VGTJ",
		"lastSeen": 1517228618,
		"estArrivalAirport": null,
		"callsign": "JAI273  ",
		"estDepartureAirportHorizDistance": 6958,
		"estDepartureAirportVertDistance": 655,
		"estArrivalAirportHorizDistance": null,
		"estArrivalAirportVertDistance": null,
		"departureAirportCandidatesCount": 1,
		"arrivalAirportCandidatesCount": 0
	},
	/* ... */
]
[
	{
		"icao24": "3c675a",
		"firstSeen": 1517258040,
		"estDepartureAirport": "EDDF",
		"lastSeen": 1517263900,
		"estArrivalAirport": "ESSA",
		"callsign": "DLH2VC  ",
		"estDepartureAirportHorizDistance": 1462,
		"estDepartureAirportVertDistance": 49,
		"estArrivalAirportHorizDistance": 7194,
		"estArrivalAirportVertDistance": 423,
		"departureAirportCandidatesCount": 1,
		"arrivalAirportCandidatesCount": 3
	},
	/* ... */
]
[
	{
		"icao24": "0101be",
		"firstSeen": 1517220729,
		"estDepartureAirport": null,
		"lastSeen": 1517230737,
		"estArrivalAirport": "EDDF",
		"callsign": "MSR785  ",
		"estDepartureAirportHorizDistance": null,
		"estDepartureAirportVertDistance": null,
		"estArrivalAirportHorizDistance": 1593,
		"estArrivalAirportVertDistance": 95,
		"departureAirportCandidatesCount": 0,
		"arrivalAirportCandidatesCount": 2
	},
	/* ... */
]
[
	{
		"icao24": "3c4ad0",
		"firstSeen": 1517230790,
		"estDepartureAirport": "EDDF",
		"lastSeen": 1517238306,
		"estArrivalAirport": null,
		"callsign": "DLH630  ",
		"estDepartureAirportHorizDistance": 4319,
		"estDepartureAirportVertDistance": 65,
		"estArrivalAirportHorizDistance": null,
		"estArrivalAirportVertDistance": null,
		"departureAirportCandidatesCount": 1,
		"arrivalAirportCandidatesCount": 0
	},
	/* ... */
]
{
	"icao24": "3c4b26",
	"callsign": "DLH440  ",
	"startTime": 1548234765,
	"endTime": 1548238909,
	"path": [
		[
			1548234765, // time
			50.0339, // latitude
			8.54, // longitude
			0, // baro_altitude
			69, // true_track
			false // on_ground
		],
		/* ... */
	]
}

Solidity example

req.add("copyPath", "states.0.8");

Chainlink Examples

The example below will give you the current status of a flight, if it is on the ground or not.

function flightOnGround
(
  address _oracle,
  bytes32 _jobId,
  string _icao24
)
  public
  onlyOwner
{
  Chainlink.Request memory req = buildChainlinkRequest(_jobId, this, this.fulfill.selector);
  req.add("endpoint", "states");
  req.add("action", "all");
  req.add("airport", _icao24);
  req.add("copyPath", "states.0.8");
  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;
}

OpenSky Network Chainlink (Testnet)


Suggested Edits are limited on API Reference Pages

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