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.
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: searchApi
url: ../openapi/apis-io-search-api-openapi.yml
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: search
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: search
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
Discovery needs no key. Ratings and market analysis are Pro.
Get an API key
Free tier, no form to fill in. Signing in shares your email address with us — we
store it to create your key and to recognise you if you sign in with another
provider. See our Privacy Policy and
Terms.