Setup and Troubleshoot

All Dataset API code examples require installation of certain packages and authentication from your ESS-DIVE account. This page provides instructions for setting up the Dataset API for your preferred coding language.

For additional information about the API, review the technical documentation at https://api-sandbox.ess-dive.lbl.gov.

ESS-DIVE Test API URL (Sandbox): https://api-sandbox.ess-dive.lbl.gov ESS-DIVE Production API URL: https://api.ess-dive.lbl.gov/ Help Desk: [email protected]

Setup Code

Step 1: Get Authentication Token: Copy your authentication token from ESS-DIVE, then paste it into the code where specified in the example.

Step 2: Setup your code in your preferred coding language as follows.

Setup in Python

Install the following python module into your python environment

$ pip install requests

In a python console or script add the following lines to setup your script.

import requests
import os
import json

token = "<Enter your authorization token here>"
base = "https://api-sandbox.ess-dive.lbl.gov/"
header_authorization =  "bearer {}".format(token)
endpoint = "packages"

Troubleshoot

Python Troubleshooting Tips

{"detail":"You do not have authorized access"}

This error message indicates your token is either incorrect or expired. Please follow the instructions on the ESS-DIVE Dataset API page to retrieve a new token.

{"detail":"One or more fields raised validation errors.","errors":["provider/member 'familyName' is a required property"]}

This error message indicates a required field is missing from your JSON. In this case it is the "familyName". Revise your JSON to include the mandatory fields.

FileNotFoundError                         Traceback (most recent call last)
<ipython-input-28-7ae5b841a5b0> in <module>
      5 
      6 files_tuples_array.append((("json-ld", json.dumps(json_ld))))
----> 7 files_tuples_array.append(("data", open(file_directory ,'rb')))
      8 
      9 post_packages_url = "{}{}".format(base,endpoint)

FileNotFoundError: [Errno 2] No such file or directory: 'trials.csv'

This error message indicates the file entered was not found. This could be because you are searching in the wrong directory or because you misrepresented the file name.

Last updated