REST API Image Issue

I'm using the REST API to integrate Collective Access into a WordPress site. I'm having trouble getting a high-resolution image from the meta data type "media" via the REST API (ie using this: http://localhost/service.php/browse/ca_objects?pretty=1). I checked the Collective Access documentation here, but don't see anything regarding high-res images. Can anyone shed some light on how I can accomplish this, please?


  • edited February 14


    I have not played a lot with API, but what I understand is that you must get informations with several steps:

    • Authentication.
    • Get informations for the object you want.
    • Get linked ca_object_representations (media) for that object. (You can have several linked media.)
    • For the ca_object_representations you want, get the URL of the original file (which have the highest resolution) by getting the media.original.url. Width and height of this file should be in media.original.width and media.original.height.

    Maybe this will help you...

  • What do you expect when you say "high resolution"? Are you expecting the originally uploaded file? Or a derived file with a set format and resolution? Also, just to make sure I understand, this is a file uploaded to a metadata element of type "media"? No an attached object representation?

  • Hi again!

    I give you an example with my collection. Suppose you want to get an original image from an object. Lets choose this object:

    Step 1: Authentification

    This returns you a token, lets say TheToken.

    Step 2: Get informations for an object.

    This returns you plenty of metadata and related ressources.

    Under representations, you find 2 representation numbers: 1543 and 1544.

    For representation 1543, you have can see the URLs, and in these URLs, there are one for a preview170, and one for the original file. For the original file:

    You also directly have the HTML tag <img src=......>.

    Step 3 (optional): Get informations about a specific representation, lets say the number 1543.

    You can call the API for the table ca_object_representations and id 1543:

    This returns about the same informations, and related ressources.

  • Hi Darrigan and Seth,

    Sorry for my delay in reply, I was out of the office.

    When I say "high resolution", I am hoping I can get the original path/url to the uploaded image file.

    For example, I want to grab the image from the "media" upload metadata elements but it's showing the preview image for some reason and not returning the original image path.

    Here's the url I've used:*&pretty=1

    Thanks so much for your help.

  • Hi,

    OK, so suppose you are interested by object number object_id=47, you can call:

    And you get informations about the 3 representations (id=7 ; 10 ; 11) with their path to original. For representation_id=7:

    original: ""

  • Hi Darrigan,

    Thanks for the reply. I'm hoping to get the path from the metadata elements so I can pull in this image for example:

  • Hi Darrigan and Seth,

    I wanted to follow up to see if you had a chance to review my last reply?

  • I searched but I don't find... this is touching my limits.

  • Okay, thanks for the reply Darrigan.

    Seth, any idea where I can get that info?

  • edited March 7

    Your screen shot shows a "main image" container field with subfields for a media upload and various text fields. What are the element codes for these subfields. It should be in the form ca_objects.<container code>.<sub field code>. You'll need them to get the data you need. Once you've got the code for the media upload field, you can include it in your item call. By default it'll return an HTML tag for embedding. Append ".url" to the element code to get a URL returned.

    On the demo site at (with user name demo and password demo). The url with this in the body:

    {"bundles":{"ca_objects.preferred_labels": {}, "ca_objects.notes": {}, "ca_objects.copyright_document.url": {}}}

    (where copyright_document is a media upload) will return this:

        "ok": true,
        "ca_objects.preferred_labels": [
                "label_id": "28",
                "object_id": "27",
                "locale_id": "1",
                "type_id": null,
                "name": "Touch Sanitation",
                "name_sort": "",
                "source_info": "Tjs=",
                "is_preferred": "1",
                "sdatetime": null,
                "edatetime": null,
                "access": "1",
                "item_type_id": "21"
        "ca_objects.notes": [
                "notes": "Photograph from citywide performance with 8,500 Sanitation workers across all 59 New York City Sanitation districts."
                "notes": "Photo by Robin Holland"
        "ca_objects.copyright_document.url": [
                "copyright_document": ""

    Now if you look at the URL you'll see that it references the tiny "icon" version, which may not be what you want. If you append .<version>.url to the element code you can control which media version is returned. For instance, to get a URL to the originally uploaded file use ca_objects.copyright_document.original.url in the API call.

  • That worked! THANK YOU Seth!

Sign In or Register to comment.