CSS Stylesheet |
---|
h3 { background-color: #eee; padding: 0.6em; } #content .code { margin-left: 2.5em!important; background-color: #fafafa!important; } .pdl .syntaxhighlighter table td.code .container, .syntaxhighlighter .line.alt2, .syntaxhighlighter .line.alt1 { background-color: #fafafa!important; } |
Table of Contents |
---|
Overview
...
Introduction
Excerpt |
---|
The Fedora 4 HTTP API is generally a RESTful API. HTTP methods like GET, PUT, POST and DELETE are implemented on most resource paths. The API also relies heavily on content negotiation to deliver context-appropriate responses, and a HATEOAS-driven text/html response (providing a decent GUI experience on top of the repository). |
...
- application/n3 (or text/rdf+n3 or text/n3)text
- application/turtlen-quads
- application/n-triples
- textapplication/trigrdf+json
- application/rdf+xmlapplication
- text/rdf+jsontrig
- applicationtext/n-quadsturtle
The text/html response also includes embedded RDFa markup.
The API is based loosely around the Linked Data Platform 1.0 Architecture, which:
[...] describes the use of HTTP for accessing, updating, creating and deleting resources from servers that expose their resources as Linked Data. It provides clarifications and extensions of the rules of Linked Data [LINKED-DATA]:
- Use URIs as names for things
- Use HTTP URIs so that people can look up those names
- When someone looks up a URI, provide useful information, using the standards (RDF*, SPARQL)
- Include links to other URIs, so that they can discover more things
...
Changes planned
- Asynchronous API support
...
Versioning
CND node types
Changelog
...
Endpoints
...
Resources
Repository objects can be loosely divided into two classes of resources:
- Object and containers ("fedora:object"), containing RDF properties and 0 or more child nodes
- Binaries, containing any binary payload (roughly corresponding to Fedora 3 datastreams)
Objects
Request URI: /path/to/some/resource
...
Status | ||||||
---|---|---|---|---|---|---|
|
...
Anchor | ||||
---|---|---|---|---|
|
Create a new node at the given path Status colour Blue title POST
...
Status | ||||
---|---|---|---|---|
|
Note |
---|
The slug you provide does not guarantee the location of the created node. Clients must check the Location header for the path to the created resource. For full control over the generated path, see POST Create a new node at the given path (link me!) |
Query Parameters:
...
Status | ||||||||
---|---|---|---|---|---|---|---|---|
|
...
Bulk creation, modification and deletion of resources with a single multipart request Status colour Blue title POST
...
For clients unable to produce multipart/mixed requests, a multipart/form-data endpoint is also provided. It uses heuristics to determine which action to apply: - if
- if the entity has a supplied filename, it will create a new datastream at the part's name
...
- if the content is RDF or SPARQL-Update (and doesn't have a filename set), add or update triples
...
- if the entity's name is "delete[]", the content of the body is a relative path to a resource to delete
- otherwise, it will create a new datastream at the part's name using the part's content.
Example:
Code Block |
---|
# creates the ds1 resource curl -X POST -F "ds1=@image.png" "http://localhost:8080/rest/path/to/some/resource/fcr:batch" # execute the supplied SPARQL-Update query against the resource curl -X POST -F ".=@sparql_update_query;type=application/sparql-update" "http://localhost:8080/rest/path/to/some/resource/fcr:batch" # delete the ds1 resource curl -X POST -F "delete[]=ds1" "http://localhost:8080/rest/path/to/some/resource/fcr:batch" # or any combination of the above. |
...
Note | ||
---|---|---|
Objects are exported and imported relative to the request URI path given. E.g., if you run:
The resource will be imported to http://localhost:8080/rest/somewhere/else/resource. |
...
fcr:export Retrieve serialized form of a resource and its subtree. Status title GET
...
Response:
Code Block |
---|
Status: 200 OK
Body:
/tmp/fcrepo4-data/path/to/backup/directory |
...
Code Block |
---|
Status: 200 OK Headers: Content-Type: text/turtle Body: <http://localhost:8080/rest/fcr:identifier> <http://fedora.info/definitions/v4/repository#hasMember> <http://localhost:8080/rest/newly-minted-identifier><http://localhost:8080/rest/fcr:identifier> <http://fedora.info/definitions/v4/repository#hasMember>identifier> , <http://localhost:8080/rest/another-newly-minted-identifier><httpidentifier> , <http://localhost:8080/rest/fcr:identifier> <http://fedora.info/definitions/v4/repository#hasMember> <http://localhost:8080/rest/yet-another-minted-identifier> |
...
Warning |
---|
The request body format for updating nodetypes is in flux. For now, and in the immediate future, it uses JCRJCR's CND syntax , but we'd prefer a provider-independent format.. |
Example:
Code Block |
---|
curl -X POST -H "Content-Type: text/cnd" -d "@cnd.txt" "http://localhost:8080/rest/fcr:nodetypes" Body: [fedora:custom_node_type] > fedora:resource mixin - fedora:thumbnail (string) |
...
Status | ||||||
---|---|---|---|---|---|---|
|
Search
Properties text
Request URI: /fcr:search
Methods: GET
...
Status | ||||||
---|---|---|---|---|---|---|
|
SPARQL
Request URI: /fcr:sparql
Methods: GET
...
Status | ||||||
---|---|---|---|---|---|---|
|
transform
Example 1 LD PATH (GET):
Transform
Request URI: /fcr:transform/{program}program default is default
Methods: GET, POST
Status | ||
---|---|---|
|
Request Headers:
Example:
Code Block | ||
---|---|---|
| ||
@prefix fcrepo : <http://fedora.info/definitions/v4/repository#> id id = . :: xsd:string ; title = dc:title :: xsd:string; uuid = fcrepo:uuid :: xsd:string ; |
Status title GET
|
Code Block |
---|
curl http://localhost:8080/rest/49/3d/24/41/493d2441-0541-41c7-a23b-09d1f17d4a0f/fcr:transform/default
|
Response:
Code Block |
---|
HTTP/1.1Status: 200 OK Headers: Content-Type: application/json Transfer-Encoding: chunked Server: Jetty(8.1.11.v20130520) Body: [{"id":["http://localhost:8080/rest/49/3d/24/41/493d2441-0541-41c7-a23b-09d1f17d4a0f"],"title":[],"uuid":["07630a24-5a0b-4ba7-80ab-0691f68667ce"]}] |
Status:
Status | ||||||
---|---|---|---|---|---|---|
|
Status | ||||||
---|---|---|---|---|---|---|
|
Example 2 LD PATH (POST):
...
Request URI: /fcr:transform/{program}
application/rdf+ldpath,application/sparql-queryget a resource transformed with the supplied transform Status colour Blue title POST
Output formats: application/json,text/tab-separated-values,text/csv,text/sse,text/plain,application/sparql-results+json,application/sparql-results+xml,application/sparql-results+bio,text/turtle,text/rdf+n3,application/N-triples,application/rdf_xml
Example:
Code Block |
---|
curl -X POST -H "Content-Type: application/rdf+ldpath" -d "@post.txt" "http://localhost:8080/rest/49/3d/24/41/493d2441-0541-41c7-a23b-09d1f17d4a0f/fcr:transform" post.txtBody: @prefix fcrepo : <http://fedora.info/definitions/v4/repository#> id = . :: xsd:string ; title = dc:title :: xsd:string; uuid = fcrepo:uuid :: xsd:string ; |
Response:
Code Block |
---|
HTTP/1.1Status: 200 OK Headers: Content-Type: application/json Transfer-Encoding: chunked Server: Jetty(8.1.11.v20130520) Body: [{"id":["http://localhost:8080/rest/49/3d/24/41/493d2441-0541-41c7-a23b-09d1f17d4a0f"],"title":[],"uuid":["07630a24-5a0b-4ba7-80ab-0691f68667ce"]}] |
Status:
Status | ||||||
---|---|---|---|---|---|---|
|
Status | ||||||
---|---|---|---|---|---|---|
|