Swys.io, all rights reserved. © 2019

Introduction

Swys provides an API which enables developers to build upon the wallet and payment features of swys.

Getting Started

1. Create An Account

Create a Swys account here or log into the api console with your existing account.


2. Create A Client

Create an new client by supplying a valid email and platform and wait for it to be approved.


3. Add Allowed Origins

In the details page of your newly created client, navigate to the Allowed Origins tab and add your allowed origins.


4. Add A JWT Signing Secret

Add your JWT signing secret in the keys tab.


Accessing The API

API Host

The API can be accessed from

copy

https://api.swys.io/api/v1/client

Requests

All requests are POST requests. Request body should be valid JSON. Request Content Type should be application/json.

A page query parameter should be added to requests that return paginated data.

Example


https://api.swys.io/api/v1/client/transactions?page=1

Responses

All responses have a Content Type of application/json. All responses have a HTTP Status Code of 200. All responses contain a top level property status which indicates if the request was successful or not.

Successful requests will return a response with status of success and a message or data property depending on the type of request.

Unsuccessful requests will return a response with a status of error and a message property containing the error message.

Sample Success Response


{
  "status": "success",
  "message": "request was successful",
  "data": { ... }
}

Sample Error Response


{
  "status": "error",
  "message": "request was not successful"
}

User Endpoints

POST /auth

This authenticates a user. Creates a new user if user does not exist

Request Parameters

Parameter Type Required Description
API_TOKEN string yes SHA256 HMAC of the email generated with the client's public key
email string yes
first_name string no
last_name string no

Sample Success Response


{
  "status": "success",
  "data": {
    "token": "eyJhbGci...VCJ9.eyJzdWIi...IyfQ.SflK...sw5c"
  }
}

POST /user

This returns a user's profile information.

Parameters

Parameter Type Required Description
_token string yes

Sample Success Response


{
  "status": "success",
  "data": {
    "id": 5,
    "first_name": "Example",
    "middle_name": null,
    "last_name": "User",
    "email": "exampleuser@site.com",
    "dob": null,
    "phone_number": null,
    "picture": null,
    "city": null,
    "country": null,
    "type": null,
    "status": "active",
    "created_at": "2019-03-08 08:18:25",
    "updated_at": "2019-03-08 08:22:05"
  }
}

POST /update-profile

This update's a user's profile information.

Parameters

Parameter Type Required Description
_token string yes
first_name string yes
last_name string yes
middle_name string no
date_of_birth string no

Sample Success Response


{
  "status": "success",
  "message": "profile updated successfully"
}

POST /wallet

This returns a user's wallet information.

Parameters

Parameter Type Required Description
_token string yes

Sample Success Response


{
  "status": "success",
  "data": {
    "bhc": "0.00",
    "bhc_usd_equivalent": "0.00",
    "bhc_ledger": "0.00",
    "bhc_ledger_usd_equivalent": "0.00",
    "btc": "0.00",
    "btc_usd_equivalent": "0.00",
    "btc_ledger": "0.00",
    "btc_ledger_usd_equivalent": "0.00",
    "dash": "0.00",
    "dash_usd_equivalent": "0.00",
    "dash_ledger": "0.00",
    "dash_ledger_usd_equivalent": "0.00",
    "lgs": "0.00",
    "lgs_usd_equivalent": "0.00",
    "lgs_ledger": "0.00",
    "lgs_ledger_usd_equivalent": "0.00",
    "lpc": "0.00",
    "lpc_usd_equivalent": "0.00",
    "lpc_ledger": "0.00",
    "lpc_ledger_usd_equivalent": "0.00",
    "ltc": "0.00",
    "ltc_usd_equivalent": "0.00",
    "ltc_ledger": "0.00",
    "ltc_ledger_usd_equivalent": "0.00",
    "zcash": "0.00",
    "zcash_usd_equivalent": "0.00",
    "zcash_ledger": "0.00",
    "zcash_ledger_usd_equivalent": "0.00",
    "status": "normal"
  },
  "new": true
}

POST /withdraw

This initiates a withdrawal request for a user.

Parameters

Parameter Type Required Description
_token string yes
type string yes should either be fiat or coin
currency string yes
address string required if type is coin
amount string yes

Sample Success Response


{
  "status": "success",
  "message": "withdrawal successful"
}

POST /withdrawals

This returns a list of a user's withdrawal requests.

Parameters

Parameter Type Required Description
_token string yes

Sample Success Response


{
  "status": "success",
  "data": [
    {
      "id": 1,
      "client_id": 1,
      "email": "exampleuser@site.com",
      "type": "coin",
      "currency": "btc",
      "address": "xwaadsddfw42rf2edweda34",
      "amount": "0.001",
      "description": "withdrawal",
      "transaction_id": "5GynT6tqnBgjX3OYe012",
      "status": "completed",
      "created_at": "2019-03-08 08:18:25",
      "updated_at": "2019-03-08 08:22:05"
    }
  ]
}

POST /transactions

This returns a paginated list of a user's transactions.

Parameters

Parameter Type Required Description
_token string yes

Sample Success Response


{
  "status": "success",
  "data": {
    "current_page": 1,
    "per_page": 16,
    "last_page": 1,
    "data": [
      {
        "id": 1,
        "client_id": 1,
        "user_id": 1,
        "email": "admin@client.com",
        "type": "btc",
        "amount": "0.5",
        "balance": "0.001",
        "description": "some description",
        "transaction_id": "5GynT6tqnBgjX3OYe012",
        "received_by": "exampleuser@site.com"
        "confirmations": "0",
        "status": "in progress",
        "created_at": "2019-03-08 08:18:25",
        "updated_at": "2019-03-08 08:22:05"
      }
    ]
  }
}

POST /account/fiat

This adds a bank withdrawal account.

Parameters

Parameter Type Required Description
_token string yes
currency string yes
bank_name string yes
bank_country string yes
account_name string yes
account_number string yes
account_number_repeat string yes
routing_id string no
tax_id string no

Sample Success Response


{
  "status": "success",
  "message": "account added successfully"
}

POST /account/coin

This adds a coin withdrawal account.

Parameters

Parameter Type Required Description
_token string yes
currency string yes
coin_address string yes

Sample Success Response


{
  "status": "success",
  "message": "account added successfully"
}

POST /account/get

This returns a list of a user's withdrawal accounts.

Parameters

Parameter Type Required Description
_token string yes

Sample Success Response


{
  "status": "success",
  "data": [
    {
      "id": 1,
      "client_id": 1,
      "email": "exampleuser@site.com",
      "type": "fiat",
      "currency": "usd",
      "bank_name": "bank of america",
      "bank_country": "usa",
      "account_name": "Example User",
      "account_number": "******9090",
      "coin_address": null,
      "routing_id": "*******8080",
      "tax_id": "********4545",
      "status": "active",
      "created_at": "2029-01-01 00:00:00",
      "updated_at": "2029-01-01 00:00:00"
    }
  ]
}

POST /account/update

This updates a user's withdrawal account.

Parameters

Parameter Type Required Description
_token string yes
id string yes the account id
currency string yes
coin_address string no
bank_name string no
bank_country string no
account_name string no
account_number string no
account_number_repeat string no
routing_id string no
tax_id string no

Sample Success Response


{
  "status": "success",
  "message": "account updated successfully"
}

Admin Endpoints

This section contains endpoints related to users who have admin roles. Endpoints that require the role parameter should be passed any of the available roles. The available roles with their access levels are listed below

Role Access Levels
1 t_admin
  • view all user transactions
2 u_admin
  • block users
  • unblock users
  • view users profile and wallet information
  • credit users
  • debit users
  • withdraw for users
3 p_admin
  • view withdrawal requests
  • approve withdrawal requests
  • reject withdrawal requests
4 g_admin
  • can perform all admin functions


POST /admin/login

This authenticates an admin user.

Request Parameters

Parameter Type Required Description
API_TOKEN string yes SHA256 HMAC of the email generated with the client's public key
email string yes

Sample Success Response


{
  "status": "success",
  "data": {
    "token": "eyJhbGci...VCJ9.eyJzdWIi...IyfQ.SflK...sw5c"
  }
}

POST /admin/users

This returns a list of users.

Request Parameters

Parameter Type Required Description
_token string yes

Sample Success Response


{
  "status": "success",
  "data": {
    "current_page": 1,
    "per_page": 16,
    "last_page": 1,
    "data": [
      {
        "id": 5,
        "first_name": "Example",
        "middle_name": null,
        "last_name": "User",
        "email": "exampleuser@site.com",
        "dob": null,
        "phone_number": null,
        "picture": null,
        "city": null,
        "country": null,
        "type": null,
        "status": "active",
        "created_at": "2019-03-08 08:18:25",
        "updated_at": "2019-03-08 08:22:05"
      }
    ]
  }
}

POST /admin/user

This returns a single user's information.

Request Parameters

Parameter Type Required Description
_token string yes
id integer yes the user's id

Sample Success Response


{
  "status": "success",
  "data": {
    "user": {
      "id": 3,
      "first_name": "Example",
      "middle_name": null,
      "last_name": "User",
      "email": "exampleuser@site.com",
      "dob": "2019-03-12",
      "phone_number": null,
      "picture": null,
      "city": null,
      "country": null,
      "type": "freelancer",
      "status": "active"
    },
    "wallet": {
      "bch": "0.00",
      "bch_ledger": "0.00",
      "bch_usd_equivalent": "0",
      "bch_ledger_usd_equivalent": "0",
      "btc": "0.00",
      "btc_ledger": "0.00",
      "btc_usd_equivalent": "0",
      "btc_ledger_usd_equivalent": "0",
      "dash": "0.00",
      "dash_ledger": "0.00",
      "dash_usd_equivalent": "0",
      "dash_ledger_usd_equivalent": "0",
      "eth": "0.00",
      "eth_ledger": "0.00",
      "eth_usd_equivalent": "0",
      "eth_ledger_usd_equivalent": "0",
      "lgs": "0.00",
      "lgs_ledger": "0.00",
      "lgs_usd_equivalent": "0",
      "lgs_ledger_usd_equivalent": "0",
      "lpc": "59.00",
      "lpc_ledger": "179.50",
      "lpc_usd_equivalent": "2",
      "lpc_ledger_usd_equivalent": "6",
      "ltc": "0.00",
      "ltc_ledger": "0.00",
      "ltc_usd_equivalent": "0",
      "ltc_ledger_usd_equivalent": "0",
      "zcash": "0.00",
      "zcash_ledger": "0.00",
      "zcash_usd_equivalent": "0",
      "zcash_ledger_usd_equivalent": "0",
      "aud": "0.00",
      "aud_ledger": "0.00",
      "cad": "0.00",
      "cad_ledger": "0.00",
      "chf": "0.00",
      "chf_ledger": "0.00",
      "cny": "0.00",
      "cny_ledger": "0.00",
      "eur": "0.00",
      "eur_ledger": "0.00",
      "gbp": "0.00",
      "gbp_ledger": "0.00",
      "jpy": "0.00",
      "jpy_ledger": "0.00",
      "nzd": "0.00",
      "nzd_ledger": "0.00",
      "sek": "0.00",
      "sek_ledger": "0.00",
      "usd": "10.00",
      "usd_ledger": "10.00"
    },
    "transactions": [
      {
        "id": 1,
        "client_id": 1,
        "user_id": "1",
        "email": "admin@client.com",
        "type": "btc",
        "amount": "0.001",
        "balance": "0.00",
        "time_created": "2019-03-22 09:33:06",
        "description": "registration bonus",
        "transaction_id": "ZeY0U2HB7T21iG2Y69ZD",
        "recieved_by": "exampleuser@site.com",
        "confirmations": null,
        "fee": null,
        "status": "pending",
        "created_at": "2019-03-22 09:33:06",
        "updated_at": "2019-03-22 09:33:06",
        "ledger_period": 90
      }
    ],
    "withdrawals": [
      {
        "id": 1,
        "client_id": 1,
        "email": "exampleuser@site.com",
        "type": "coin",
        "currency": "btc",
        "address": "nd03hfn0cwwpfenwefn0923f",
        "amount": "10",
        "description": "withdrawal",
        "transaction_id": "ytq5yGyMeB1ByPfMaQ11",
        "status": "pending",
        "created_at": "2019-03-22 11:31:27",
        "updated_at": "2019-03-22 11:31:27"
      }
    ]
  }
}

POST /admin/search-users

This searches for a user.

Request Parameters

Parameter Type Required Description
_token string yes
query string yes

Sample Success Response


{
  "status": "success",
  "data": [
    {
      "id": 5,
      "first_name": "Example",
      "middle_name": null,
      "last_name": "User",
      "email": "exampleuser@site.com",
      "dob": null,
      "phone_number": null,
      "picture": null,
      "city": null,
      "country": null,
      "type": null,
      "status": "active",
      "created_at": "2019-03-08 08:18:25",
      "updated_at": "2019-03-08 08:22:05"
    }
  ]
}

POST /admin/block

This blocks a user.

Request Parameters

Parameter Type Required Description
_token string yes
email string yes the user's email

Sample Success Response


{
  "status": "success",
  "message": "user blocked successfully"
}

POST /admin/unblock

This unblocks a user.

Request Parameters

Parameter Type Required Description
_token string yes
email string yes the user's email

Sample Success Response


{
  "status": "success",
  "message": "user unblocked successfully"
}

POST /admin/debit-user/:amount

This debits a user's wallet. The amount is passed as a url parameter.

Request Parameters

Parameter Type Required Description
_token string yes
email string yes the user's email
coin string yes
description string description

Sample Success Response


{
  "status": "success",
  "message": "the debit was successful"
}

POST /admin/credit-user/:amount

This credits a user's wallet. The amount is passed as a url parameter.

Request Parameters

Parameter Type Required Description
_token string yes
email string yes the user's email
coin string yes
description string no
ledger_period integer no number of days before funds is available for withdrawal

Sample Success Response


{
  "status": "success",
  "message": "the credit was successful"
}

POST /admin/add-admin

This adds the t_admin role to a user.

Request Parameters

Parameter Type Required Description
_token string yes
email string yes

Sample Success Response


{
  "status": "success",
  "message": "exampleuser@site.com added as t_admin"
}

POST /admin/remove-admin

This removes admin role from a user.

Request Parameters

Parameter Type Required Description
_token string yes
email string yes

Sample Success Response


{
  "status": "success",
  "message": "exampleuser@site.com admin role has been removed"
}

POST /admin/change-admin-role

This changes an admin's role.

Request Parameters

Parameter Type Required Description
_token string yes
email string yes
role string yes

Sample Success Response


{
  "status": "success",
  "message": "exampleuser@site.com admin role changed to g_admin"
}

POST /admin/admins

This returns all admin's information and activities.

Request Parameters

Parameter Type Required Description
_token string yes

Sample Success Response


{
  "status": "success",
  "data": [
    {
      "id": 1,
      "first_name": "Example",
      "middle_name": null,
      "last_name": "Admin",
      "email": "exampleadmin@site.com",
      "dob": null,
      "phone_number": "",
      "country": null,
      "type": null,
      "status": "active",
      "activities": [
        {
          "id": 1,
          "client_id": 1,
          "email": "exampleadmin@site.com",
          "description": "Example Admin approved Example User's withdrawal of 1 btc",
          "status": null,
          "created_at": "2019-03-25 12:56:26",
          "updated_at": "2019-03-25 12:56:26"
        }
      ],
      "role": {
        "id": 1,
        "client_id": 1,
        "email": "exampleadmin@site.com",
        "role": "admin",
        "status": "active",
        "created_at": "2019-03-25 11:48:12",
        "updated_at": "2019-03-22 00:00:00"
      }
    }
  ]
}

POST /admin/admin

This returns a single admin's information and activities.

Request Parameters

Parameter Type Required Description
_token string yes
id integer yes the admin's id

Sample Success Response


{
  "status": "success",
  "data": {
    "id": 1,
    "first_name": "Example",
    "middle_name": null,
    "last_name": "Admin",
    "email": "exampleadmin@site.com",
    "dob": null,
    "phone_number": "",
    "country": null,
    "type": null,
    "status": "active",
    "activities": [
      {
        "id": 1,
        "client_id": 1,
        "email": "exampleadmin@site.com",
        "description": "Example Admin approved Example User's withdrawal of 1 btc",
        "status": null,
        "created_at": "2019-03-25 12:56:26",
        "updated_at": "2019-03-25 12:56:26"
      }
    ],
    "role": {
      "id": 1,
      "client_id": 1,
      "email": "exampleadmin@site.com",
      "role": "admin",
      "status": "active",
      "created_at": "2019-03-25 11:48:12",
      "updated_at": "2019-03-22 00:00:00"
    }
  }
}

POST /admin/withdrawals

This returns a paginated list of withdrawal requests.

Request Parameters

Parameter Type Required Description
_token string yes

Sample Success Response


{
  "status": "success",
  "data": {
    "currrent_page": 1,
    "last_page": 1,
    "per_page": 16,
    "data": [
      {
        "id": 1,
        "email": "exampleuser@site.com",
        "type": "coin",
        "currency": "lpc",
        "address": "Yhsyah78ygIUG9ujja0",
        "amount": "0.90",
        "description": "withdrawal",
        "transaction_id": "j5z5YLB52qklNc6CwGeI",
        "status": "pending",
        "created_at": "2019-02-06 11:46:01",
        "updated_at": "2019-02-06 11:46:01",
        "user_data": {
          "id": 1,
          "first_name": "Example",
          "middle_name": null,
          "last_name": "User",
          "email": "exampleuser@site.com",
          "dob": null,
          "phone_number": null,
        }
      }
    ]
  }
}

POST /admin/withdrawal

This returns a single withdrawal request.

Request Parameters

Parameter Type Required Description
_token string yes
id integer yes the withdrawal id

Sample Success Response


{
  "status": "success",
  "data": {
    "id": 1,
    "email": "exampleuser@site.com",
    "type": "coin",
    "currency": "lpc",
    "address": "Yhsyah78ygIUG9ujja0",
    "amount": "0.90",
    "description": "withdrawal",
    "transaction_id": "j5z5YLB52qklNc6CwGeI",
    "status": "pending",
    "created_at": "2019-02-06 11:46:01",
    "updated_at": "2019-02-06 11:46:01",
    "user_data": {
      "id": 1,
      "first_name": "Example",
      "middle_name": null,
      "last_name": "User",
      "email": "exampleuser@site.com",
      "dob": null,
      "phone_number": null,
    }
  }
}

POST /admin/withdrawal/approve/stage1

This approves the first stage of a withdrawal request.

Request Parameters

Parameter Type Required Description
_token string yes
id integer yes the withdrawal id

Sample Success Response


{
  "status": "success",
  "message": "withdrawal approved"
}

POST /admin/withdrawal/approve/stage2

This approves the second stage of a withdrawal request.

Request Parameters

Parameter Type Required Description
_token string yes
id integer yes the withdrawal id

Sample Success Response


{
  "status": "success",
  "message": "withdrawal approved"
}

POST /admin/withdrawal/reject

This rejects a withdrawal request.

Request Parameters

Parameter Type Required Description
_token string yes
id integer yes the withdrawal id

Sample Success Response


{
  "status": "success",
  "message": "withdrawal rejected"
}

POST /admin/activities

This returns activities performed by admins.

Request Parameters

Parameter Type Required Description
_token string yes

Sample Success Response


{
  "status": "success",
  "data": [
    {
      "id": 1,
      "client_id": 1,
      "email": "exampleadmin@site.com",
      "description": "Example Admin approved Example User's withdrawal of 1 btc",
      "status": null,
      "created_at": "2019-03-25 12:56:26",
      "updated_at": "2019-03-25 12:56:26"
    }
  ]
}

POST /admin/ledger

This returns a paginated list transactions of all users.

Request Parameters

Parameter Type Required Description
_token string yes

Sample Success Response


{
  "status": "success",
  "data": {
    "current_page": 1,
    "per_page": 16,
    "last_page": 1,
    "data": [
      {
        "id": 1,
        "client_id": 1,
        "user_id": 1,
        "email": "admin@client.com",
        "type": "btc",
        "amount": "0.5",
        "balance": "0.001",
        "description": "some description",
        "transaction_id": "5GynT6tqnBgjX3OYe012",
        "received_by": "exampleuser@site.com"
        "confirmations": "0",
        "status": "in progress",
        "created_at": "2019-03-08 08:18:25",
        "updated_at": "2019-03-08 08:22:05"
      }
    ]
  }
}

POST /admin/api-key

This returns the client's api key.

Request Parameters

Parameter Type Required Description
_token string yes

Sample Success Response


{
  "status": "success",
  "data": {
    "api_key": "abf3760fbad0e80abd0ebc0deb0abd0eba"
  }
}

POST /admin/api-key/regenerate

This regenerates the client's api key.

Request Parameters

Parameter Type Required Description
_token string yes

Sample Success Response


{
  "status": "success",
  "message": "new key generated"
}

POST /admin/me

This returns the current admin's profile information.

Request Parameters

Parameter Type Required Description
_token string yes

Sample Success Response


{
  "status": "success",
  "data": {
    "id": 1,
    "first_name": "Example",
    "middle_name": null,
    "last_name": "Admin",
    "email": "exampleadmin@site.com",
    "dob": null,
    "phone_number": null,
    "country": null,
    "type": null,
    "status": "active",
    "role": {
      "id": 1,
      "client_id": 1,
      "email": "exampleadmin@site.com",
      "role": "admin",
      "status": "active",
      "created_at": "2019-03-25 11:48:12",
      "updated_at": "2019-03-22 00:00:00"
    }
  }
}

POST /admin/update-profile

This update's the current admin's profile information.

Parameters

Parameter Type Required Description
_token string yes
first_name string yes
last_name string yes
middle_name string no
phone_number string no
date_of_birth string no

Sample Success Response


{
  "status": "success",
  "message": "profile updated successfully"
}                 

JWT Endpoints

These endpoints require parameters that are JWTs signed with your JWT signing secret using the HMAC SHA256 algorithm.

POST /auth

This authenticates a user. Creates a new user if user does not exist

Request Parameters

Parameter Type Required Description
authToken JWT yes Payload should contain
API_TOKEN (required),
EmailID (required),
FirstName,
LastName,
UserRole,
Country

Sample Success Response


{
  "status": "success",
  "data": {
    "token": "eyJhbGci...VCJ9.eyJzdWIi...IyfQ.SflK...sw5c"
  }
}

POST /wallet-info

This returns a user's wallet information

Request Parameters

Parameter Type Required Description
emailToken JWT yes Payload should contain email (required)

Sample Success Response


{
  "status": "success",
  "data": {
    "bhc": "0.00",
    "bhc_usd_equivalent": "0.00",
    "bhc_ledger": "0.00",
    "bhc_ledger_usd_equivalent": "0.00",
    "btc": "0.00",
    "btc_usd_equivalent": "0.00",
    "btc_ledger": "0.00",
    "btc_ledger_usd_equivalent": "0.00",
    "dash": "0.00",
    "dash_usd_equivalent": "0.00",
    "dash_ledger": "0.00",
    "dash_ledger_usd_equivalent": "0.00",
    "lgs": "0.00",
    "lgs_usd_equivalent": "0.00",
    "lgs_ledger": "0.00",
    "lgs_ledger_usd_equivalent": "0.00",
    "lpc": "0.00",
    "lpc_usd_equivalent": "0.00",
    "lpc_ledger": "0.00",
    "lpc_ledger_usd_equivalent": "0.00",
    "ltc": "0.00",
    "ltc_usd_equivalent": "0.00",
    "ltc_ledger": "0.00",
    "ltc_ledger_usd_equivalent": "0.00",
    "zcash": "0.00",
    "zcash_usd_equivalent": "0.00",
    "zcash_ledger": "0.00",
    "zcash_ledger_usd_equivalent": "0.00",
    "status": "normal"
  },
  "new": false
}

POST /debit-user

This debits a user's wallet.

Request Parameters

Parameter Type Required Description
walletToken JWT yes Payload should contain
email (required),
coin (required),
amount (required),
description,

Sample Success Response


{
  "status": "success",
  "message": "the debit was successful"
}

POST /credit-user

This credits a user's wallet.

Request Parameters

Parameter Type Required Description
walletToken JWT yes Payload should contain
email (required),
coin (required),
amount (required),
ledger_period,
description,

Sample Success Response


{
  "status": "success",
  "message": "the credit was successful"
}