Datasets

API change history

The dataset API gives access to all the data published by EFSA. The API returns the metadata in DCAT-AP standard format with the DOI link to download the dataset. A set of filters are available allowing to retrieve a list of the datasets of interests (for instance the newly published), or the full list could be retrieved in once.

search

This API allows to retrieve metadata of EFSA published Datasets. Metadata are expressed in DCAT_AP.

In order to retrieve metadata it is possible to execute a query on the main fields like title (dcterms:title), abstract (dcterms:description), digital object identifier (adms:Identifier), keywords (dcat:keyword), publication date (dcterms:issued).

Below you can find some example of query search. For a complete guide on query syntax refers to https://docs.microsoft.com/en-us/rest/api/searchservice/search-documents

Search all and retrieve first 10 datastes { "search":"*", "top": "10", "skip": "0", }

Search datasets by identifier { "search": "\"10.5281/zenodo.3060680\"", "searchFields":"adms:Identifier" }

Search datasets published after a specific date { "top": "35", "skip": "0", "filter" : "dcterms:issued gt 2019-04-30T00:00:00Z" }

To retrieve all versions of the same dataset, execute a query on the 'relation' metatdata, since it is common for all versions, for example

{ "search": "\"http://doi.org/10.5281/zenodo.1339343\"", "searchFields":"dcterms:relation", "count":"true" }

Please note: an empty request will not return any metadata. Insert at least a parameter for example "search":"*"

Try it

Request

Request URL

Request headers

  • (optional)
    string
    Media type of the body sent to the API.
  • string
    Subscription key which provides access to this API. Found in your Profile.

Request body

 { 
	"search": "*", 
	"top":"3",
	"skip":"0"
 }
{
  "example": " { \n\t\"search\": \"*\", \n\t\"top\":\"3\",\n\t\"skip\":\"0\"\n }"
}

Responses

200 OK

Representations

{
  "datasets": [
    {
      "@context": {
        "adms": "http://www.w3.org/ns/adms#",
        "dcat": "http://www.w3.org/ns/dcat#",
        "dcatapop": "http://data.europa.eu/88u/ontology/dcatapop#",
        "dcterms": "http://purl.org/dc/terms/",
        "foaf": "http://xmlns.com/foaf/0.1/",
        "owl": "http://www.w3.org/2002/07/owl#",
        "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
        "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
        "schema": "http://schema.org/",
        "skos": "http://www.w3.org/2004/02/skos/core#",
        "vcard": "http://www.w3.org/2006/vcard/ns#",
        "xsd": "http://www.w3.org/2001/XMLSchema#"
      },
      "@graph": [
        {
          "@id": "Kind-9c3db30fcf09ecb536467ad4524e9da0",
          "@type": "vcard:Kind",
          "vcard:hasEmail": "data.collection@efsa.europa.eu",
          "vcard_organization_name": [
            "European Food Safety Authority",
            "European Centre for Disease Prevention and Control"
          ]
        },
        {
          "@id": "10.5281/zenodo.2585938",
          "@type": "dcat:Dataset",
          "dcat:contactPoint": {
            "@id": "Kind-9c3db30fcf09ecb536467ad4524e9da0"
          },
          "dcat:distribution": {
            "@id": "Distribution-9c3db30fcf09ecb536467ad4524e9da0"
          },
          "dcat_keyword": [
            "antimicrobial resistance",
            "zoonotic bacteria",
            "indicator bacteria",
            "ESBL",
            "resistance to antibiotics",
            "indicator species",
            "extended spectrum beta-lactamases"
          ],
          "dcat:landingPage": "http://doi.org/10.5281/zenodo.2585938",
          "dcat:theme": {
            "@id": "http://publications.europa.eu/resource/authority/data-theme/AGRI"
          },
          "dcterms:description": "<p>All tables, figures and maps produced for the European Union Summary Report on Antimicrobial Resistance in Zoonotic and Indicator Bacteria from Humans, Animals and Food in 2017&nbsp;are provided.</p>",
          "dcterms:issued": {
            "@type": "xsd:dateTime",
            "@value": "2019-02-20 00:00:00"
          },
          "dcterms:language": {
            "@id": "http://publications.europa.eu/resource/authority/language/ENG"
          },
          "dcterms:publisher": {
            "@id": "http://publications.europa.eu/resource/authority/corporate-body/EFSA"
          },
          "dcterms:subject": {
            "@id": "http://eurovoc.europa.eu/6569"
          },
          "dcterms:title": "Tables and Figures complementing the European Union Summary Report on Antimicrobial Resistance in Zoonotic and Indicator Bacteria from Humans, Animals and Food in 2017",
          "owl:versionInfo": "1",
          "dcterms:relation": {
            "@id": "http://doi.org/10.5281/zenodo.2562858"
          }
        },
        {
          "@id": "10.5281/zenodo.2585938",
          "@type": "adms:Identifier",
          "adms:schemaAgency": "European Food Safety Agency",
          "dcterms:issued": {
            "@type": "xsd:dateTime",
            "@value": "2019-02-20 00:00:00"
          },
          "skos:notation": {
            "@type": "http://purl.org/spar/datacite/doi",
            "@value": "10.5281/zenodo.2585938"
          }
        },
        {
          "@id": "https://zenodo.org/communities/efsa-kj",
          "@type": "dcat:Catalog",
          "dcat:dataset": {
            "@id": "10.5281/zenodo.2585938"
          },
          "dcatapop:isPartOfCatalog": {
            "@id": "https://zenodo.org/communities/efsa-kj"
          },
          "dcterms:description": {
            "@language": "en",
            "@value": "The Knowledge Junction is a curated, open repository for the exchange of evidence and supporting materials used in food and feed safety risk assessments. Our aim is to improve transparency, reproducibility and evidence reuse."
          },
          "dcterms:publisher": {
            "@id": "http://publications.europa.eu/resource/authority/corporate-body/EFSA"
          },
          "dcterms:title": {
            "@language": "en",
            "@value": "Knowledge Junction"
          }
        },
        {
          "@id": "http://publications.europa.eu/resource/authority/corporate-body/EFSA",
          "@type": "foaf:Agent",
          "foaf:name": "EFSA"
        },
        {
          "@id": "Distribution-9c3db30fcf09ecb536467ad4524e9da0",
          "@type": "dcat:Distribution",
          "dcat:accessURL": {
            "@id": "http://doi.org/10.5281/zenodo.2585938"
          },
          "dcterms:format": {
            "@id": "http://publications.europa.eu/resource/authority/file-type/HTML"
          },
          "dcterms:license": {
            "@id": "http://publications.europa.eu/resource/authority/licence/CC_BY_4_0"
          },
          "dcterms:title": "Tables and Figures complementing the European Union Summary Report on Antimicrobial Resistance in Zoonotic and Indicator Bacteria from Humans, Animals and Food in 2017",
          "dcterms:type": {
            "@id": "http://publications.europa.eu/resource/authority/distribution-type/DOWNLOADABLE_FILE"
          }
        }
      ]
    }
  ]
}

400 Bad Request

"response": { "error": { "code": "", "message": "Invalid expression: Syntax error at position 38 in 'type eq 'Dataset' and dcterms_issued : 2018-01-19T00:00:00Z'.\r\nParameter name: $filter" } }

"response": { "error": { "code": "", "message": "Invalid expression: Could not find a property named 'dcterms_issueds' on type 'search.document'.\r\nParameter name: $filter" } }

"response": { "error": { "code": "", "message": "Illegal arguments in query request: dcterms_titles is not a searchable field." } }

"response":{ "error": { "code": "", "message": "The request is invalid. Invalid JSON." } }

Representations

401 Unauthorized

{ "statusCode": 401, "message": "Access denied due to missing subscription key. Make sure to include subscription key when making requests to an API." }

Representations

500 Internal Server Error

{ "statusCode": 500, "message": "Internal server error", "activityId": "742828c4-11c4-44fb-80aa-7415b4de3389" }

Representations

Code samples

@ECHO OFF

curl -v -X POST "https://openscaie-dev.azure-api.net/datasets/v1.0/"
-H "Content-Type: application/json"
-H "Ocp-Apim-Subscription-Key: {subscription key}"

--data-ascii "{body}" 
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;

namespace CSHttpClientSample
{
    static class Program
    {
        static void Main()
        {
            MakeRequest();
            Console.WriteLine("Hit ENTER to exit...");
            Console.ReadLine();
        }
        
        static async void MakeRequest()
        {
            var client = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            // Request headers
            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");

            var uri = "https://openscaie-dev.azure-api.net/datasets/v1.0/?" + queryString;

            HttpResponseMessage response;

            // Request body
            byte[] byteData = Encoding.UTF8.GetBytes("{body}");

            using (var content = new ByteArrayContent(byteData))
            {
               content.Headers.ContentType = new MediaTypeHeaderValue("< your content type, i.e. application/json >");
               response = await client.PostAsync(uri, content);
            }

        }
    }
}	
// // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class JavaSample 
{
    public static void main(String[] args) 
    {
        HttpClient httpclient = HttpClients.createDefault();

        try
        {
            URIBuilder builder = new URIBuilder("https://openscaie-dev.azure-api.net/datasets/v1.0/");


            URI uri = builder.build();
            HttpPost request = new HttpPost(uri);
            request.setHeader("Content-Type", "application/json");
            request.setHeader("Ocp-Apim-Subscription-Key", "{subscription key}");


            // Request body
            StringEntity reqEntity = new StringEntity("{body}");
            request.setEntity(reqEntity);

            HttpResponse response = httpclient.execute(request);
            HttpEntity entity = response.getEntity();

            if (entity != null) 
            {
                System.out.println(EntityUtils.toString(entity));
            }
        }
        catch (Exception e)
        {
            System.out.println(e.getMessage());
        }
    }
}

<!DOCTYPE html>
<html>
<head>
    <title>JSSample</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>

<script type="text/javascript">
    $(function() {
        var params = {
            // Request parameters
        };
      
        $.ajax({
            url: "https://openscaie-dev.azure-api.net/datasets/v1.0/?" + $.param(params),
            beforeSend: function(xhrObj){
                // Request headers
                xhrObj.setRequestHeader("Content-Type","application/json");
                xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
            },
            type: "POST",
            // Request body
            data: "{body}",
        })
        .done(function(data) {
            alert("success");
        })
        .fail(function() {
            alert("error");
        });
    });
</script>
</body>
</html>
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
    NSString* path = @"https://openscaie-dev.azure-api.net/datasets/v1.0/";
    NSArray* array = @[
                         // Request parameters
                         @"entities=true",
                      ];
    
    NSString* string = [array componentsJoinedByString:@"&"];
    path = [path stringByAppendingFormat:@"?%@", string];

    NSLog(@"%@", path);

    NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
    [_request setHTTPMethod:@"POST"];
    // Request headers
    [_request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [_request setValue:@"{subscription key}" forHTTPHeaderField:@"Ocp-Apim-Subscription-Key"];
    // Request body
    [_request setHTTPBody:[@"{body}" dataUsingEncoding:NSUTF8StringEncoding]];
    
    NSURLResponse *response = nil;
    NSError *error = nil;
    NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];

    if (nil != error)
    {
        NSLog(@"Error: %@", error);
    }
    else
    {
        NSError* error = nil;
        NSMutableDictionary* json = nil;
        NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
        NSLog(@"%@", dataString);
        
        if (nil != _connectionData)
        {
            json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
        }
        
        if (error || !json)
        {
            NSLog(@"Could not parse loaded json with error:%@", error);
        }
        
        NSLog(@"%@", json);
        _connectionData = nil;
    }
    
    [pool drain];

    return 0;
}
<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';

$request = new Http_Request2('https://openscaie-dev.azure-api.net/datasets/v1.0/');
$url = $request->getUrl();

$headers = array(
    // Request headers
    'Content-Type' => 'application/json',
    'Ocp-Apim-Subscription-Key' => '{subscription key}',
);

$request->setHeader($headers);

$parameters = array(
    // Request parameters
);

$url->setQueryVariables($parameters);

$request->setMethod(HTTP_Request2::METHOD_POST);

// Request body
$request->setBody("{body}");

try
{
    $response = $request->send();
    echo $response->getBody();
}
catch (HttpException $ex)
{
    echo $ex;
}

?>
########### Python 2.7 #############
import httplib, urllib, base64

headers = {
    # Request headers
    'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
}

params = urllib.urlencode({
})

try:
    conn = httplib.HTTPSConnection('openscaie-dev.azure-api.net')
    conn.request("POST", "/datasets/v1.0/?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################

########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64

headers = {
    # Request headers
    'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
}

params = urllib.parse.urlencode({
})

try:
    conn = http.client.HTTPSConnection('openscaie-dev.azure-api.net')
    conn.request("POST", "/datasets/v1.0/?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################
require 'net/http'

uri = URI('https://openscaie-dev.azure-api.net/datasets/v1.0/')


request = Net::HTTP::Post.new(uri.request_uri)
# Request headers
request['Content-Type'] = 'application/json'
# Request headers
request['Ocp-Apim-Subscription-Key'] = '{subscription key}'
# Request body
request.body = "{body}"

response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
    http.request(request)
end

puts response.body