APIs.io · Arazzo Workflow

APIs.io Paginate Search Results

Version 1.0.0

Read the first page of a keyword search, learn the total page count, then fetch a following page of results.

1 workflow 1 source API 1 provider
View Spec View on GitHub API AggregationAPI DirectoryAPI DiscoveryAPI IndexingAPI RatingAPI SearchAPIs.jsonSearch EngineArazzoWorkflows

Provider

apis-io

Workflows

paginate-search-results
Page through APIs.io keyword search results using the response page metadata.
Fetches the first page of a keyword search to learn the total page count and the next-page link, then conditionally retrieves the next page of results when more than one page exists.
2 steps inputs: apiKey, limit, search outputs: firstPageResults, nextPageResults, totalPages
1
firstPage
searchAPIs
Fetch the first page of results for the keyword and read the total page count and the next-page link from the response metadata.
2
nextPage
searchAPIs
Fetch the second page of results for the same keyword so results can be accumulated beyond the first page.

Source API Descriptions

Arazzo Workflow Specification

apis-io-paginate-search-results-workflow.yml Raw ↑
arazzo: 1.0.1
info:
  title: APIs.io Paginate Search Results
  summary: Read the first page of a keyword search, learn the total page count, then fetch a following page of results.
  description: >-
    The APIs.io search response carries pagination metadata — the total number
    of pages plus self, next, and last links. This workflow walks that
    pagination: it reads the first page to discover how many pages of results
    exist for a keyword, branches on whether more than one page is available,
    and when it is, fetches the next page so a caller can accumulate results
    across pages. Each step inlines its request, including the required API key
    header, so the flow is self-describing.
  version: 1.0.0
sourceDescriptions:
- name: apisIoSearchApi
  url: ../openapi/apis-io-search-openapi.yaml
  type: openapi
workflows:
- workflowId: paginate-search-results
  summary: Page through APIs.io keyword search results using the response page metadata.
  description: >-
    Fetches the first page of a keyword search to learn the total page count and
    the next-page link, then conditionally retrieves the next page of results
    when more than one page exists.
  inputs:
    type: object
    required:
    - search
    - apiKey
    properties:
      search:
        type: string
        description: The keyword or phrase to search the APIs.io index by.
      limit:
        type: string
        description: The number of results to return per page.
        default: "50"
      apiKey:
        type: string
        description: The APIs.io API key sent in the x-api-key header.
  steps:
  - stepId: firstPage
    description: >-
      Fetch the first page of results for the keyword and read the total page
      count and the next-page link from the response metadata.
    operationId: searchAPIs
    parameters:
    - name: x-api-key
      in: header
      value: $inputs.apiKey
    - name: search
      in: query
      value: $inputs.search
    - name: limit
      in: query
      value: $inputs.limit
    - name: page
      in: query
      value: "0"
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      firstPageResults: $response.body#/data
      totalPages: $response.body#/meta/totalPages
      nextLink: $response.body#/links/next
    onSuccess:
    - name: morePages
      type: goto
      stepId: nextPage
      criteria:
      - context: $response.body
        condition: $.meta.totalPages > 1
        type: jsonpath
    - name: singlePage
      type: end
      criteria:
      - context: $response.body
        condition: $.meta.totalPages <= 1
        type: jsonpath
  - stepId: nextPage
    description: >-
      Fetch the second page of results for the same keyword so results can be
      accumulated beyond the first page.
    operationId: searchAPIs
    parameters:
    - name: x-api-key
      in: header
      value: $inputs.apiKey
    - name: search
      in: query
      value: $inputs.search
    - name: limit
      in: query
      value: $inputs.limit
    - name: page
      in: query
      value: "1"
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      nextPageResults: $response.body#/data
      currentPage: $response.body#/meta/page
  outputs:
    firstPageResults: $steps.firstPage.outputs.firstPageResults
    nextPageResults: $steps.nextPage.outputs.nextPageResults
    totalPages: $steps.firstPage.outputs.totalPages