Back to top

faast SWAP API

faast logo

  • Current Version: 0.2.1

  • For changes, see History

This document describes the faast REST-like API to be used to easily convert between any cryptocurrency.

Introduction

Overview

The goal of the faast API is to provide an instant, and secure method to convert from one cryptocurrency to another. To achieve this, a user specifies which currency they possess (deposit currency), and which currency they would like to obtain (withdrawal currency), as well as a wallet address for the currency they would like to obtain.

The faast API then generates a unique deposit wallet address for the “deposit currency”, where the user can send any arbitrary amount of cryptocurrency. Upon noticing any transaction on this deposit address faast will immediately fullfill an order at the current market rate, and send an equivalent amount of “withdrawal currency” to the users specified “wallet address”.

faast never takes custody of users cryptocurrency, and has no user account system. It is designed for instant, safe, and secure conversion in between any arbitrary set of cryptocurrencies.

Basic flow

Order creation:

  1. Get a current price/rate (varies in real time with market)

  2. Generate an order and deposit address

  3. Send cryptocurrency to the deposit address

  4. Monitor the status for completion

Fixed pricing vs Variable Pricing

Faast provides two forms of pricing: fixed and variable. When using fixed pricing, an order is created expecting a specific deposit amount in return for a specific withdrawal amount. When using variable pricing, any arbitrary amount can be deposited, and an equivalent withdrawal amount will be calculated using the prevailing exchange rate at the time the deposit is received. This model provides optimal user experience, as well as developer flexibility.

Fixed Pricing

The faast api is inherently asynchronous. There will always be a time lag in-between the time that a swap is created, and a deposit is send for that specific swap. Given the volatility of cryptocurrency markets, even these short delays can cause pricing discrepancies, and as a result, poor user experience.

For this reason, faast provides a “fixed pricing” option when creating a swap. Faast will guarantee the price quoted back in the response assuming the deposit is received before the expiry period. To provide the best experience with fixed pricing, timing is paramount.

How to create a fixed price swap

When calling the /swap endpoint, ensure a deposit_amount is specified, and the generated swap will return a price based on the market depth at the time of the request. The response will contain a price and price_locked_until parameters.

A deposit from the customer must be received before price_locked_until, and match the deposit_amount expected to ensure the price will honored. In the off chance that signing a transaction takes longer than expected, the /swaps/refresh endpoint can be called to refresh the price and re-quote based on an updated market rate.

All transactions are considered “received” when they are detected by a blockchain node on the faast network. Transactions do not need to be “confirmed” or in a “block” to be considered “received”.

Variable pricing

Variable pricing allows for more flexibility, in that users can deposit any amount and receive an equivalent payout based on the prevailing rate at the time the deposit is received.

Given that the API does not know the exact deposit amount, it is impossible to accurately estimate the price of the swap beforehand (due to market depth issues on most cryptocurrencies). For this reason, the specific price of the swap will be quoted when a deposit is received by one of the blockchain nodes on the faast network.

To create a variable price swap, simply omit the deposit_amount when calling the /swap endpoint.

Affiliate Program

Question: Why should I integrate with the faast API and not XYZ API?

Answer: Faast provides the best opportunity for revenue generation as an API integrator.

Earn revenue today by integrating the Faast swap API into your product or service! No sign up is required, and payouts are instant!

Faast allows API integrators to quickly and easily earn revenue by setting a specific percentage of each swap they would like to earn as a commission. Contrary to competitive implementations, the faast affiliate program allows the developer to choose the exact commission they would like to earn.

All earned commission is paid in Bitcoin to the developers specified Bitcoin address. Affiliate payouts are paid in batches after the affiliate commission amount has reached 0.01BTC.

How it works:

When generating a swap on behalf of a customer, simply add the affiliate_margin and affiliate_payment_address field to the request API.

Then, when the customer deposits funds for the swap, the following will happen:

  1. The price the customer is quoted will be adjusted down by affiliate_margin
  2. An equivalent amount of Bitcoin (deposit_amount * affiliate_margin) will be withheld for an affiliate payout
  3. The customer will receive their withdrawal_currency payout
  4. After the total affiliate payout for a specific affiliate_payment_address reaches 0.01BTC, it will automatically be sent in a bitcoin transaction.

Affiliate margin

The affiliate margin is a percentage (from 0 to 5) an affiliate would like to charge its customers. Faast prices its swaps based on the prevailing rates on the market, plus an approximate 0.5% fee. Affiliate margins are applied on-top of faast’s native fee.

It is suggested that affiliates make clear to their users the affiliate margin being applied to a swap. The recommended margin is `0.5%``, but affiliates are welcome to vary this rate based on business opportunities and application.

Affiliate payment address

Affiliates are recommended to use a single affiliate payment address to simplify accounting. To minimize blockchain bloating, affiliate payouts will be made after the total affiliate commission for a specific address reaches 0.01 BTC.

Affiliate payment addresses must be Bitcoin addresses. If an affiliate prefers to receive their payouts in a different currency, there is a solution! Simply create a variable-rate BTC -> Currency swap using the faast API, and use the BTC deposit address as an affiliate_payment_address. Every time an affiliate payout is sent, it will automatically be converted to the desired payout currency.

Integration Testing

faast provides a staging server that can be used for integration testing. It provides the same API, but with the following differences:

  • It uses the TestNet bitcoin and ethereum (ropsten) test network, and thus expects testnet addresses and coins (eg. mqdofsXHpePPGBFXuwwypAqCcXi48Xhb2f)

  • ERC20 Tokens are all a single custom faast Token on ropsten address: 0xe72bbed5cf09686c62ed5be8f571a7670c11c468

  • testnet coins may or may not be sent to the testnet address provided, depending on how our staging servers are configured

The testing base url is https://testapi.faa.st

Authentication

faast currently has no authentication required. In the future, authentication may be required for additional features or preferred pricing.

Base URL

Production

The production base URL is https://api.faa.st

Test

The test base URL is https://testapi.faa.st

GET Requests

Get a price

Get a price
GET/api/v2/public/price/{pair}

This will return a price for a selected currency pair

Example URI

GET /api/v2/public/price/BTC_ETH
URI Parameters
HideShow
pair
string (required) Example: BTC_ETH

The pair is depositCurrency_withdrawalCurrency.

Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
  "pair": "BTC_ETH",
  "price": 0.04726611,
  "deposit_amount": 0,
  "minimum_deposit": 0.00028219
}

Get supported currencies

Get supported currencies
GET/api/v2/public/currencies

This will return a list of supported cryptocurrencies on faast. Make close note of the returned deposit and receive fields. deposit indicates if swaps can be created with the currency as the deposit_currency. receive indicates if the specific currency can be set as the withdrawal_currency in a swap.

Example URI

GET /api/v2/public/currencies
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
[
  {
    "name": "Bitcoin",
    "symbol": "BTC",
    "walletUrl": "https://copay.io",
    "deposit": true,
    "receive": true,
    "infoUrl": "https://bitcoin.org",
    "decimals": 8,
    "cmcID": "bitcoin",
    "iconUrl": "https://api.faa.st/api/v1/public/static/img/coins/icon_BTC.png"
  },
  {
    "name": "Ethereum",
    "symbol": "ETH",
    "walletUrl": "https://faa.st",
    "deposit": true,
    "receive": true,
    "infoUrl": "https://ethereum.org",
    "decimals": 18,
    "cmcID": "ethereum",
    "iconUrl": "https://api.faa.st/api/v1/public/static/img/coins/icon_ETH.png"
  },
  {
    "name": "Augur",
    "validate": "ETH",
    "symbol": "REP",
    "walletUrl": "https://faa.st",
    "deposit": true,
    "receive": true,
    "ERC20": true,
    "infoUrl": "https://etherscan.io/token/0x1985365e9f78359a9B6AD760e32412f4a445E862",
    "contractAddress": "0x1985365e9f78359a9B6AD760e32412f4a445E862",
    "decimals": 18,
    "cmcID": "augur",
    "iconUrl": "https://api.faa.st/api/v1/public/static/img/coins/icon_REP.png"
  }, ...
]

Query swaps by withdrawal_address or user_id

Query swaps by withdrawal_address or user_id
GET/api/v2/public/swaps{?withdrawal_address,page,limit}

Query swaps by withdrawal address or provided User ID. Results are paginated. “total” is the total matching results for the entire query.

Example URI

GET /api/v2/public/swaps?withdrawal_address="0x33ec06a42f7d6b4ceca597edaf28ff1580b283df"&page=5&limit=10
URI Parameters
HideShow
withdrawal_address
string (required) Example: "0x33ec06a42f7d6b4ceca597edaf28ff1580b283df"

find swaps for a given withdrawal address

user_id: "my_user_id_992"
string (required) 

find swaps for a given client-provided user ID

limit
string (required) Example: 10

number of results returned per pagination page

page
string (required) Example: 5

page number of paginated results to return

Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
  "total": 1,
  "orders": [
    {
      "swap_id": "ab0d3433-723a-4b6e-8c1c-a487103c1eb1",
      "user_id": "my_user_id_992",
      "created_at": "2018-08-17T16:25:47.659Z",
      "updated_at": "2018-08-17T17:01:14.130Z",
      "deposit_address": "0x94fa1b52E7B6282dad0213e17A8BF7B2538b4b1E",
      "deposit_amount": 0.02,
      "deposit_currency": "ETH",
      "spot_price": 0.03435726,
      "price": 0.037981955000000005,
      "price_locked_at": "2018-08-17T16:25:47.650Z",
      "price_locked_until": "2018-08-17T16:40:47.650Z",
      "withdrawal_address": "0x3d6Bb40C0dDe451812A935163cC57974063b8dA3",
      "withdrawal_currency": "BNB",
      "withdrawal_amount": 1.16252102,
      "status": "complete",
      "amount_deposited": 0.04,
      "amount_withdrawn": 1.16252102,
      "transaction_id": "0x849cfa8edde231c50cab8a4a3a2a1c8530797c870ef28b189cd5b58d63eb2ac2"
    }
  ]
}

POST Requests

Create a swap

Create a swap
POST/api/v2/public/swap

Create a new swap order, and generate a deposit address.

Example URI

POST /api/v2/public/swap
Request
HideShow
Headers
Content-Type: application/json
Body
{
  "user_id": "my_user_id_992", (optional, user provided ID to be used for historical order lookups)
  "deposit_amount": 0.02, (optional, specify amount for a fixed price swap)
  "deposit_currency": "ETH",
  "withdrawal_address": "0xf9357f4fdef81103ed55296649a7cacf04e80ef3",
  "withdrawal_currency": "BAT",
  "refund_address": "0xf9357f4fdef81103ed55296649a7cacf04e80ef3", (optional, address to send a refund if there are any issues)
  "affiliate_margin": 5, (optional, decimal from 0.0 to 5.0)
  "affiliate_payment_address": "mqdofsXHpePPGBFXuwwypAqCcXi48Xhb2f" (optional, Bitcoin address)
}
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
  "swap_id": "30711734-e4ee-4ff1-a45b-4020cef8488b",
  "user_id": "my_user_id_992",
  "created_at": "2018-08-17T18:08:59.004Z",
  "deposit_address": "0x94fa1b52E7B6282dad0213e17A8BF7B2538b4b1E",
  "deposit_amount": 0.02,
  "deposit_currency": "ETH",
  "spot_price": 0.03399216,
  "price": 0.035870226,
  "price_locked_at": "2018-08-17T18:08:58.829Z",
  "price_locked_until": "2018-08-17T18:23:58.829Z",
  "withdrawal_address": "0x3d6Bb40C0dDe451812A935163cC57974063b8dA3",
  "withdrawal_currency": "BNB",
  "affiliate_margin": 5,
  "affiliate_payment_address": "mqdofsXHpePPGBFXuwwypAqCcXi48Xhb2f"
}

Fetch a swap

Fetch a swap
GET/api/v2/public/swaps/{swapId}

Get the status of a swap by its ID.

Example URI

GET /api/v2/public/swaps/3f1c1a39...
URI Parameters
HideShow
swapId
string (required) Example: 3f1c1a39...

swap_id from Create swap response

Request
HideShow
Headers
Content-Type: application/json
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
  "swap_id": "3f1c1a39-de8f-457d-ae2f-11383acd9403",
  "created_at": "2018-08-16T20:04:48.950Z",
  "updated_at": "2018-08-17T22:14:54.620Z",
  "user_id": "my_user_id_992",
  "deposit_address": "0x94fa1b52E7B6282dad0213e17A8BF7B2538b4b1E",
  "deposit_amount": 0.02,
  "deposit_currency": "ETH",
  "spot_price": 0.03375493,
  "price": 0.03731607000000001,
  "price_locked_at": "2018-08-17T22:14:54.619Z",
  "price_locked_until": "2018-08-17T22:29:54.619Z",
  "withdrawal_address": "0x3d6Bb40C0dDe451812A935163cC57974063b8dA3",
  "withdrawal_amount": 0.53596212,
  "withdrawal_currency": "BNB",
  "refund_address": null,
  "affiliate_margin": 10,
  "affiliate_payment_address": "mqdofsXHpePPGBFXuwwypAqCcXi48Xhb2f",
  "status": "awaiting deposit"
}

Fetch/Refresh a swap

Fetch/Refresh a swap
POST/api/v2/public/swaps/{swapId}/refresh

Get the status of a swap by its ID. If the guaranteed price has expired, a new price will be set.

Example URI

POST /api/v2/public/swaps/3f1c1a39.../refresh
URI Parameters
HideShow
swapId
string (required) Example: 3f1c1a39...

swap_id from Create swap response

Request
HideShow
Headers
Content-Type: application/json
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
  "swap_id": "3f1c1a39-de8f-457d-ae2f-11383acd9403",
  "created_at": "2018-08-16T20:04:48.950Z",
  "updated_at": "2018-08-17T22:14:54.620Z",
  "user_id": "my_user_id_992",
  "deposit_address": "0x94fa1b52E7B6282dad0213e17A8BF7B2538b4b1E",
  "deposit_amount": 0.02,
  "deposit_currency": "ETH",
  "spot_price": 0.03375493,
  "price": 0.03731607000000001,
  "price_locked_at": "2018-08-17T22:14:54.619Z",
  "price_locked_until": "2018-08-17T22:29:54.619Z",
  "withdrawal_address": "0x3d6Bb40C0dDe451812A935163cC57974063b8dA3",
  "withdrawal_amount": 0.53596212,
  "withdrawal_currency": "BNB",
  "refund_address": null,
  "affiliate_margin": 10,
  "affiliate_payment_address": "mqdofsXHpePPGBFXuwwypAqCcXi48Xhb2f",
  "status": "awaiting deposit"
}

History

Version 0.1:

  • Add currently supported APIs

  • GET rate

  • GET txStat

  • POST shift

  • Add initial list of supported Deposit and withdrawal Currencies

Version 0.2:

  • Removed list of supported currencies from doc, use v1 currencies API to get currency list

  • Removed /shift

  • Removed /txStat

  • Add initial v2 APIs

  • GET price

  • GET swaps

  • POST swap

  • POST swap/refresh

Version 0.2.1:

  • Fixed lack of URI parameter in refresh API

Version 0.3.0:

  • added GET swap

Generated by aglio on 17 Sep 2018