Koks_rs
Koks_rs

Reputation: 680

How to get table content via REST API

I am wondering how I can get table content via Hbase REST API ?

Example: If I have table "users" and I want all users then I will execute

scan "users" 

How I can do it via REST Api ?

I didn't find it in docs http://hbase.apache.org/book.html#_rest Is it possible ?

Upvotes: 1

Views: 1330

Answers (1)

Nishu Tayal
Nishu Tayal

Reputation: 20860

You can't directly query the entire table using REST API.
First you need to call /table/scanner with a batch size, it will return the scanner ID.

Next, pass that scanner ID to the /table/scanner/<scanner-id> endpoint, it will return the number of rows(=batch size) each time, you call until it is exhausted

curl -vi -X PUT \
  -H "Accept: text/xml" \
  -H "Content-Type: text/xml" \
  -d '<Scanner batch="1"/>' \
  "http://example.com:8000/users/scanner/"

It will return a LOCATION in HTTP response as scanner endpoint : http://example.com:8000/users/scanner/123

Then call :

curl -vi -X GET \
  -H "Accept: text/xml" \
  "http://example.com:8000/users/scanner/123"

It will return the data in batches.

Upvotes: 2

Related Questions