Get started

Step 0: Get 31Third API key

Request an API key via [email protected].

Step 1: Get an indicative price

Use /swap/price to fetch an indicative price.

price

You'll receive indicative information about:

  • buy amount

  • conversion price

  • price impact estimation.

Step 2: Get quote

Use /swap/quote to fetch a quote.

quote

You'll receive information about:

  • buy amount

  • minimal buy amount

  • conversion price

  • guaranteed conversion price

  • price impact

  • maximal price impact

  • raw transaction

Step 3: Send transaction

The quote response contains a raw transaction.

RawTransaction {
  to: string;
  data: string;
  value: string;
  gasLimit?: string; // Not always present
  gasPrice?: string; // Not always present
}

This transaction can be broadcasted to execute the swap.

Ethers.js example

The raw transaction can be passed into ethers signer.sendTransaction as follows:

signer.sendTransaction(rawTransaction);

Last updated