> For the complete documentation index, see [llms.txt](https://portal-integracao.intelbras.com.br/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://portal-integracao.intelbras.com.br/linha-de-faciais/obtendo-eventos-em-tempo-real/snapmanager.md).

# SnapManager

O SnapManager assim como o eventManager, requer que o servidor solicite aos dispositivos o envio dos eventos em um formato de "pooling". Este end-point é responsável por encaminhar eventos relacionados aos acessos e à imagem obtida no momento em que o evento foi realizado.

{% hint style="warning" %}
Para o funcionamento correto é necessário que a requisição seja feita em polling e modo Stream, caso contrário o dispositivo não irá retornar os eventos.

Por este motivo esta chamada não irá funcionar no Postman.&#x20;

Vale ressaltar que dispositivos sem câmeras não suportam as chamadas do snapManager e portanto os eventos de acesso serão encaminhados pelo eventManager.
{% endhint %}

### Obtendo eventos via snapManager

#### Requisição - GET

<mark style="color:green;">`GET`</mark>`http://192.168.1.201/cgi-bin/snapManager.cgi?action=attachFileProc&Flags[0]=Event&Events=[All]&heartbeat=5`

| param       | type   | description                                                                                           |
| ----------- | ------ | ----------------------------------------------------------------------------------------------------- |
| `Events` \* | String | Código de evento a ser filtrado, , pode ser utilizado: "All", "CitizenPictureCompare"                 |
| `heartbeat` | String | Valor pode ser de 1 a 5. Define o intervalo de envio da mensagem ao cliente com a informação hearbeat |

#### Retorno - *multipart-mixed*

```sh
--myboundary
Content-Type: text/plain
Content-Length: 836

Events[0].Alive=100
Events[0].CardName=John
Events[0].CardNo=
Events[0].CardType=0
Events[0].CreateTime=1629814150
Events[0].Door=0
Events[0].ErrorCode=16
Events[0].EventBaseInfo.Action=Pulse
Events[0].EventBaseInfo.Code=AccessControl
Events[0].EventBaseInfo.Index=0
Events[0].ImageInfo[0].Height=360
Events[0].ImageInfo[0].Length=14655
Events[0].ImageInfo[0].Offset=0
Events[0].ImageInfo[0].Type=1
Events[0].ImageInfo[0].Width=640
Events[0].ImageInfo[1].Height=600
Events[0].ImageInfo[1].Length=18102
Events[0].ImageInfo[1].Offset=14655
Events[0].ImageInfo[1].Type=2
Events[0].ImageInfo[1].Width=480
Events[0].Method=15
Events[0].ReaderID=1
Events[0].Similarity=0
Events[0].SnapPath=/var/tmp/partsnap3.jpg
Events[0].Status=0
Events[0].Type=Entry
Events[0].UTC=1629814150
Events[0].UserID=
Events[0].UserType=0

--myboundary
Content-Type: image/jpeg
Content-Length: 32757

[BYTES DA IMAGEM DO MOMENTO DE ACESSO]
```

#### Exemplos

{% tabs %}
{% tab title="Python" %}

```python
import requests

url = "http://192.168.3.87/cgi-bin/snapManager.cgi?action=attachFileProc&Flags[0]=Event&Events=[All]&heartbeat=5"
digest_auth = requests.auth.HTTPDigestAuth('admin', 'acesso1234')

response = requests.get(url, auth=digest_auth, stream=True, timeout=60, verify=False)

empty_lines = 0
event = {}

for chunk in response.iter_lines():
        print(chunk)

        if chunk == ''.encode():
            empty_lines += 1
            if empty_lines == 2:
                empty_lines = 0
                print(event)
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
const request = require('request');
 
const url = "http://192.168.3.87/cgi-bin/snapManager.cgi?action=attachFileProc&Flags[0]=Event&Events=[All]&heartbeat=5"
const auth = {
    user: 'admin',
    pass: 'acesso1234',
    sendImmediately: false
}
 
request.get(url, {
    auth: auth,
    timeout: 60 * 1000,
    strictSSL: false,
})
.on('data', function(chunk) {
    console.log(chunk.toString());
 
    if (chunk.toString() === '') {
        empty_lines++;
        if (empty_lines === 2) {
            empty_lines = 0;
            console.log(event);
        }
    }
})
.on('error', function(err) {
    console.error(err);
});
```

{% endtab %}

{% tab title="Curl" %}

```shellscript
curl --digest -u "admin:admin12345" -g "http://192.168.1.201/cgi-bin/snapManager.cgi?action=attachFileProc&Flags[0]=Event&Events=[All]" > test_snapManager.txt
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://portal-integracao.intelbras.com.br/linha-de-faciais/obtendo-eventos-em-tempo-real/snapmanager.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
