NEW

Chainlink Data Streams have officially launched on mainnet. Sign up for early access.

Back

Make a GET Request

This series of guides explains how to make HTTP GET requests to external APIs from smart contracts, using Chainlink's Request & Receive Data cycle.

Response Types

Make sure to choose an oracle job that supports the data type that your contract needs to consume. Multiple data types are available such as:

  • uint256 - Unsigned integers
  • int256 - Signed integers
  • bool - True or False values
  • string - String
  • bytes32 - Strings and byte values. If you need to return a string, use bytes32. Here's one method of converting bytes32 to string. Currently, any return value must fit within 32 bytes. If the value is bigger than that, make multiple requests.
  • bytes - Arbitrary-length raw byte data

Examples

Single Word Response

This guide explains how to make an HTTP GET request and parse the json response to retrieve the value of one single attribute.

Multi-Variable Responses

This guide explains how to make an HTTP GET request and parse the json response to retrieve the values of multiple attributes.

Fetch data from an Array

This guide explains how to make an HTTP GET request that returns a json array and parse it to retrieve the target element's value.

Large Responses

This guide explains how to make an HTTP Get request that returns a json containing an arbitrary-length raw byte data and parse it to return the data as bytes data type.

Make an Existing Job Request

This guide explains how to call a job that leverages External adapters and returns the relevant data to the smart contract. This allows building succinct smart contracts that do not need to comprehend the URL or the response format of the target API.

What's next

Stay updated on the latest Chainlink news