slashdb_api/db takes an existing database model and automatically constructs a web service API from it. This makes your data instantly accessible to mobile applications, websites or enterprise systems.

/db works in two modes:

  • Data Discovery – automatically reflects all objects in database as URL addressable resources
  • SQL Pass-thru – configure any SQL statement and map it to a URL

In both modes data becomes addressable via simple URL.

Data Discovery Mode

In this mode all records automatically become HTTP resources, which can be read and udpated.

For example an individual Customer’s record in the Chinook database would be referenced like so:

http://demo.slashdb.com/db/Chinook/Customer/CustomerId/1.html

Data becomes instantly available in several convenient data formats such as XML, JSON and comma-separated values text (CSV). The same record represented in JavaScript Object Notation (JSON) would be addressable as follows:

http://demo.slashdb.com/db/Chinook/Customer/CustomerId/1.json

/db effectively constructs a graph representation of all relational databases behind it. The system reflects the data model’s relationships, so links between related records are natural to follow.

For example, customer’s invoices can be referenced as:

http://demo.slashdb.com/db/Chinook/Customer/CustomerId/1/Invoice.html,

or from the side of the Invoice table like this:

http://demo.slashdb.com/db/Chinook/Invoice/CustomerId/1.html

Drill-downs to vector slices and individual scalar values are also supported without sacrificing clarity of the URL link.

Customer’s name by itself, represented in XML can be reached using this URL:

http://demo.slashdb.com/db/Chinook/Customer/CustomerId/1/FirstName.xml

Customers first name, last name and phone number:

http://demo.slashdb.com/db/Chinook/Customer/FirstName,LastName,Phone.html?limit=10

In-lining related records within a document of a parent record is another powerful mechanism that simply works out of the box. In a single request you can get a Customer record with all his/her Invoice records.

http://demo.slashdb.com/db/Chinook/Customer/CustomerId/1.json?depth=1

There are plenty more powerful features in Data Discovery, but sometimes you may want or need to run an SQL query or a stored procedure. The next section in about that.

SQL Pass-thru Mode

Using this mode SlashDB administrator or a application backend developer can define arbitrary SQL queries using SlashDB configuration GUI. Once defined, those queries can be executed using a URL. For example this query returns customers from London:

http://demo.slashdb.com/query/customers-in-city/city/London.html

As before the results are available in all supported formats simply by changing the extension of the URL:

Queries can be fully parameterized. In fact to get customers from another city user would simply substitute that part of the URL:

http://demo.slashdb.com/query/customers-in-city/city/Chicago.html

See Also

We invite you to our live demo and to read about number of use cases, where /db offers unmatched benefits in software solution design.