Galleries

Galleries are a way to collect videos, images and audio files in a single bucket. Media is attached to galleries in the same way they are attached to articles.

This collection of endpoints deals with Galleries. We provide a JSON Schema for the gallery object, which you can find hereopen in new window

    {
      "id": "3211e44d...",
      "organisation_id": "1c862f0a...",
      "title": "Gallery title",
      "slug": "gallery-slug",
      "links": {
        "view": "https://api.motorpress.co.za/galleries/sint-saepe-veritatis-voluptatum-aspernatur-blanditiis-rerum-sit-nobis",
        "thumbnail": "https://api.motorpress.co.za/storage/defaults/thumbnail.jpg"
      },
      "attachments": {
        "images": 4,
        "videos": 1,
        "audio": 0
      },
      "published_at": "2024-02-13T14:32:55+00:00",
      "created_at": "2024-02-13T14:32:55+00:00"
    },

Fetching Galleries

OrganisationMedia

You can retrieve a paginated list of recently published galleries. Note that non-published galleries are not included in this list. The returned list can be filtered using the URL parameters provided.

Endpoint

get
/galleries

URL Parameters

A number of URL parameters are accepted which can be used to filter the returned galleries. Note that month cannot be used if a year is not also specified.

ParameterDescription
yearOnly include articles published in the specified year.
monthOnly include articles published in the specified month. Requires that a year is specified.

Example

curl "https://api.motorpress.co.za/galleries" \
     -H 'Accept: application/json' \
     -H 'Content-Type: application/json' \
     -H 'Authorization: Bearer TEST_TOKEN'
<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.motorpress.co.za/galleries');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
  'Accept: application/json',
  'Content-Type: application/json',
  'Authorization: Bearer TEST_TOKEN',
]);

$response = curl_exec($ch);

if (!$response) {
  die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
}

echo 'HTTP Status Code: ' . curl_getinfo($ch, CURLINFO_HTTP_CODE) . PHP_EOL;
echo 'Response Body: ' . $response . PHP_EOL;

curl_close($ch);
{
  "data": [
    {
      "id": "c224bfbd-dd6b-423e-83aa-dba525f81600",
      "organisation_id": "1c862f0a-6a3d-446d-bfdc-fe76870dc1ca",
      "title": "Provident Dolorum",
      "slug": "provident-dolorum",
      "links": {
        "view": "https://motorpress.co.za/galleries/provident-dolorum",
        "thumbnail": "https://motorpress.co.za/storage/defaults/thumbnail.jpg"
      },
      "attachments": {
        "images": 15,
        "videos": 1,
        "documents": 2,
        "audio": 0
      },
      "published_at": "2024-02-13T14:19:43.000000Z",
      "created_at": "2024-02-13T14:19:43.000000Z"
    },

    // ...
  ],
  "links": {
    "first": "https://api.motorpress.co.za/galleries?page=1",
    "last": "https://api.motorpress.co.za/galleries?page=2",
    "prev": null,
    "next": "https://api.motorpress.co.za/galleries?page=2"
  },
  "meta": {
    "current_page": 1,
    "from": 1,
    "last_page": 2,
    "links": [
      {
        "url": null,
        "label": "&laquo; Previous",
        "active": false
      },
      {
        "url": "https://api.motorpress.co.za/galleries?page=1",
        "label": "1",
        "active": true
      },

      // ...
    ],
    "path": "https://api.motorpress.co.za/galleries",
    "per_page": 20,
    "to": 20,
    "total": 36
  }
}
OrganisationMedia

You can use this endpoint to fetch a single gallery object. Note that there is no additional data included in the gallery object but it can be useful if you already know the ID of the gallery you need.

Endpoint

get
/galleries/[GALLERY_ID]

Example

curl "https://api.motorpress.co.za/galleries/7eefb9ce-8633-4aaf-a24a-7a9f4e7c6c41" \
     -H 'Accept: application/json' \
     -H 'Content-Type: application/json' \
     -H 'Authorization: Bearer TEST_TOKEN'
<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.motorpress.co.za/galleries/7eefb9ce-8633-4aaf-a24a-7a9f4e7c6c41');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
  'Accept: application/json',
  'Content-Type: application/json',
  'Authorization: Bearer TEST_TOKEN',
]);

$response = curl_exec($ch);

if (!$response) {
  die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
}

echo 'HTTP Status Code: ' . curl_getinfo($ch, CURLINFO_HTTP_CODE) . PHP_EOL;
echo 'Response Body: ' . $response . PHP_EOL;

curl_close($ch);
{
  "data": {
    "id": "7eefb9ce-8633-4aaf-a24a-7a9f4e7c6c41",
    "organisation_id": "1c862f0a-6a3d-446d-bfdc-fe76870dc1ca",
    "title": "Aut Tenetur Voluptas",
    "slug": "aut-tenetur-voluptas",
    "links": {
      "view": "https://motorpress.co.za/articles/aut-tenetur-voluptas",
      "thumbnail": {
        "square": "https://motorpress.co.za/storage/defaults/thumbnail.jpg"
      }
    },
    "attachments": {
      "images": 16,
      "videos": 0,
      "documents": 3,
      "audio": 0
    },
    "published_at": "2024-01-20T18:19:43+00:00",
    "created_at": "2024-01-20T18:19:43+00:00"
  }

Much like articles, galleries can carry a number of attachments. Unlike articles, document attachments are not included with galleries. Images, Videos and Audio attachments are all possible, though. When fetching a paginated list of galleries or a single gallery only the number of each type of attachment is included in the returned gallery object. To fetch the actual atteachments, you'll need to make a request to each of the attachment endpoints.

Images

OrganisationMedia

You can use this endponit to fetch a paginated list of images attached to the gallery. The response from this endpoint is the same as fetching an index of images.

Endpoint

get
/galleries/{gallery_uuid}/images

See Also

Videos

OrganisationMedia

You can use this endponit to fetch a paginated list of videos attached to the gallery. The response from this endpoint is the same as fetching an index of videos.

Endpoint

get
/gallery/{gallery_uuid}/videos

See Also

Audio

OrganisationMedia

You can use this endponit to fetch a paginated list of audio files attached to the gallery. The response from this endpoint is the same as fetching an index of audio files.

Endpoint

get
/galleries/{gallery_uuid}/audio

See Also

Last Updated:
Contributors: Warrick Bayman, warrick