Adding a IIIF presentation through API

I am creating a lot of items in Omeka using a Python script with the help of the omeka_s_tools Python module. It is all going pretty well, but I have got stuck trying to create a IIIF presentation media attachment to an item. I can do this manually in Omeka. All I need is the manifest URL (for example https://n2t.durham.ac.uk/ark:/32150/t2mm326m2021).

But how am I supposed to create the media attachment using the API? The examples in the omeka_s_tools documentation such as add_media_to_item seem to assume that you are uploading a file. Should I just give it a suitable JSON payload for the media metadata and omit the file?

I’ve tried looking at the REST API documentation on the developer site. It has a very short section for Create but it’s pretty sparse even about how to create a media item.

If I view the media item for a IIIF presentation through the API, it is very long, and I think it contains the whole of the manifest. I hope I do not have to do that manually. What is the least I can get away with submitting which will trigger Omeka to go and fetch the manifest, set up thumbnails, and so on?

Perhaps it’s just a matter of POST /api/media with something like

{
  "@context": "https://caxton-test.durham.ac.uk/omeka-s/api-context",
  "@type": "o:Media",
  "o:is_public": true,
  "o:ingester": "iiif_presentation",
  "o:renderer": "iiif_presentation",
  "o:item": {
    "@id": "https://host.name.here/omeka-s/api/items/1234",
    "o:id": 1234
  },
  "o:source": "https://n2t.durham.ac.uk/ark:/32150/t2mm326m2021",
}

Can anyone recommend any fuller documentation of code I could plagiarise?

Actually, that seems to be exactly the right thing to do! Not sure whether it will generate any thumbnails though.

Sorry - posted this in completely the wrong forum!

I moved the post.

To answer your question, you’re right on about what you’re supposed to do to create a iiif_presentation media: just specify the source as the URL to the manifest. This is exactly what the user interface does; there’s no additional magic or anything happening.

This will also generate a thumbnail in Omeka S if the manifest specifies a thumbnail property.