Search…
Server-Side Libraries
This section explains how you can integrate Passbase into your backend and interact with our API.

General

Some clients are legally required to hold a copy of their customers' Personal data. In this case, you can retrieve any of the Data points relative to a Verification from the Passbase API:
  • The Data points required in the Verification (i.e first name, last name, document number, identity score)
  • Any metadata relative to the Verification (i.e. user agent, timestamp, user references)
We recommend you request & store as few pieces of information as possible about your users on your side. This decreases your data liability to the extent, that you only have to protect the data you truly need. If you only care that a user has been verified or is over a certain age, then you should store this as a boolean (true/false) once Passbase has completed the identity or age verification of that user.

API Key

In the previous sections, we worked with the client-side SDKs. We used the publishable API key there. Since we are now working in a server-to-server environment, you need to use the secret API key. Please never share this API key or commit it to a repo, since it gives access to your sensitive user data. If you leak this API key, a potential bad actor could retrieve and expose information about the identities of your users.
Be very careful with the secret API key. Never share it or send it through unencrypted communication methods!

Install a Server-Side Library

Follow the instructions below to install the latest Passbase server-side library in your backend project.
Javascript
Python
Java
Go
Ruby
PHP
1
/*
2
Add @passbase/node npm package to your package.json.
3
Passbase has no dependency but expects node version to be LTS (12.x).
4
*/
5
6
// Run
7
npm install @passbase/node --save
8
Copied!
1
"""
2
Add Passbase's SDK package to your requirements.txt.
3
The SDK should work on both python 2.7 and 3+
4
"""
5
6
pip install passbase_sdk && pip freeze | grep passbase_sdk >> requirements.txt
7
Copied!
1
// Maven users, add this dependency to your project's POM:
2
3
<dependency>
4
<groupId>com.passbase</groupId>
5
<artifactId>passbase</artifactId>
6
<version>0.0.1</version>
7
<scope>compile</scope>
8
</dependency>
9
10
//Gradle users, add this dependency to your project's build.gradle:
11
12
compile "com.passbase:passbase:0.0.1"
Copied!
1
// Add Passbase to your dependencies
2
3
go get github.com/passbase/passbase-go
Copied!
1
# Add Passbase's SDK gem to your Gemfile.
2
3
gem 'passbase', '~> 0.0.1'
Copied!
1
2
//To install the bindings via Composer, add the following to `composer.json`:
3
4
{
5
"repositories": [
6
{
7
"type": "git",
8
"url": "https://github.com/passbase/passbase-php.git"
9
}
10
]
11
}
12
13
// Then run composer install
14
Copied!

Usage of the Library

You can use the sample code below to initialize the server-side libraries and interact with the Passbase API. Please do not forget to use your secret API key in the header. The code below shows an example of how to request data from the Passbase API.
You can find more information about all the different functions/methods of the server-side libraries on their individual Github repository.
Javascript
Python
Java
Go
Ruby
PHP
1
const {
2
PassbaseClient,
3
PassbaseConfiguration,
4
ResponseFormats,
5
} = require("@passbase/node");
6
7
async function main() {
8
const apiKey = "YOUR_SECRET_API_KEY";
9
10
// Configure the SDK with your API Secret access key
11
const config = new PassbaseConfiguration({
12
apiKey,
13
format: ResponseFormats.Json,
14
});
15
const client = new PassbaseClient(config);
16
17
// Get project settings
18
const settings = await client.getProjectSettings();
19
console.log(JSON.stringify(settings, null, 4));
20
}
21
22
main().catch(err => {
23
console.error(err);
24
process.exit(1);
25
});
Copied!
1
import passbase
2
from pprint import pprint
3
4
# Configure the SDK with your API Secret access key
5
configuration = passbase.Configuration()
6
configuration.api_key["X-API-KEY"] = "YOUR_SECRET_API_YEY"
7
api_client = passbase.ApiClient(configuration)
8
api_instance = passbase.ProjectApi(api_client)
9
10
try:
11
# Get project settings
12
api_response = api_instance.get_settings()
13
pprint(api_response)
14
15
except Exception as e:
16
print("Exception when calling ProjectApi->get_settings: %s\n" % e)
17
Copied!
1
2
import com.passbase.*;
3
import com.passbase.api.ProjectApi;
4
import com.passbase.model.ProjectSettings;
5
import java.util.List;
6
import java.util.Map;
7
8
public final class App {
9
public static void main(String[] args) {
10
11
// Configure the SDK with your API Secret access key
12
ApiClient defaultClient = Configuration.getDefaultApiClient();
13
defaultClient.setApiKey("YOUR_SECRET_API_KEY");
14
ProjectApi apiInstance = new ProjectApi(defaultClient);
15
16
try {
17
// Get project settings
18
ProjectSettings settings = apiInstance.getSettings();
19
System.out.println(settings);
20
} catch (ApiException e) {
21
printError(e);
22
}
23
}
24
25
private static void printError(ApiException e) {
26
System.err.println("Exception when calling ProjectApi#getSettings");
27
System.err.println("Status code: " + e.getCode());
28
System.err.println("Reason: " + e.getResponseBody());
29
System.err.println("Response headers: " + e.getResponseHeaders());
30
e.printStackTrace();
31
}
32
}
Copied!
1
package main
2
3
import (
4
"context"
5
"fmt"
6
7
passbase "github.com/passbase/passbase-go"
8
)
9
10
func main() {
11
12
// Configure the SDK with your API Secret access key
13
client := passbase.NewAPIClient(passbase.NewConfiguration())
14
ctx := context.WithValue(context.Background(), passbase.ContextAPIKey, passbase.APIKey{
15
Key: "YOUR_SECRET_API_KEY",
16
})
17
18
// Get project settings
19
settings, _, err := client.ProjectApi.GetSettings(ctx)
20
if err != nil {
21
panic(err)
22
}
23
fmt.Println("Setting for ", settings.Slug, "->", settings)
24
}
Copied!
1
require 'passbase'
2
3
# Setup authorization
4
Passbase.configure do |config|
5
# Configure API key authorization: SecretApiKey
6
config.api_key['SecretApiKey'] = 'YOUR API KEY'
7
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
8
# config.api_key_prefix['SecretApiKey'] = 'Bearer'
9
end
10
11
api_instance = Passbase::ProjectApi.new
12
13
begin
14
# Get project settings
15
result = api_instance.get_settings
16
p result
17
rescue Passbase::ApiError => e
18
puts "Exception when calling ProjectApi->get_settings: #{e}"
19
end
Copied!
1
<?php
2
use App\Http\Controllers\Controller;
3
use Passbase\Configuration;
4
use Passbase\api\IdentityApi;
5
use GuzzleHttp\Client;
6
7
class APIController extends Controller
8
{
9
public function api_call()
10
{
11
// Configure the SDK with your API Secret access key
12
$config = Configuration::getDefaultConfiguration()->setApiKey('X-API-KEY', 'SECRET-KEY');
13
14
$apiInstance = new IdentityApi(
15
new Client(),
16
$config
17
);
18
19
// Unique identity access key received from webhooks
20
$id= "identityAccessKey";
21
22
try {
23
$result = $apiInstance->getIdentityById($id);
24
print_r($result);
25
} catch (Exception $e) {
26
echo 'Exception when calling IdentityApi->getIdentityById: ', $e->getMessage(), PHP_EOL;
27
}
28
}
29
}
30
?>
Copied!