Pagination

The Mediacloud API returns responses in a paginated format, automatically providing 10 items per page. This guide will help you understand how to navigate and utilize these paginated results.

Example using cursors

In this example, we start by requesting the first page of media items. If there's a next page, we proceed to fetch and print the media URLs from that page as well.

  • Name
    current_page
    Type
    integer
    Description

    Indicates the current page number.

  • Name
    data
    Type
    array
    Description

    An array containing the URLs of the media items on the current page.

  • Name
    first_page_url
    Type
    integer
    Description

    The URL to access the first page of results.

  • Name
    from
    Type
    integer
    Description

    The index of the first item on the current page.

  • Name
    last_page
    Type
    integer
    Description

    The total number of pages available for the current query.

  • Name
    last_page_url
    Type
    integer
    Description

    The URL to access the last page of results.

  • Name
    links
    Type
    object
    Description

    Navigation links for the paginated results, including: Previous page: null if there is no previous page. Current page: URL for the current page. Next page: null if there is no next page.

  • Name
    next_page_url
    Type
    integer
    Description

    The URL for the next page of results. null if this is the last page.

  • Name
    path
    Type
    integer
    Description

    The base URL for the media items endpoint.

  • Name
    per_page
    Type
    integer
    Description

    The number of items per page, which is always 10.

  • Name
    prev_page_url
    Type
    integer
    Description

    The URL for the previous page of results. null if this is the first page.

  • Name
    to
    Type
    integer
    Description

    The index of the last item on the current page.

  • Name
    total
    Type
    integer
    Description

    The total number of items available across all pages.

cURL Fetch all Uploaded Media

curl -G https://mediacloud.ng/api/media/ \
  -H "Authorization: Bearer {token}"

Paginated response

{
    "current_page": 1,
    "data": [
        "https://mediacloud.ng/media/bWVkaWEvaW1hZ2VzL29yaWdpbmFsLzdUU3BsWFo3U2hTQkNWVDVMWjFlb3IxS2JhaXlJRFM5dGhEU2x1SXkucG5n.png",
        "https://mediacloud.ng/media/bWVkaWEvaW1hZ2VzL29yaWdpbmFsL0dLOVd0and4WWF5azkwMjlEbUpDMVpxSzBVemp3VmJMdThOUUlrMU8ucG5n.png"
    ],
    "first_page_url": "https://mediacloud.ng/api/media?page=1",
    "from": 1,
    "last_page": 1,
    "last_page_url": "https://mediacloud.ng/api/media?page=1",
    "links": [
        {
            "url": null,
            "label": "« Previous",
            "active": false
        },
        {
            "url": "https://mediacloud.ng/api/media?page=1",
            "label": "1",
            "active": true
        },
        {
            "url": null,
            "label": "Next »",
            "active": false
        }
    ],
    "next_page_url": null,
    "path": "https://mediacloud.ng/api/media",
    "per_page": 10,
    "prev_page_url": null,
    "to": 2,
    "total": 2
}

Was this page helpful?