# Intelligence Integration Guide

## Introduction

This manual describes the standard integration workflow of GBS Intelligence, which enables biographic search in the database. Any API call mentioned in this manual must be made in accordance with the [GBS Intelligence API Specification](https://gitbook.griaule.com/apis/intelligence) .

{% hint style="info" %}
All calls to GBS Intelligence must be made to the ETR server, as mentioned in the API specification.
{% endhint %}

## Login

Any request to GBS Intelligence requires an authenticated login `session-guid`. To obtain it, it is necessary to send `session-guid`a request [for login, providing a valid username/password combination.](https://gitbook.griaule.com/apis/intelligence/endpoints#post-session)

{% hint style="info" %}
The username and password must be the same used to log in to GBDS and other Griaule applications.
{% endhint %}

The login operation will return a session-guid that must be provided in all requests to GBS Intelligence.

## List of Search Fields by Request

Any search request submitted to GBS Intelligence must specify the biographic field to be used. To check the available biographic fields, one can use [listSearchFields](https://gitbook.griaule.com/apis/intelligence/fields)

{% hint style="info" %}
If the biographic field name specified in the search request does not match a field that exists within the database, an error will be returned.
{% endhint %}

## Searching by Value

When making a search request, it is recommended to split the workflow into two steps: count and list.

By counting the results available for the provided search criteria in advance, it is possible to paginate the results, avoiding any overhead in retrieving and viewing the results.

After counting the results, it is possible to request and paginate the search results through the request query parameters.

### Count

The request [for count search results](https://gitbook.griaule.com/dev/api/intelligence/profiles#post-profile-list-count) must contain the fields `name`and `value`to be searched.

{% hint style="info" %}
Any profile that contains the value to be searched within the provided biographic field will be returned as a search result, regardless of position.

for example, a regular expression that describes the search criteria would be `*value*`, with `*`a wildcard that covers any character in any quantity.
{% endhint %}

### To perform video searches, BEST will extract the best face images of each person and consolidate them into a single identity. To see each image individually, you can turn off the Only Consolidated option in the top bar. You can also filter the list by date, case creator, case codes, trace or fragment, and status.

The request [List Search Results](https://gitbook.griaule.com/dev/api/intelligence/profiles#post-profile-list) must also contain the fields `name`and `value`to be searched, and the search criteria will be the same used to count the results.

This request accepts query parameters that can be used to filter the returned list, such as `first`, which determines the position of the first result returned in the list, and `size`, which sets the number of results to be returned, starting from the `first`.

## Accessing profile details

After performing the search and retrieving the results, it is possible to use the returned PGUIDs to access profile details via the call [Request Profile](https://gitbook.griaule.com/apis/intelligence/profiles#get-profile-person-pguid).

This method will return all profile data for the provided PGUID, including biographic data and images encoded in base64.

## Image conversion tool

GBS Intelligence also provides a method to [convert images](https://gitbook.griaule.com/apis/intelligence/image-conversion#post-image-convert) into different formats, providing the original image encoded in base64, its format and the desired format for conversion.
