REST API (Representational State Transfer Application Programming Interface or RESTful web service) is a web API implemented using HTTP and the principles of REST. It is a collection of resources, with four defined aspects:
  • Base URI (e.g.
  • Internet media type of the data supported (JSON, XML, ...)
  • Set of operations using HTTP methods (GET, PUT, POST, or DELETE)
  • Hypertext driven

Tools for the REST API Communication

The following examples use Linux tools - wget, curl, and Java tool: Apache Ant. You can also use Firefox REST API plugin for the simulations.

LIST (GET) Operations

You get a list of databases or one database connect string using the HTTP GET method and tools wget or curl. The examples show, how to get plain text connect string, XML or JSON format strings.
export TNSADMIN_USER=tnsadmin
export TNSADMIN_PASSW=tnsadmin
wget -S -q -O - ${TNADMIN_URL}/tnsnames.ora
wget -S -q -O - ${TNADMIN_URL}/tnsnames.ora?code=mydb
wget -S -q -O - ${TNADMIN_URL}/tnsnames.ora?id=MYDB.TNSADMIN.NET 2> /dev/null
wget -S -q --header "Accept: application/json" -O - ${TNADMIN_URL}/api/databases
wget -S -q --header "Accept: application/xml" -O - ${TNADMIN_URL}/api/databases
wget -S -q --header "Accept: application/json" -O - ${TNADMIN_URL}/api/databases/MYDB.TNSADMIN.NET
wget -S -q --header "Accept: application/xml" -O - ${TNADMIN_URL}/api/databases/MYDB
curl -i -H "Accept: application/json" ${TNADMIN_URL}/api/databases
curl -i -H "Accept: application/xml" ${TNADMIN_URL}/api/databases
Apache Ant can be used to automate various database update tasks (Java platform):
<?xml version="1.0" encoding="UTF-8" ?>
<project name="Connect to database" default="all" basedir=".">
<property name="db.code" value="MYDB" />
<property name="tnsadmin.url" value="${db.code}&type=jdbc" />
<property name="db.file" value="/tmp/db.txt" />

<target name="">
<!-- get database connect properties -->
<get src="${tnsadmin.url}" dest="${db.file}" />
<loadfile property="db.connect" srcFile="${db.file}" />
<delete file="${db.file}" />
<!-- use db.file property to connect to a database -->


Update operations require the authentication and authorization. The URI /api/secured is for this reason secured using BASIC authentication and requires administration role.
Let's create a XML input file (rest_sample1.xml) with 'id' element, which is unique.
The following code creates new item (XML format is used here, content type must be specified):
curl -X PUT --data-binary @/home/myuser/rest_sample1.xml -u "${TNSADMIN_USER}:${TNSADMIN_PASSW}" -H "Content-Type: application/xml" ${TNADMIN_URL}/api/secured/database


Update operation also contains 'id' specifier of the database. The sent XML can contain different 'id' value, if the item is about to be replaced. The JSON format is also supported.
Let's create other XML input file (rest_sample2.xml):
The following code updates existing item:
curl -X POST \
     --data-binary @/home/myuser/rest_sample2.xml \
     -H "Content-Type: application/xml" ${TNADMIN_URL}/api/secured/database/MYDB.TNSADMIN.NET


Delete operation contains 'id' specifier of the database. The following code deletes existing item:
curl -X DELETE \
     -H "Accept: application/xml" ${TNADMIN_URL}/api/secured/database/MYDB1.TNSADMIN.NET


REST API is an efficient method of getting the database connection parameters. It can be used for automating various enterprise tasks and solutions (deployment of connection pools, update of databases, configuration of JEE applications, etc.)