Artificial Intelligence Corporate Risk
  • Welcome
  • Getting Started
    • Inviting Users
    • Adding New Large Language Models
      • Azure OpenAI Service
      • OpenAI
      • Mistral
      • Google AI
      • LLaMA AI
      • AWS Bedrock
  • Chat
    • Initiating a Chat
    • Viewing Chat History
  • Dashboards
    • Creating Dashboards
    • Dashboard Elements
      • Top N
      • Charts and Graphs
      • Totals
      • Maps
  • Monitoring
    • Adding a User to the Monitor Role
    • Setting up alerts and issues
    • Editing Issues
  • Compliance
    • Adding a User to the Compliance Role
    • Creating a Search
    • Consuming the Results
  • Admin
    • AI Agents
      • Adding a New Agent
        • General Settings
        • Agent Engine Properties
          • Azure OpenAI
          • OpenAI
          • Mistral
          • Google AI
          • LLaMA AI
          • AWS Bedrock
        • Advanced Settings
          • Usage
            • Max Messages
            • LLM Temperature
          • Scanners
            • AI Scanners
            • General Scanners
          • API Keys
          • Files
      • Editing an Agent
      • Deleting an Agent
      • Adding from a Template
    • Company
      • General Information
      • External Agent Provider Settings
    • Custom APIs
      • OAuth2 API
      • Adding a New API
        • API Information
        • API Headers
        • API Endpoint Parameters
        • API Query Parameters
        • Body Parameters
      • Editing a Custom API
      • Deleting a Custom API
    • Custom Database
    • Users
      • Inviting a New User
      • Deleting a User
      • Roles
        • Accessing User Roles
      • Assigning an Agent
      • Setting a Default Agent
    • Groups
      • Adding a New Group
      • Deleting a Group
      • Assigning a User
      • Removing a User
      • Adding an Agent
      • Removing an Agent
    • Agent Scanner Defaults
      • Toxicity
      • Personal Information
      • Topic Scanner
      • Prompt Injection Detection
      • Regex Scanner
      • Geographic Gating
      • Language Detection
      • Allowed File Types
    • Logs
      • Interpreting Logs
  • Server Admin
    • Upgrade
    • Default Agents
      • Adding a New Agent
    • Data Archive
    • API Access
      • Chat
        • List Agents
        • Create Conversation
        • List of Conversations
        • Get Conversations
        • Ask Agent
        • Chat with Agent
        • Add File to Conversation
        • Add Files to Agent
        • Deleting a File
      • OAuth2
        • OAuth2
        • OAuth2 Token
      • Users
        • List Users
        • Create User
        • Add User to Group
        • Set User Token
        • Delete User
      • How to Launch Our API Example
        • How the Code Works
    • Configure OAuth2
    • Custom Secrets
  • API Overview
    • Authentication
    • Calling the Scanner
    • Consuming the Results
    • 📃Pagination
      • Understanding API Parameters
      • Pagination Helper
      • Example Page
      • Recap
    • AIRisk API OAuth2 Authentication
      • Authorization
      • Authorization Endpoint
        • Example Authorization URL
        • Error Responses
      • Tokens
        • Error Handling
        • Generic vs. User-Specific Tokens
          • Example Usage Flow / Reasons
        • Usage of the Access Token
      • Token Endpoint
        • Example Token Request
        • Error Responses
      • Summary of OAuth2 Authorization Flow
  • Managing Your Account
    • Personal Data
  • Support
    • Onboarding Check List
  • Internal Deployment
    • Outlook Plugin
    • Firewall Rules
    • Infrastructure
    • Graph Connection Requirements
    • Zoom Transcripts
  • Example Python Application
  • Release Notes
    • V4.28
    • V4.12
    • V4.0
    • V3.71
    • V3.0 Beta
    • V2.23
    • V2.22
    • V2.120 HotFix
    • V2.103 June 1
Powered by GitBook
On this page
  • 🔢 How to Fetch a Specific Page of Data
  • 🧭 Understanding API Parameters (with Purpose)
  • 🛠 Pagination Helper (Agent Handling)
  • 🧑‍💼 Example: Fetching Page 4 with Filter
  • 🔁 Recap: Building a UI with Pagination
  1. API Overview

Pagination

Pagination is exclusive to the GetConversation endpoints

  • /api/Chat/GetConversations/{agentid}/{results}/{skip}/{metadatasearch}

  • /api/Chat/GetConversations/{agentid}

  • /api/Chat/GetConversations

The Semantic Meaning of the pagination-related parameters are:

  1. results : Page Length

  2. skip : Starting Index

    1. Corresponds with (page_num * page_size)

🔢 How to Fetch a Specific Page of Data

Fetching page-based data is simple when you understand how to calculate what to fetch and from where to start.

📘 What You Need to Know

To request Page N from our API, you’ll need to provide two key numbers:

Parameter
Meaning
Example (for Page 3, 20 items/page)

results

How many items you want (page size)

20

skip

Where to start from in the total list

(3 - 1) * 20 = 40

🔍 Formula: skip = (pageNumber - 1) * results

This formula tells the API where in your data to begin. The results value tells it how many items to return from that point.

🧭 Understanding API Parameters (with Purpose)

Parameter
Type
Required?
Description

agentid

string

No*

The ID of the agent you want data for. Omit if you want system-wide data.

results

integer

Yes

Number of records per page. Defaults to 20 if not specified.

skip

integer

Yes

Offset in the dataset (calculated based on current page).

metadatasearch

string

No

Optional keyword filter. Use "" (empty string) if not filtering.


Below are plug-and-play functions that dynamically support both API routes:

  • /api/Chat/GetConversations/ (when agent ID is not known)

  • /api/Chat/GetConversations/{agentid} (when it is)

These helpers calculate the correct skip, and let your app specify the page without worrying about the URL details.

✅ If agentid is omitted, just use /api/Chat/GetConversations — the API will still respond with paginated data.

Note: For your own app integrating with our API, it is typical in pagination to first get the total number of query-able items in the not-paginated data source so that you know for instance what the max.

🛠 Pagination Helper (Agent Handling)


🐍 Python Helper

import requests

def fetch_conversations(agentid=None, page=1, results=20, metadatasearch=""):
    skip = (page - 1) * results
    base = "https://yourdomain.com/api/Chat/GetConversations"
    
    if agentid:
        url = f"{base}/{agentid}"
    else:
        url = base

    params = {
        "results": results,
        "skip": skip,
        "metadatasearch": metadatasearch,
    }

    response = requests.get(url, params=params)
    return response.json()
    
def alt_fetch_conversations(agentid=None, page=1, results=20, metadatasearch=""):
    # Demonstrates the alternative way of calling GetConversations using only path parameters
    # E.g. `/api/Chat/GetConversations/{agentid}/{results}/{skip}/{metadatasearch}`
    skip = (page - 1) * results
    base = "https://yourdomain.com/api/Chat/GetConversations"
    
    if agentid is not None and \
        page is not None and \
        results is not None and \
        metadatasearch:
        
        url = f"{base}/{agentid}/{results}/{skip}/{metadatsearch}"
        response = requests.get(url)
        return response.json()
   else:  # If not all params have valid value, use GET params instead of path ones
       return fetch_conversations(agentid, page, results, metadatasearch)
async function fetchConversations({ agentId = null, page = 1, results = 20, metadatasearch = "" }) {
  const skip = (page - 1) * results;
  const baseUrl = "https://yourdomain.com/api/Chat/GetConversations";
  const url = new URL(agentId ? `${baseUrl}/${agentId}` : baseUrl);

  url.searchParams.set("results", results);
  url.searchParams.set("skip", skip);
  url.searchParams.set("metadatasearch", metadatasearch);

  const res = await fetch(url);
  return await res.json();
}


🧑‍💼 Example: Fetching Page 4 with Filter

Scenario: You want to load Page 4 of a conversation list filtered by the keyword “sales”, with 25 results per page.

Using the API directly:

GET /api/Chat/GetConversations/abc123?results=25&skip=75&metadatasearch=sales
  • page = 4

  • results = 25

  • skip = (4 - 1) * 25 = 75

With the helper:

fetch_conversations(agentid="abc123", page=4, results=25, metadatasearch="sales")

🔁 Recap: Building a UI with Pagination

To integrate pagination smoothly into your UI:

  1. Set a default results value (e.g., 20 or 50)

  2. Track currentPage in your frontend or backend state

  3. When the user clicks “Next” or “Previous”:

    • Update page

    • Recalculate skip

    • Re-fetch data using the helpers above

  4. Render the results into your UI

💡 Pro tip: You can pre-fetch the next page in the background to create an “instant” pagination experience.

PreviousConsuming the ResultsNextUnderstanding API Parameters

Last updated 1 month ago

📃
Page cover image