-
Notifications
You must be signed in to change notification settings - Fork 197
API
This documentation is a work in progress and subject to change.
Super users may configure the API using the Settings > API form.
- Enable/disable the API (default: enabled)
- Adjust the amount of results per page (default: 50)
You can extend the API to include custom resources. In your plugin, register your resource using the api_resources filter, following this format:
<?php
public function filterApiResources($apiResources)
{
// For the path: /api/your_resources/:id
$apiResources['your_resources'] = array(
// Controller associated with your resource.
'controller' => 'your-resource-controller',
// Type of record associated with your resource.
'record_type' => 'YourResourceRecord',
// List of actions available for your resource.
'actions' => array(
'index', // GET request without ID
'get', // GET request with ID
'post', // POST request
'put', // PUT request (ID is required)
'delete', // DELETE request (ID is required)
),
// List of GET parameters available for your index action.
'index_params' => array('foo', 'bar'),
);
return $apiResources;
}
If not given, controller falls back to the default controller (api). Resources using the default controller MUST include a record_type. Records must extend Omeka_Record_AbstractRecord
and implement the Omeka_Api_RecordInterface
interface. Remove actions that are not wanted or not implemented. For index actions, all GET parameters must be registered with the index_params whitelist.
yourdomain.com/api[/:version]
Resources must be accessible to the consumer, public or via API key authentication.
Return data about resources (most often records):
GET /:resources
- page: integer
Return data about the specified resource (most often a specific record):
GET /:resources/:id
Return available API resources (must be registered) and information about them:
GET /resources
{
"resources": {
"controller": "resources",
"record": null,
"actions": ["index", "get"]
},
"collections": {
"controller": "api",
"record": "Collection",
"actions": ["index", "get", "post", "put", "delete"]
},
"items": {
"controller": "api",
"record": "Item",
"actions": ["index", "get", "post", "put", "delete"]
}
}
Return data about collections:
GET /collections
- public: boolean
- featured: boolean
- added_since: string (ISO 8601)
- modified_since: string (ISO 8601)
- owner (user): integer
Return data about the specified collection:
GET /collections/:id
[
{
"id": 1,
"url": "/collections/1",
"owner": {"id": 1, "url": "/users/1"},
"public": true,
"featured": false,
"added": "2013-03-27T08:17:37+00:00",
"modified": "2013-04-21T15:05:07+00:00",
"items": {"count": 100, "url": "/items?collection=1"},
"element_texts": {"count": 100, "url": "/element_texts?record_type=collection&record_id=1"}
}
]
Return data about items:
GET /items
- collection: integer
- item_type: integer
- featured: boolean
- public: boolean
- added_since: string (ISO 8601)
- modified_since: string (ISO 8601)
- owner (user): integer
Return data about the specified item:
GET /items/:id
[
{
"id": 1,
"url": "/items/1",
"item_type": {"id": 1, "url": "/item_types/1", "name": "Text"},
"collection": {"id": 1, "url": "/collections/1"},
"owner": {"id": 1, "url": "/users/1"},
"public": true,
"featured": false,
"added": "2013-03-27T08:17:37+00:00",
"modified": "2013-04-21T15:05:07+00:00",
"files": {"count": 100, "url": "/files?item=1"},
"element_texts": {"count": 100, "url": "/element_texts?record_type=item&record_id=1"}
}
]
Return data about files:
GET /files
- item: integer
- order: integer
- size_greater_than: integer
- has_derivative_image: boolean
- mime_type: string
- added_since: string (ISO 8601)
- modified_since: string (ISO 8601)
Return data about the specified item:
GET /files/:id
[
{
"id": 1,
"url": "/files/1",
"item": {"id": 1, "url": "/items/1"},
"order": null,
"size": 1953540,
"has_derivative_images": true,
"authentication": "f6089bca39470e8c19410242061b1f78",
"mime_type": "audio/mpeg",
"type_os": "MPEG ADTS, v1, 128 kbps, 44.1 kHz, JntStereo",
"filename": "54a21c1552feef92069d504fbaf145a8.mp3",
"original_filename": "1ATwUDzA3SCU.128.mp3",
"added": "2013-03-27T08:17:37+00:00",
"modified": "2013-04-21T15:05:07+00:00",
"stored": true,
"metadata": {},
"element_texts": {"count": 100, "url": "/element_texts?record_type=file&record_id=1"}
}
]
Return data about item types:
GET /item_types
- name: string
Return data about the specified item type:
GET /item_types/:id
[
{
"id": 1,
"url": "/item_types/1",
"name": "Text",
"description": "A resource consisting primarily of words for reading.",
"elements": {"count": 10, "url": "/elements?item_type=1"},
"items": {"count": 100, "url": "/items?item_type=1"}
}
]
Return data about element sets:
GET /element_sets
- name: string
- record_type: string
Return data about the specified element set:
GET /element_sets/:id
[
{
"id": 1,
"url": "/element_sets/1",
"record_type": null,
"name": "Dublin Core",
"description": "The Dublin Core metadata element set is common to all Omeka records.",
"elements": {"count": 100, "url": "/elements?element_set=1"}
}
]
Return data about elements:
GET /elements
- element_set: integer
- order: integer
- name: string
Return data about the specified element:
GET /elements/:id
[
{
"id": 1,
"url": "/elements/1",
"element_set": {"id": 1, "url": "/element_sets/1"},
"order": 1,
"name": "Text",
"description": "Any textual data included in the document",
"comment": null,
"element_texts": {"count": 100, "url": "/element_texts?element=1"}
}
]
Return data about element texts:
GET /element_texts
- record_type: string
- record_id: integer
- element: integer
[
{
"record": {"id": 1, "type": "item", "url": "/items/1"},
"element_set": {"id": 1, "name": "Dublin Core", "url": "/element_sets/1"},
"element": {"id": 1, "name": "Title", "url": "/elements/1"},
"html": false,
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
},
{
"record": {"id": 2, "type": "item", "url": "/items/2"},
"element_set": {"id": 1, "name": "Dublin Core", "url": "/element_sets/1"},
"element": {"id": 2, "name": "Description", "url": "/elements/2"},
"html": false,
"text": "Nunc ante ante, mollis at euismod nec, hendrerit vitae turpis."
}
]
GET /users
GET /users/:id
GET /tags
GET /plugins
GET /plugins/:name