NOAA   ERDDAP   Easier access to scientific data    
Brought to you by NOAA NMFS SFSC ERD    

ERDDAP > Computer Programs

Accessing ERDDAP as a Web Service

ERDDAP is both: For every ERDDAP feature that you as a human with a browser can use
(for example, Full Text Search for datasets),
there is an almost identical feature that is designed to be easy for computer programs to access
(for example, Full Text Search for datasets which returns the results as some other file type, like JSON),
These features can be used by computer programs or scripts that you write.
And they can be used to build other web applications or web services on top of ERDDAP
(making ERDDAP do most of the work!).
So if you have an idea for a better interface to the data the ERDDAP serves,
we encourage you to build your own web application or web service, and use ERDDAP as the foundation.
Your system can get data, graphs, and other information from our ERDDAP server, or you can set up your own ERDDAP server.

Requests
Requests for interface information from ERDDAP (for example, search results) use the web's universal standard for requests: HTTP GET.
This is the same mechanism that your browser uses when you fill out a form on a web page and click on Submit.
To use HTTP GET, you generate a specially formed URL (perhaps with a query) and send it to the web with HTTP GET.
You can form these URLs by hand and enter them in the address textfield of your browser
(for example, http://coastwatch.pfeg.noaa.gov/erddap/search/index.json?searchFor=temperature),
or a computer program can be written to create the URLs, submit them, and get the responses.
Often, the computer program will need to percent encode the URL
(for example, replace " " in a query value with "%20", for example, "searchFor=temperature%20wind%20speed").
(Browsers do this for you automatically when you fill out a form on a web page and click on Submit.)
Programming languages have tools to do this (for example, see java.net.URLEncoder).
HTTP GET was chosen because it is simple, it works,
it is universally supported (in browsers, computer languages, operating system tools, etc),
and it is a foundation of REST and ROA.
These URLs are great because they completely define a given request,
and you can bookmark them in your browser, write them in your notes, email them to a friend, ...

Requesting Compressed Files
ERDDAP doesn't offer results stored in compressed (e.g., .zip or .gzip) files.
Instead, ERDDAP looks for accept-encoding in the HTTP GET request header sent by the client.
If a supported compression type ("gzip", "x-gzip", or "deflate") is found in the accept-encoding list,
ERDDAP includes "content-encoding" in the HTTP response header and compresses the data as it transmits it.
It is up to the client program to look for "content-encoding" and decompress the data.
Browsers and OPeNDAP clients do this by default. They request compressed data and decompress the returned data automatically.
Other clients (e.g., Java programs) have to do this explicitly.

Responses
Although humans using browsers want to receive interface results (for example, search results) as HTML documents,
computer programs often prefer to get results in simple, easily parsed, less verbose documents.
ERDDAP can return interface results as a table of data in these common, computer-program friendly, file types:

The first row of the table has the column names.
In some types of files, the second row has the column's Java-style data type (e.g., "String" or "float").
Subsequent rows of the table have the results.

.csv and .tsv issues:

Requests for .json files may now include an optional jsonp request
by adding "&.jsonp=functionName" to the end of the query.
Basically, this just tells ERDDAP to add "functionName(" to the beginning of the response
and ")" to the end of the response.
If originally there was no query, leave off the "&" in your query.

Remember that these are the file types ERDDAP can use to respond to user-interface types of requests (for example, search requests).
ERDDAP supports a different set of file types for the actual data (for example, satellite and buoy data) requests (see griddap and tabledap).

Access URLs
ERDDAP has these URL access points for computer programs:

Using ERDDAP as a Data Source within Your Java Program

As described above, since Java programs can access data available on the web,
you can write a Java program that accesses data from any publicly accessible ERDDAP installation.

Or, since ERDDAP is an all-open source program, you can also set up your own copy of ERDDAP
on your own server (internal or public) to serve your own data.
Any Java programs that you write can get data from that copy of ERDDAP.

Or, since ERDDAP is an all-open source, all-Java program,
you can also set up your own copy of ERDDAP on your own computer within your Java program.
Then you can access ERDDAP's services from within your program
(for example, doing full-text searches for datasources or creating data files from remote data sources) .
See Set Up Your Own ERDDAP, especially the JavaDocs for the gov.noaa.pfel.erddap.Erddap class.
 
ERDDAP Version 1.22


Questions, comments, suggestions? Contact bob dot simons at noaa dot gov.
ERDDAP is a brought to you by NOAA NMFS SFSC ERD.
Disclaimers | Privacy Policy
Usage Limitations - The SeaWiFS images and data from this site may be used for free, but not redistributed;
    all other images and data from this site may be used and redistributed for free.