DFXswiss / api

DFX API
https://api.dfx.swiss
MIT License
12 stars 31 forks source link

DFX API

DFX is a crypto on- and off-ramp with an open API that can be integrated by anyone. This page explains the basic concepts of the API. If you don't want to bother with API calls, you can integrate our ready-to-use web widget with a few lines of code (see the services repository) or use our React API npm package.

API Documentation

Swagger

Authentication

Each user who wants to use the service must be registered separately with their blockchain address and a signature to prove ownership.

Initial Wallet Setup (optional)

Contact support to register your wallet name. This is used to identify all users that signed up with your wallet. This step is optional.

Sign-Up / Sign-In

  1. Get the sign message from sign-message endpoint (with the user's address) and sign it with the corresponding private key
  2. Sign the user up or in with the auth endpoint. This call will register a new user, if the user does not exist yet. If there is already a user with the same address, the user will be signed in. The response contains a JWT access token, which can be used for further API calls. usedRef, wallet and specialCode parameters are optional. usedRef and wallet are only taken into account on user registration.
    • Use the wallet name (wallet) from step initial setup
    • See below for more information on the referral program (usedRef)

Alternatively the sign-up and sign-in endpoints can be used if only one functionality (sign-up or sign-in) is required.

Notifications

If a user wants to get notified about ongoing transactions, he can register his email address with the user endpoint

Referral Program

KYC (optional)

KYC is not required for a daily transaction volume up to 1000 CHF. To increase the transaction volume, the user needs to be verified with a KYC process, which can be done on the DFX KYC page. Just open then link to the KYC page with the user's API access token: https://services.dfx.swiss/kyc?session=<jwt-access-token>

The current KYC level of a user can be read using the user endpoint. The different levels are listed below.

Transactions

Buy Crypto

Get a quote

  1. Get all available assets with the asset endpoint
    • This endpoint will return all assets compatible with the user's address, which might be assets on multiple blockchains. The query parameter (optional) can be used to filter for specific blockchains.
    • Only assets with the buyable field set to true can be bought
  2. Get all available currencies with the fiat endpoint
    • Only fiats with the sellable field set to true can be used to buy crypto
  3. Get a quote with the buy quote endpoint

Get payment infos

  1. Get all available assets with the asset endpoint
    • This endpoint will return all assets compatible with the user's address, which might be assets on multiple blockchains. The query parameter (optional) can be used to filter for specific blockchains.
    • Only assets with the buyable field set to true can be bought
  2. Get all available currencies with the fiat endpoint
    • Only fiats with the sellable field set to true can be used to buy crypto
  3. Get the payment information with the buy payment endpoint
  4. Do a bank transfer with the provided payment infos
    • Ensure compliance with minimum deposit and KYC limits
  5. The crypto asset will be sent to the user's blockchain address as soon as the bank transfer is completed

Sell Crypto

Get a quote

  1. Get all available assets with the asset endpoint
    • Only assets with the sellable field set to true can be sold
  2. Get all available currencies with the fiat endpoint
    • Only fiats with the buyable field set to true can be used to sell crypto
  3. Get a quote with the sell quote endpoint

Get payment infos

In order to perform bank transactions, DFX needs to know the name and address of the recipient (KYC level ≥ 20). Therefore, user data must be collected once before a sale can be made. The user data can be updated with the kyc data endpoint. Required fields are accountType, mail, phone, firstname, lastName, address (street, city, zip, country). For non personal accounts, organizationName, organizationAddress (street, city, zip, country) are also required.

  1. Update user data, if required (check with kyc.dataComplete field from user endpoint)
  2. Get all available assets with the asset endpoint
    • Only assets with the sellable field set to true can be sold
  3. Get all available currencies with the fiat endpoint
    • Only fiats with the buyable field set to true can be used to sell crypto
  4. Get the payment information with the sell payment endpoint
  5. Do a blockchain transaction to the provided deposit address
    • Ensure compliance with minimum deposit and KYC limits
  6. The fiat will be sent to the specified bank account as soon as the blockchain transaction is completed

Bank Accounts (optional)

Integration Example