How do I retrieve contextual metadata programmatically?

SMW
SMW Member Posts: 4
edited September 2022 in Developer APIs

I'm using cloudinary: ^1.32.0

Tagged:

Answers

  • rlux
    rlux Administrator, Cloudinary Staff Posts: 68
    edited September 2022

    Hi @SMW, do you have an example of where you're having the problem?

  • SMW
    SMW Member Posts: 4

    Hi rlux, I managed to solve the problem myself.

    The call I was looking for was

    const alt_text = await   cloudinary.api.resources_by_ids( imageId, {context:true} )

    .then(metadata=> metadata.resources[0].context.custom.image_alt_text)

     .catch(err=>{console.log({err}); )


    Is there a complete list of options and what values they accept anywhere?

  • rlux
    rlux Administrator, Cloudinary Staff Posts: 68

    Looping in @JackieDoc for some input on this.

  • JackieDoc
    JackieDoc Member, Cloudinary Staff Posts: 2

    @SMW - Hi. Just noticed I was tagged here, so delayed response, but maybe still helpful? 🙏

    You can find all the details of our Admin API, including syntax, descriptions of all available params, and code examples for all SDKs, here: https://cloudinary.com/documentation/admin_api

    FYI - In addition to the totally valid solution you came up with for your requirement, there's also this helper method in SDKs that might be more convenient:

    https://cloudinary.com/documentation/admin_api#get_resources_by_context

    Hope this will be helpful going forward!