• Rest API
    • Version 2.0
    • Version 1.3
      • Ping
      • Version
      • Request Quotas
      • Reports
        • Submit Report
        • Update Report
        • Upsert Report
        • Get Report Details
        • Delete Report
        • Copy Report
        • Move Report
        • Find Correlated Reports
        • Search Reports
        • Redact Report
        • Get Report Status
      • Indicators
        • Get Indicators for Report
        • Find Related Indicators
        • Search Indicators
        • Get Whitelist
        • Add to Whitelist
        • Delete from Whitelist
        • Get Indicator Metadata
        • Submit Indicators
        • Get Indicator Summaries
      • Tags
        • Get All Report Tags
        • Get Tags For Report
        • Alter Report Tags
        • Add Tag To Report (Deprecated)
        • Delete Tag From Report (Deprecated)
        • Get All Indicator Tags
        • Add Tag to Indicator
        • Delete Tag from Indicator
      • Enclaves
        • Get Enclaves
      • Phishing Triage
        • Get Phishing Submissions
        • Set Triage Status
        • Get Phishing Indicators
      • Errors
        • Invalid OAuth2 Token (400)
        • Expired OAuth2 Token (400)
        • Bad Request (400)
        • Unauthorized (401)
        • Forbidden (403)
        • Not Found (404)
        • Payload Too Large (413)
        • Query String Too Long (414)
        • Too Many Requests (429)
        • Internal Server Error (500)
      • Deprecated
        • Get Indicator List
        • Get Reports
  • Python SDK
    • Quick Start
    • TruStar (Main Class)
      • Reports
        • Get Report Details
        • Submit Report
        • Update Report
        • Delete Report
        • Copy Report
        • Move Report
        • Get Reports
        • Get Reports (Page)
        • Get Correlated Reports
        • Get Correlated Reports (Page)
        • Search Report
        • Search Report (Page)
      • Indicators
        • Get Indicators for Report
        • Get Indicators for Report (Page)
        • Get Related Indicators
        • Get Related Indicators (Page)
        • Search Indicators
        • Search Indicators (Page)
        • Get Whitelist
        • Get Whitelist (Page)
        • Get Indicators
        • Get Indicators (Page)
        • Get Indicator Summaries
        • Get Indicator Summaries (Page)
        • Add Terms to Whitelist
        • Delete Indicator from Whitelist
        • Get Community Trends
        • Submit Indicators
        • Get Indicators Metadata
        • Get Indicator Metadata (Deprecated)
      • Tags
        • Get Enclave Tags for Report
        • Alter Report Tags
        • Add Enclave Tag to Report (Deprecated)
        • Delete Enclave Tag from Report (Deprecated)
        • Get All Enclave Tags
        • Add Indicator Tag
        • Delete Indicator Tag
        • Get All Indicator Tags
      • Enclaves
        • Get Enclaves
      • Phishing Triage
        • Get Phishing Submissions
        • Get Phishing Submissions (Page)
        • Set Triage Status
        • Get Phishing Indicators
        • Get Phishing Indicators (Page)
      • Utility
        • Log
        • Ping
        • Version
        • Get Request Quotas
    • Models
      • Report
      • Indicator
      • Indicator Summary
      • Intelligence Source
      • Tag
      • Enclave
      • Enclave Permissions
      • Page
      • NumberedPage
      • CursorPage
      • Request Quota
      • PhishingSubmission
      • PhishingIndicator
    • Examples
      • Ingest Report CSV
      • Create Indicators CSV
      • Delete Reports
      • Pagination
TruSTAR Documentation
  • Docs »
  • TruSTAR Python SDK »
  • Examples »
  • Pagination

PaginationΒΆ

The SDK offers two different ways of using API endpoints that support pagination. The first is to manually get each successive page. For example, the following will print each indicator for a given report:

page = None

# get each successive page of indicators
while page is None or page.has_more_pages():

    # get next page of indicators
    page = ts.get_indicators_for_report_page(report_id="4d1fcaee-5009-4620-b239-2b22c3992b80",
                                             page_number=page_number)

    # print each indicator in the page
    for indicator in page.items:
        print(indicator)

    page_number += 1

Because this pattern is so common for paginated endpoints, there is a shorthand available:

indicators = ts.get_indicators_for_report(report_id="4d1fcaee-5009-4620-b239-2b22c3992b80")

for indicator in indicators:
    print(indicator)

The two examples are completely equivalent. In the first example, page is an instance of the Page class. It contains a field called items, which is a list of Indicator objects. In the second example, indicators is a generator, which is a Python object that can be iterated over using a for loop.

For every method that makes a request to a paginated endpoint and returns a Page object (get_reports_page, get_indicators_for_report_page, etc.), there is a corresponding method that returns a generator (get_reports, get_indicators_for_report, etc.).

Previous

© Copyright 2021, Splunk Inc..

Built with Sphinx using a theme provided by Read the Docs.