大量のデータをスクロール毎に取得するページネーションAPI設計を検討
ページネーションの検討
openapi: 3.0.0
info:
title: Credit Card Transaction API
version: 1.0.0
paths:
/transactions:
get:
summary: Retrieve credit card transactions
description: |
Retrieves credit card transactions. The initial request returns 50 transactions, and subsequent requests return 30 transactions each.
parameters:
- name: userId
in: query
required: true
description: The ID of the user
schema:
type: string
example: 'user123'
- name: offset
in: query
required: false
description: The offset for pagination
schema:
type: integer
example: 0
responses:
'200':
description: Successfully retrieved transactions
content:
application/json:
schema:
type: object
properties:
transactions:
type: array
items:
type: object
properties:
transactionId:
type: string
description: The ID of the transaction
example: 'txn12345'
date:
type: string
format: date-time
description: The date of the transaction
example: '2023-10-01T12:34:56Z'
amount:
type: number
format: float
description: The amount of the transaction
example: 123.45
description:
type: string
description: The description of the transaction
example: 'Grocery Store'
nextOffset:
type: integer
description: The offset for the next set of transactions
example: 50
'400':
description: Bad Request - Invalid input data
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: 'Invalid input data'
'500':
description: Internal Server Error
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: 'Internal Server Error'