For the complete documentation index, see llms.txt. This page is also available as Markdown.

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: ess-dive-support@lbl.gov

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"

Setup in R

Install the following R packages

install.packages("httr")
install.packages("jsonlite")
install.packages("readr")

#Require the package so you can use it
require("jsonlite")
require("httr")
library(readr)

Setup the Dataset API information

token <- "<Enter your authentication token here>"
base <- "https://api-sandbox.ess-dive.lbl.gov"
header_authorization <- paste("bearer",token, sep=" ")
endpoint <- "packages"

Setup in Java

To be able to do the setup correctly, you need a few prerequisites installed on your machine which are unzip, java, javac and curl.

Inside your project directory create a java file named essdive.java and a directory lib. The following are the Linux commands to create the file and directory:

Add http client, http core and commons logging from Apache HTTPComponents libraries version 4.5.6 and json_simple-1.1 into your lib directory by downloading its zip file, extracting it and moving it inside lib.

Open essdive.java document created earlier using any text editor and add the following code to start importing the libraries needed for your java code:

Definition of configuration variables

Inside the main function you should define your configuration variables:

Then define your utilities objects:

Troubleshoot

Python Troubleshooting Tips

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.

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.

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.

R Troubleshooting Tips

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.

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.

Currently no troubleshooting tips are available in Java.

Last updated