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 (dcterms:identifier), keywords (dcat:keyword), publication date (dcterms:issued), contact email (vcard:hasEmail).

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 documents { "search":"*", "top": "10", "skip": "0", }

Search document by identifier { "search": "\"10.5281/zenodo.1212388\"", "searchFields":"dcterms:identifier" }

Search documents published after a specific date { "top": "35", "skip": "0", "filter" : "dcterms:issued gt 2018-01-19T00:00:00Z" }

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

HTTP/1.1 200 ok
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 5050
Content-Type: multipart/related; type="application/json"; boundary="uuid:9c04a5b3-7a39-42d1-924f-3804b7030afa"; start="<root.message@azure.api.com>"; start-info="application/json"
Expires: -1
request-id: 2622739d-1ce8-40de-b900-50e765a62636
elapsed-time: 86
OData-Version: 4.0
Preference-Applied: odata.include-annotations="*"
Strict-Transport-Security: max-age=15724800; includeSubDomains
Date: Wed, 25 Jul 2018 07:49:35 GMT

--uuid:9c04a5b3-7a39-42d1-924f-3804b7030afa
Content-Type: application/json; charset=UTF-8; type="application/json";
Content-Transfer-Encoding: binary
Content-ID: <root.message@azure.api.com>

--uuid:9c04a5b3-7a39-42d1-924f-3804b7030afa
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-Disposition: attachment;name="searchdataset.xml"

<rdf:dataset xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:adms="http://www.w3.org/ns/adms#" xmlns:dcat="http://www.w3.org/ns/dcat#" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:schema="http://schema.org/" xmlns:vcard="http://www.w3.org/2006/vcard/ns#">
  <rdf:RDF>
    <rdf:Description rdf:about="https://zenodo.org/record/571155">
      <dcterms:title>Occurrence Data On Alternaria Toxins In Food</dcterms:title>
      <dcterms:description>&lt;p&gt;Alternaria toxins are mycotoxins produced by Alternaria species that cause plant diseases on many crops. They are the principal contaminating fungi in wheat, sorghum and barley, and have also been reported to occur in oilseeds such as sunflower and rapeseed, tomato, apples, citrus fruits, olives and several other fruits and vegetables. In addition, some Alternaria toxins are genotoxic in vitro and/or fetotoxic in rats. This published dataset contains data related to years 1995, 2002, 2003, 2004, 2008 and 2009. Occurrence data were received from two Member States, which provided 11,730 occurrence results in food, and complemented with data published in the scientific literature. This data has been used for the preparation of the Scientific Opinion on the risks for animal and public health related to the presence of Alternaria toxins in feed and food adopted by EFSA in 2011.&lt;/p&gt;

&lt;p&gt;Several chromatography-based techniques are suitable for Alternaria toxin quantification in foods and feeds, and liquid chromatography coupled to (tandem) mass spectrometry, compliant with the requirements as described by the Commission regulation No. 401/2006, has become the method of choice. In the dataset published the following analytical methods have been used: HPLC-RI; Chromatographic tests (Not Specified); HPLC-UV; Standard Chromatographic tests (paper- thin layer- and column chromatography); LC-MS-MS (QqQ); HPLC-HG-AFS.&lt;/p&gt;</dcterms:description>
      <dcterms:identifier>10.5281/zenodo.571155</dcterms:identifier>
      <rdf:type rdf:resource="http://www.w3.org/ns/dcat#Dataset" />
      <dcterms:publisher rdf:resource="http://publications.europa.eu/resource/authority/corporate-body/EFSA" />
      <dcterms:issued>2017-05-11 00:00:00</dcterms:issued>
      <dcat:keyword>toxicity</dcat:keyword>
      <dcat:keyword>risk assessment</dcat:keyword>
      <dcat:keyword>dietary exposure</dcat:keyword>
      <dcat:keyword>mycotoxins</dcat:keyword>
      <dcat:keyword>Alternaria</dcat:keyword>
      <dcat:keyword>sampling</dcat:keyword>
      <dcat:keyword>occurrence</dcat:keyword>
      <dcat:keyword>analysis</dcat:keyword>
      <dcat:keyword>food</dcat:keyword>
      <dcterms:distribution rdf:resource="Distribution-03574896114426825e43a5c832806d9f" />
      <dcat:contactPoint rdf:resource="Kind-03574896114426825e43a5c832806d9f" />
    </rdf:Description>
    <rdf:Description rdf:about="Distribution-03574896114426825e43a5c832806d9f">
      <rdf:type rdf:resource="http://www.w3.org/ns/dcat#Distribution" />
      <dcterms:license rdf:resource="http://publications.europa.eu/resource/authority/licence/COM_REUSE" />
      <dcat:accessURL>http://doi.org/10.5281/zenodo.571155</dcat:accessURL>
    </rdf:Description>
    <rdf:Description rdf:about="Kind-03574896114426825e43a5c832806d9f">
      <rdf:type rdf:resource="http://www.w3.org/2006/vcard/ns#Kind" />
      <vcard:hasEmail>Format: Excel (XLSX); contact: data.collection@efsa.europa.eu</vcard:hasEmail>
      <vcard:organization-name>European Food Safety Authority (EFSA)</vcard:organization-name>
      <vcard:organization-name>EFSA</vcard:organization-name>
    </rdf:Description>
    <rdf:Description rdf:about="https://zenodo.org/communities/efsa-kj">
      <rdf:type rdf:resource="http://www.w3.org/ns/dcat#Catalog" />
      <dcterms:title xml:lang="en">Knowledge Junction</dcterms:title>
      <dcterms:description xml:lang="en">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:description>
      <dcterms:publisher rdf:resource="http://publications.europa.eu/resource/authority/corporate-body/EFSA" />
      <dcat:dataset rdf:resource="https://zenodo.org/record/571155" />
    </rdf:Description>
    <rdf:Description rdf:about="Agent-03574896114426825e43a5c832806d9f">
      <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Agent" />
      <foaf:name>EFSA</foaf:name>
    </rdf:Description>
  </rdf:RDF>
</rdf:dataset>

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://openapi.efsa.europa.eu/datasets/"
-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://openapi.efsa.europa.eu/datasets/?" + 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://openapi.efsa.europa.eu/datasets/");


            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://openapi.efsa.europa.eu/datasets/?" + $.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://openapi.efsa.europa.eu/datasets/";
    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://openapi.efsa.europa.eu/datasets/');
$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('openapi.efsa.europa.eu')
    conn.request("POST", "/datasets/?%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('openapi.efsa.europa.eu')
    conn.request("POST", "/datasets/?%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://openapi.efsa.europa.eu/datasets/')


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