API Response Format for List Endpoints

Introduction

The Ordermentum API provides structured JSON responses for list endpoints, divided into three main sections: data, meta, and links. Each section plays a specific role in facilitating efficient data retrieval:

  1. Data Section: This contains an array of objects representing resources (e.g., orders or products). Each object includes relevant details like ID, creation date, status, etc. For example, retrieving orders would return an array of order objects.

  2. Meta Section: Offers pagination information such as total results, current page number, pages per size, and total pages. This helps in managing large datasets by indicating how many items are available and how they're divided into pages.

  3. Links Section: Provides navigation URLs for paginated results:

    • self: Current page URL.
    • first: First page URL.
    • prev: Previous page URL (if applicable).
    • next: Next page URL (if applicable).
    • last: Last page URL.

Pagination Handling:

  • Use the links to navigate through pages, especially with the next link for subsequent requests.
  • Stop fetching when the next link is null or not provided.
  • Adjust pageSize based on processing capacity and rely on meta.totalPages to plan API calls efficiently.

Implementation Considerations:

  • Extract data from JSON using appropriate programming methods (e.g., Python dictionaries).
  • Handle pagination by iterating through pages until all results are retrieved.
  • Be cautious of cases where next links may not be present, indicating no more data.

By understanding and utilizing these sections effectively, you can manage large datasets efficiently and automate pagination processes.