If you don't have an ECMWF account, please self register at https://appsapi.ecmwf.int/registration/v1/key ( click login and then register ) and then follow follow ONE of the steps below.
HTML |
---|
<script type="text/javascript"> var urlApiKey = 'https://cors-proxy.ecmwf.int/https://api.ecmwf.int/v1/key/'; var API_FILENAME = '.ecmwfapirc'; var FILE_TYPE = 'application/octet-stream'; //'application/ecmwfapirc'; //'application/json'; //'.ecmwfapirc'; //'text/plain'; causes chrome to append .txt $(function() { getApiInfo(function(apiInfo){ AJS.$('#apiInfo').append('<br /><p>You can use any of the 3 listed methods:</p><br />'); AJS.$('#apiKey').append('<h4> 1. (Recommended) Save your API key credentials into a file</h4>' + apiInfo.apiKey + '<br \>'); AJS.$('#envVars').append(typeof apiInfo.envVars=='undefined' ? '' : '<h4>2 2. Environment variables</h4>variables' + apiInfo.envVars + '<br \>'); AJS.$('#objServer').append(typeof apiInfo.objServer=='undefined' ? '' : '<h4>3 3. Include this information in your Python script when creating the ECMWFDataServer/ECMWFService Object</h4>Object' + apiInfo.objServer); }); }); function getApiInfo(obj) { AJS.$.ajax({ url: urlApiKey, data: {format: 'json'}, method: 'get', xhrFields: { withCredentials: true }, crossDomain: true }).done(function(json){ obj({ 'apiKey':'<p>Copy / paste the text below into a blank text file and save it to your $HOME directory as <b>' + API_FILENAME + '</b> (If you use Windows, you have to put the file in C:\\Users\\(USERNAME)<USERNAME>\\.ecmwfapirc ; see <a href="https://gist.github.com/ozh/4131243">how to create a file with a leading dot</a>.)</p><pre><code>' + JSON.stringify(json, null, ' ') + '</code></pre>', 'envVars':'<p>Set these environment variables before executing the Python script:</p><pre><code>export ECMWF_API_URL="' + json.url + '"\nexport ECMWF_API_KEY="' + json.key + '"\nexport ECMWF_API_EMAIL="' + json.email + '"</code></pre>', 'objServer':'<pre><code>server = ECMWFDataServer(url="' + json.url + '",key="' + json.key + '",email="' + json.email + '")\n#or\nserver = ECMWFService("mars", url="' + json.url + '",key="' + json.key + '",email="' + json.email + '")</code></pre>' }); }).fail(function(jqXHR, textStatus){ console.error('Request failed: ' + textStatus); obj({ 'apiKey':'<p>Your<p style="color:red"><b>Your API key information is not available here - try <a href="https://api.ecmwf.int/v1/key/">https://api.ecmwf.int/v1/key/</a>.</b></p><ul><li>If you are not logged in, please log in to <a href="https://www.ecmwf.int">www.ecmwf.int</a> first.</li><li>If you are logged in, please <a href="https://wwwsupport.ecmwf.int/en/about/contact-us">let our Service Desk know</a> that ' + window.location.href + ' is not working as expected. Please provide us with your username and screenshots or error messages if possible so that we can investigate and fix the problem.</li></ul><p>We apologise for any inconvenience.</p>' }); //TODO: could send back empty string for envVars and objServer? }); } </script> <style> pre { background-color: #eff0f1; padding: 1em; } </style> <div id="apiInfo"></div><br /> <div id="apiKey"></div> <div id="envVars"></div> <div id="objServer"></div> |
You can also try visiting https://api.ecmwf.int/v1/key/ to retrieve your credentials.
Info |
---|
Note that the key expires in 1 year. You will receive an email to the registered email address 1 month before the expiration date with the renewal instructions. |