I want to be able to automate or batch download Sentinel data (in particular S2).
I am trying to use the OData protocol as described in the Sentinels Scientific Data Hub user-guide on APIs and batch scripting. As an example I try to download a complete product using wget:
wget --no-check-certificate --user=username --password=usrpass "https://scihub.copernicus.eu/apihub/odata/v1/Products('18f7993d-eae1-4f7f-9d81-d7cf19c18378')/$value"
(With a registered username and password) but I just receive the index.html:
<?xml version='1.0' encoding='utf-8'?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xml:base="https://scihub.copernicus.eu/dhus/odata/v1/"><id>https://scihub.copernicus.eu/dhus/odata/v1/Products('18f7993d-eae1-4f7f-9d81-d7cf19c18378')</id><title type="text">S1A_IW_SLC__1SDV_20141023T172123_20141023T172150_002960_0035D1_9743</title><updated>2014-12-07T17:06:00.324Z</updated><category term="DHuS.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/><link href="Products('18f7993d-eae1-4f7f-9d81-d7cf19c18378')" rel="edit" title="Product"/><link href="Products('18f7993d-eae1-4f7f-9d81-d7cf19c18378')/$value" rel="edit-media" type="application/octet-stream"/><link href="Products('18f7993d-eae1-4f7f-9d81-d7cf19c18378')/Products" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Products" title="Products" type="application/atom+xml;type=feed"/><link href="Products('18f7993d-eae1-4f7f-9d81-d7cf19c18378')/Nodes" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Nodes" title="Nodes" type="application/atom+xml;type=feed"/><link href="Products('18f7993d-eae1-4f7f-9d81-d7cf19c18378')/Attributes" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Attributes" title="Attributes" type="application/atom+xml;type=feed"/><link href="Products('18f7993d-eae1-4f7f-9d81-d7cf19c18378')/Class" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Class" title="Class" type="application/atom+xml;type=entry"/><content type="application/octet-stream" src="Products('18f7993d-eae1-4f7f-9d81-d7cf19c18378')/$value"/><m:properties><d:Id>18f7993d-eae1-4f7f-9d81-d7cf19c18378</d:Id><d:Name>S1A_IW_SLC__1SDV_20141023T172123_20141023T172150_002960_0035D1_9743</d:Name><d:ContentType>application/octet-stream</d:ContentType><d:ContentLength>8544532822</d:ContentLength><d:ChildrenNumber>2</d:ChildrenNumber><d:Value m:null="true"/><d:CreationDate>2014-12-07T17:06:00.324</d:CreationDate><d:IngestionDate>2014-12-07T17:06:00.324</d:IngestionDate><d:EvictionDate m:null="true"/><d:ContentDate m:type="DHuS.TimeRange"><d:Start>2014-10-23T17:21:23.23</d:Start><d:End>2014-10-23T17:21:50.495</d:End></d:ContentDate><d:Checksum m:type="DHuS.Checksum"><d:Algorithm>MD5</d:Algorithm><d:Value>C4415763B3198B7A2874C2A60B2CDCDC</d:Value></d:Checksum><d:ContentGeometry><gml:Polygon srsName="http://www.opengis.net/gml/srs/epsg.xml#4326" xmlns:gml="http://www.opengis.net/gml">
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates>41.289764,6.891860 41.685265,9.900283 40.048470,10.244140 39.652199,7.311233 41.289764,6.891860</gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon></d:ContentGeometry><d:Metalink><metalink xmlns="urn:ietf:params:xml:ns:metalink"><file name ="S1A_IW_SLC__1SDV_20141023T172123_20141023T172150_002960_0035D1_9743.zip"><url>https://scihub.copernicus.eu/dhus/odata/v1/Products('18f7993d-eae1-4f7f-9d81-d7cf19c18378')/$value</url></file></metalink></d:Metalink></m:properties></entry>
However, if I put the URI query https://scihub.copernicus.eu/dhus/odata/v1/Products%28'18f7993d-eae1-4f7f-9d81-d7cf19c18378'%29/$value
directly into the browser it does download the product zip file.
I have also tried using curl as described in an answer to this question
curl -u username:usrpass -JO "https://scihub.copernicus.eu/dhus/odata/v1/Products('18f7993d-eae1-4f7f-9d81-d7cf19c18378')/$value"
but I get the error
Warning: Remote filename has no length!
I can't yet access the APIhub, only the science hub, (although a colleague with APIhub access has tried that too and had the same problem). I am able to use the science hub gui to interactively download data but would like to be able to automate the process. There are third party python scripts and shell scripts around, but many use the API hub, and I would like to understand what I am doing so I can develop specific scripts.