Omeka REST API Experiment

In the Domain of One’s Own workshop yesterday, Ed Beck‘s work around integrating Omeka and WordPress came up. It led me to check out the Omeka S API. I made a functional example in CodePen and a couple of things came up that might be of interest.

First, why do something like this? You have some options here. You could use FeedWordPress and syndicate the content over but I’m less and less of a fan of having copies of data everywhere. It gets messy. You could probably iframe some chunk of the Omeka piece into WordPress but that’s messy in other ways. You have to theme two different systems, removing chunks of a site (like the header) in iframes is a hassle.

The API route can solve those problems. The data is clean. You can structure it how you’d like and add classes or whatever you need to it merges seamlessly with the existing WP theme CSS or you can tweak it to do what you need but there’s no battling with Omeka structure or CSS. It’s a clean way to include the data of your choosing within the visual frame of WordPress.


One problem with a lot of REST APIs these days is CORS issues. I used a PHP proxy to get around that but I need to spend some more time seeing how to make this work better.

There was something else weird going on with the Omeka response so I ended up just grabbing the JSON and sticking it in a folder. If it had been my Omeka install or if I was really going to do this, I’d spend some time figuring this out.

Omeka has opted to include colons in the JSON keys (essentially, the labels). That’s annoying because normally you can just do something like thing.labelname.value but now you have to do item[“dcterms:title”][0][“@value”] to navigate the structure. Not terrible but annoying.

Anyway, the example is below and it works. Styling would be nice and easy. You could work in a Gutenberg block or shortcode to allow arguments to be passed. If you have enough structures in the the theme organization, it could happen automatically by page category or title. Lots of options to make the interface between the two systems nice and smooth.

See the Pen
Omeka API Example
by Tom (@twwoodward)
on CodePen.