A REST client for Omeka, using the API introduced in Omeka 2.1.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself:
gem install omeka_client
See the Omeka API documentation for information about what is possible with the Omeka's API.
First, load the gem in your script:
Next, create a client to interact with your Omeka site. You'll need your endpoint and, optionally, an API key.
client = OmekaClient::Client.new("http://localhost/omeka/api", "api_key") # => #<OmekaClient::Client:0x007f4307937aa0>
You can use the convenience methods for easy access to data.
site_info = client.site puts site_info['title'] # => Omeka RC Dev items = client.items puts items['id'] # => 1 puts items['url'] # => http://localhost/omeka/api/items/1
If you want more flexibility, you can use the higher level methods.
client.get('collections', 1) client.get_hash('collections', 1)
If you just want a raw REST connection to Omeka, then you can access the underlying instance from the Rest gem.
Testing and documentation
You can run the tests by running
rake test. You'll need to have an Omeka site running at least 2.1-RC1 to use the tests.
You can generate the documentation by running
For now the gem only handles GET requests. I'm going to work on making methods that pull information out of Omeka as robust as possible before I deal with POST, PUT, and DELETE. Contributions are more than welcome.
This gem is licensed under the GPLv3, the same as Omeka.