> ## Documentation Index
> Fetch the complete documentation index at: https://docs.oloid-demo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Guide to Retrieving Events and Transactions - For Review

> This guide provides an overview of how to authenticate and retrieve events and transactions from our API. It covers the login process, fetching transactions...

This guide provides an overview of how to authenticate and retrieve events and transactions from our API. It covers the login process, fetching transactions, and retrieving activity events.

## Table of Contents

1. [Authentication](https://oloid.help/en/articles/9073240-login-api-documentation)
2. [Retrieving Transactions](https://oloid.help/en/articles/9827773-list-transactions-api)
3. [Retrieving Activity Events](https://oloid.help/en/articles/9827844-list-activity-logs-api)

## 1. Authentication

Before you can access any data, you need to authenticate with our API. We use a token-based authentication system.

## Login API

To obtain an access token, use the Login API

## Endpoint

`POST /login`

## Request Body

**Parameter**

**Data Type**

**Description**

UserName

*string*

The username of the credential

TenantName

*string*

The name of the tenant that the user belongs to.

Password

*string*

The password of the credential

## Request Body Sample

```
{
  "TenantName": <string>,
  "UserName": <string>,
  "Password": <string>
}
```

**Sample curl request**

```
curl --location 'https://api.oloidpreview.com/login' \
 --header 'Content-Type: application/json' \
 --data-raw '{
      "TenantName": "pepsi",
      "UserName": "pepsiadmin",
      "Password": "Password"
 }'
```

## Response Body

**Parameter**

**Data Type**

**Description**

cognitoToken.AuthenticationResult.IdToken

*string*

The JWT token that serves as the identity token

cognitoToken.AuthenticationResult.AccessToken

*string*

The token used to access API resources

cognitoToken.AuthenticationResult.RefreshToken

*string*

The token used to refresh the authentication when the current token expires

cognitoToken.AuthenticationResult.ExpiresIn

*integer*

The expiration time of the token in seconds

cognitoToken.AuthenticationResult.TokenType

*string*

The type of the token provided

user.OloID

*string*

OloID of the user

user.TenantID

*string*

The ID of the tenant

user.TenantName

*string*

The name of the tenant that the user belongs to.

## Sample Response

```
{
  "cognitoToken": {
    "ChallengeParameters": {},
    "AuthenticationResult": {
      "AccessToken": <string>,
      "ExpiresIn": <string>,
      "TokenType": <string>,
      "RefreshToken": <string>,
      "IdToken": <string>
    }
  },
  "user": {
    "OloID": <string>,
    "TenantID": <string>,
    "TenantName": <string>
  }
}
```

Store the `AccessToken` securely. You'll need to include it in the `Authorization` header for subsequent API calls. For more details on the Login API, see the [full Login API documentation](https://oloid.help/en/articles/9073240-login-api-documentation).

## 2. Retrieving Transactions

To fetch transactions, use the List Transactions API:

## Endpoint

`POST /transactions`

## Headers

* `Authorization: Bearer &lt;your_access_token>`
* `Content-Type: application/json`

## Request Body

**Parameter**

**Data Type**

**Description**

PageSize

*number*

Number of items in the result set

FromDate

*Epoch time*

The start timestamp for filtering results

ToDate

*Epoch time*

The end timestamp for filtering results

ApplicationID

*string*

The ID of the application

## Sample curl Request

```
curl --location 'https://api.oloidpreview.com/transactions' \
 --header 'Authorization: <Bearer Token> \
 --header 'Content-Type: application/json' \
 --data '{
     "FromDate": 1598863842240,
     "ToDate": 1605616031604,
     "NextPageToken": {
        "LastEvaluatedKey": {
             "MonthCreated": "Sep-2024",
             "EndpointID": "Tc3LPN",
             "CreatedOn": 1725450816290
      },
      "MonthKeys": [
           "Aug-2024",
           "Sep-2024"
      ]
   }
}'
```

## Response Body

**Parameter**

**Data Type**

**Description**

data.NextPageToken

*Json Object*

To paginate through the result

set

data.transactions

*Array*

A list of transactions

message

*string*

Additional information about the status of transactions

```
{
  "data": {
    "NextPageToken": "next_page_token_here",
    "transactions": [
      {
        "ApplicationName": "AccessControl",
        "EndpointName": "Main Entrance",
        "CreatedOn": 1662364800,
        "TransactionID": "trans-123",
        // ... other transaction fields ...
      }
      // ... more transactions ...
    ]
  },
  "message": "Transactions retrieved successfully"
}
```

## Sample Response

```
{
    "message": "Success",
    "data": {
        "transactions": [
           {
               "ApplicationName": "LxApplication",
               "CreatedOn": 1725450488111,
               "MonthCreated": "Sep-2024",
               "EndpointName": "KeepRooling",
               "Mode": "Online",
               "TransactionID": "0B88F29C-4D4D-4282-9F15-B21B36C570B2",
               "EndpointID": "Tc3LPN",
               "ApplicationID": "a17bb160935711eea978e5da75ed1ff2"
           },
           {
              "ApplicationName": "LxApplication",
              "CreatedOn": 1725447316337,
              "MonthCreated": "Sep-2024",
              "EndpointName": "KeepRooling",
              "Mode": "Online",
              "TransactionID": "F66F2D99-4D19-45DE-BAE5-65580DC524ED",
              "EndpointID": "Tc3LPN",
              "ApplicationID": "a17bb160935711eea978e5da75ed1ff2"
           }
        ],
        "NextPageToken": {
            "LastEvaluatedKey": {
                "MonthCreated": "Sep-2024",
                "EndpointID": "upRp54",
                "CreatedOn": 1725433260185
            },
            "MonthKeys": [
                "Aug-2024",
                "Sep-2024"
            ]
        }
    }
}
```

To fetch subsequent pages, include the `NextPageToken` in your next request. For more details on the List Transactions API, see the [full List Transactions API documentation](https://oloid.help/en/articles/9827773-list-transactions-api).

## 3. Retrieving Activity Events

To fetch activity events, use the Filter Activity API:

### Endpoint

`POST /filterActivity`

### Headers

* `Authorization: Bearer &lt;your_access_token>`
* `Content-Type: application/json`

### Request Body

**Parameter**

**Data Type**

**Description**

start

*Epoch time*

The start timestamp for filtering results

end

*Epoch time*

The end timestamp for filtering results

limit

*Number*

Number of items on

result set

**Sample curl Request**

```
curl --location 'https://api.oloidpreview.com/filterActivity' \
 --header 'Authorization: <Bearer Token>' \
--header 'Content-Type: application/json' \
 --data '{
      "start": 1725218978544,
      "end": 1725391778544,
      "nextToken": {
           "start": 10,
           "end": 20,
           "count": 20
 },
 "limit": 10
}'
```

**Response Body**

**Parameters**

**Data Type**

**Description**

data.activities

*array*

A list of activity objects

data.nextToken

*JSON Object*

Token for paginating

through result set

message

*string*

Additional information about the status of activities

```
{
  "data": {
     "activities": [
      {
        "id": "act-123",
        "timestamp": 1662388800000,
        "activityType": "LOGIN",
        "details": {
          "userId": "user-456",
          "userName": "John Doe"
        }
      }
      // ... more activities ...
    ],
    "nextToken": "next_token_here"
  },
  "message": "Activity logs retrieved successfully"
}
```

## Sample Response

```
{
     "message": "Success",
     "data": {
        "events": [
            {
                "logStreamName": "String",
                "timestamp": "Date String",
                "message": "JSON String",
                "eventId": "String"
            },
            ...more events..
        ],
        "nextToken": {
             "start": 20,
             "end": 30,
             "count": 30
       }
   }
}
```

To fetch subsequent pages, include the `nextToken` in your next request.

For more details on the Filter Activity API, see the [full Filter Activity API documentation](https://oloid.help/en/articles/9827844-list-activity-logs-api).

## Best Practices

1. Implement token refresh logic to maintain uninterrupted access.
2. When fetching large amounts of data, use pagination to improve performance.
3. Consider implementing rate limiting in your application to avoid hitting API limits.

## Error Handling

All APIs may return error responses. Always check the HTTP status code and error message in the response body. Common error codes include:

* 400: Bad Request
* 401: Unauthorized
* 403: Forbidden
* 404: Not Found
* 500: Internal Server Error
