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"Check that your token is up-to-date; it expires after 24 hours
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"Check that your token is up-to-date; it expires after a 24 hours
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:
Note: You will have to close the class and main blocks by adding two closing curly braces at the end of the document.
Then define your utilities objects:
Check that your token is up-to-date; it expires after a 24 hours
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