Outdated version

You are browsing the docs for Nexus v1.9.x, the latest release is available here

Multi fetch

The multi-fetch operation allows to get in a given format multiple resources that can live in multiple projects.

The response includes a resources array that contains the resources in the order specified in the request. The structure of the returned resources is similar to that returned by the fetch API. If there is a failure getting a particular resource, the error is included in place of the resource.

This operation can be used to return every type of resource.

Authorization notes

When performing a request, the caller must have resources/read permission on the project each resource belongs to.

Please visit Authentication & authorization section to learn more about it.

Payload

GET|POST /v1/multi-fetch/resources

{
  "format": {format}
  "resources": [
    {
      "id": "{id}",
      "project": "{project}"
    },
    ...
  ]
}

where…

  • {format}: String - the format we expect for the resources in the response. Accepts the following values: source (to get the original payload), annotated-source (to get the original payload with metadata), compacted, expanded, n-triples, dot
  • {project}: String - the project (in the format ‘myorg/myproject’) where the specified resource belongs. This field is optional. It defaults to the current project.
  • {id}: Iri - the @id value of the resource to be returned. Can contain a tag or a revision.

Example

The following example shows how to perform a multi-fetch and an example of response containing errors (missing permissions and resource not found). As a response, a regular json is returned containing the different resources in the requested format.

Request
sourcecurl -L \
     -X GET \
     -d '
     {
       "format": "source",
        "resources" : [
          {
            "id": "https://bbp.epfl.ch/person/alex",
            "project": "public/person"
          },
          {
            "id": "https://bbp.epfl.ch/person/john-doe",
            "project": "public/person"
          },
          {
             "id": "https://bbp.epfl.ch/secret/xxx",
             "project": "restricted/xxx"
          }
      ]
     }
'
Payload
source{
  "format": "source",
  "resources" : [
    {
      "id": "https://bbp.epfl.ch/person/alex",
      "project": "public/person"
    },
    {
      "id": "https://bbp.epfl.ch/person/john-doe",
      "project": "public/person"
    },
    {
      "id": "https://bbp.epfl.ch/secret/xxx",
      "project": "restricted/xxx"
    }
  ]
}
Response
source{
  "format": "source",
  "resources": [
    {
      "@id": "https://bbp.epfl.ch/person/alex",
      "project": "public/person",
      "value": {
        "@context": {
          "@vocab": "https://bluebrain.github.io/nexus/vocabulary/"
        },
        "@id": "https://bluebrain.github.io/nexus/vocabulary/success",
        "@type": "Person",
        "bool": false,
        "name": "Alex",
        "number": 24
      }
    },
    {
      "@id": "https://bbp.epfl.ch/person/john-doe",
      "project": "public/person",
      "error": {
        "@type": "NotFound",
        "reason": "The resource 'https://bbp.epfl.ch/person/john-doe' was not found in project 'public/person'."
      }
    },
    {
      "@id": "https://bbp.epfl.ch/secret/xxx",
      "project": "restricted/xxx",
      "error": {
        "@type": "AuthorizationFailed",
        "reason": "The supplied authentication is not authorized to access this resource."
      }
    }
  ]
}