In the meantime, if you are interested in generating your own, you can access our full Open API/Swagger spec here.
This is the documentation for the PHP SDK for Basiq.io API
Basiq.io PHP SDK is a set of tools you can use to easily communicate with Basiq API. If you want to get familiar with the API docs, click here.
The SDK is organized to mirror the HTTP API's functionality and hierarchy. The top level object needed for SDKs functionality is the Session object which requires your API key to be instantiated. You can grab your API key on the dashboard.
1.1.0 Added support for secondaryLoginId
0.9.1beta - getTransactions now receives limit parameter. Fixed bug on refresh all connections
0.9.0beta - Initial release
Now that you have your API key, you can use the following command to install the SDK:
composer require basiqio/basiq-sdk-php
Next step is to import the used classes into your namespace. A list of classes you will probably use the most:
// Used to handle the token session
use Basiq\Session;
// Used to manipulate jobs and connections
use Basiq\Services\ConnectionService;
// Used to manipulate users
use Basiq\Services\UserService;
You can fetch a list of supported financial institutions. The function returns a list of Institution structs.
use Basiq\Session;
$session = new Session("YOUR_API_KEY");
$institutions = $session->getInstitutions();
You can specify the version of API when instantiating Session object. When the version is not specified, default version is 1.0.
use Basiq\Session;
$session = new Session("YOUR_API_KEY", "2.0");
$institutions = $session->getInstitutions();
When a new connection request is made, the server will create a job that will link user's financial institution with your app.
use Basiq\Session;
$session = new Session("YOUR_API_KEY");
$user = $session->forUser($userId);
$job = $user->createConnection($institutionId, $userId, $password[, $securityCode, $secondaryLoginId]);
// Poll our server to wait for the credentials step to be evaluated
$connection = job->waitForCredentials(1000, 60);
In this example, the function returns a transactions list struct which is filtered by the connection->id property. You can iterate through transactions list by calling Next().
use Basiq\Session;
use Basiq\Utilities\FilterBuilder;
$session = new Session("YOUR_API_KEY");
$user = $session->forUser($userId);
$fb = new FilterBuilder();
$fb->eq("connection->id", "conn-id-213-id");
$transactions = $user->getTransactions($fb);
while ($transactions->next()) {
var_dump("Next transactions len:", len(transactions.Data))
}
The API of the SDK is manipulated using Services and Entities. Different services return different entities, but the mapping is not one to one.
If an action encounters an error, you will receive an HTTPResponseException instance. The class contains all available data which you can use to act accordingly.
public $response;
public $statusCode;
public $message;
Check the docs for more information about relevant fields in the error object.
Some of the methods support adding filters to them. The filters are created using the FilterBuilder class. After instantiating the class, you can invoke methods in the form of comparison(field, value).
Example:
use Basiq\Utilities\FilterBuilder;
$fb = new FilterBuilder();
$fb->eq("connection->id", "conn-id-213-id")->gt("transaction.postDate", "2018-01-01")
$transactions = $user->getTransactions(fb);
This example filter for transactions will match all transactions for the connection with the id of "conn-id-213-id" and that are newer than "2018-01-01". All you have to do is pass the filter instance when you want to use it.
Services
$session = new Session("YOUR_API_KEY");
The following are APIs available for the User service
$userService = new UserService($session);
Note: The following action will not send an HTTP request, and can be used to perform additional actions for the instantiated user.
$user = $userService->forUser($userId);
$user = $userService->create(["email" => "", "mobile" => ""]);
$user = $userService->get($userId);
$user = $userService->update($userId, ["email" => "", "mobile" => ""]);
null = $userService->delete($userId);
$jobs = $userService->refreshAllConnections($userId);
$conns = $userService->getAllConnections($userId[, $filter]);
$acc = $userService->getAccount($userId, $accountId);
$accs = $userService->getAccounts($userId[, $filter]);
$transaction = $userService->getTransaction($userId, $transactionId);
$transactions = $userService->getTransactions($userId[, $filter]);
The following are APIs available for the Connection service
$connService = new ConnectionService($session, $user);
$connection = $connService->get($connectionId);
$connection = $connService->for($connectionId);
$job = $connService->create(["institutionId" => "", "loginId" => "", "password" => "", "securityCode" => "", "secondaryLoginId" => ""]);
$job = $connService->update($connectionId, $password);
null = $connService->delete($connectionId);
$job = $connService->getJob($jobId);
Entities
$user = $user->update(["email" => "", "mobile" => ""]);
null = $user->delete();
$accounts = $user->getAccounts();
$account = $user->getAccount($accountId);
$transactions = $user->getTransactions($filterBuilder = null, $limit = null < 500);
$transaction = $user->getTransaction($transactionId);
$job = $user->createConnection(["institutionId" => "", "loginId" => "", "password" => "", "securityCode" => "", "secondaryLoginId" => ""]);
$jobs = $user->refreshAllConnections();
$job = $connection->refresh();
$job = $connection->update($password);
null = $connection->delete();
$connectionId = $job->getConnectionId();
$connection = $job->getConnection();
(interval is in milliseconds, timeout is in seconds; in case of timeout an exception will be thrown)
$connection = $job->waitForCredentials($interval, $timeout);
(interval is in milliseconds, timeout is in seconds; in case of timeout an exception will be thrown)
$connection = $job->waitForTransactions($interval, $timeout);
$next = $transactions->next();