3

I want to know whether PostgreSQL provides support for rest or is there any other way to achieve it?

1
  • 3
    PostgreSQL is an RDBMS, it has nothing to do with REST! But it has JDBC drivers available, so use such a driver with a Java API which does REST and you're set. Strange question, really. After that, which Java ORM (hint: use JooQ) and REST-able API you use is up to you Commented Jan 8, 2015 at 5:58

3 Answers 3

8

Another project that try to solve this is PostgREST. It's written in Haskell not Java, but you can use it from Java using ordinary HTTP requests.

PostgREST serves a fully RESTful API from any existing PostgreSQL database. It provides a cleaner, more standards-compliant, faster API than you are likely to write from scratch.

Sign up to request clarification or add additional context in comments.

1 Comment

Just found ToroDB, also worth a look.
2

Postgres doesn't support an REST interface out of the box. But there is an early draft about adding one: Postgres Wiki So Postgres might add one in a future version. There are some "experiments" for it on Github: link

Right now there are two viable solutions:

  1. Use a third party tool, that provides a rest api for postgres. restsql would be an example.

  2. Implement your own Webservice layer.

It depends on your requirements which way to go:

(2) offers you the most control. You can design the api the way you need it. Modern Java Frameworks (JPA, JAX-RS, Jackson etc.) make it fairly easy and efficient to create a lightweight API layer.

(1) would be viable if you only need a basic way to access a DB over REST.

Comments

1

Disclamer: I am an owner of the product in the answer.

Hello,

You might want to check out https://zenite.io, a database host platform that supports REST endpoints for querying the database data.

For example, you can create an API endpoint /user and define a SQL query on it:

SELECT * FROM users WHERE id = $id;

and then execute a GET request on the database server:

https://server.zenite.io/user?id=1

This URL would return the data in the JSON format:

[
    {
        "rows": [
            {
                "Id": 1,
                "FirstName": "John",
                "LastName": "Doe",
                "Age": 30
            }
        ],
        "code": 0
    }
]

The supported technologies include PostgreSQL, among others.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.