Communicate with Couchbase lite with RESTful API using low-level C/Java API?

380 views
Skip to first unread message

Sebastien Flaesch

unread,
Mar 5, 2014, 9:06:14 AM3/5/14
to mobile-c...@googlegroups.com
Hello,

I am new to Couchbase so forgive me for this question if it's obvious:

Couchbase lite supports RESTful API as described here:
http://docs.couchbase.com/couchbase-lite/cbl-api/

Reading that documentation, I did not found how to send HTTP requests to the local Couchbase lite
software component of a mobile application...

I found the doc about PhoneGap, but if I understand correctly, this is a complete framework/container?

I do not want to use the "Native APIs" (Java / Objective-C) ...

Is there no low-level way, using the C SDK for example?
http://www.couchbase.com/autodocs/couchbase-c-client-2.2.0/lcb_make_http_request.3couchbase.html
Or is this only for Couchbase server client programming?

Not quite clear if the "SDKs" apply to Couchbase server programming, Couchbase lite or both...

Thanks!
Seb

J. Chris Anderson

unread,
Mar 5, 2014, 9:10:37 AM3/5/14
to mobile-c...@googlegroups.com
It would help to know what you are aiming to accomplish. What platforms are your targeting to run your C code on?

Couchbase Server has a mature C library. If you want to interact with data from your servers in the cloud, this is probably a good bet. If you are writing C code on mobile devices, it would help to know more...

Chris

Sebastien Flaesch

unread,
Mar 5, 2014, 9:24:36 AM3/5/14
to mobile-c...@googlegroups.com
We target both iOS and Android platforms.
We want to store data locally on CBLite and get automatic db sync with a central database.
Apps must be able to run in standalone mode, when no network is available.
Seb

Jens Alfke

unread,
Mar 5, 2014, 10:06:25 AM3/5/14
to mobile-c...@googlegroups.com
On Mar 5, 2014, at 6:06 AM, Sebastien Flaesch <sebastie...@gmail.com> wrote:

Reading that documentation, I did not found how to send HTTP requests to the local Couchbase lite
software component of a mobile application...

Get the internalURL property of the CBLManager instance, which is the root URL of the REST API, and then send requests to it.

I do not want to use the "Native APIs" (Java / Objective-C) ...
Is there no low-level way, using the C SDK for example?
http://www.couchbase.com/autodocs/couchbase-c-client-2.2.0/lcb_make_http_request.3couchbase.html
Or is this only for Couchbase server client programming?

That’s for Couchbase Server. Completely different API, used for writing app servers.

I don’t really understand what you want. You want to use C, but talk to the internal REST API? Why? I mean, you can, but it’s going to take a lot of code and be lower performance than using the native APIs...

—Jens

Sebastien Flaesch

unread,
Mar 5, 2014, 11:04:10 AM3/5/14
to mobile-c...@googlegroups.com
Thank you Jens for the tip...

Our product is a programming language called Genero, it's neither Java nor C, it's a simple programming language designed for SQL.
With our solution, you compile to our proprietary pcode then you execute on any platform we support with our virtual machine (like with java).
Our VM is written in C and on Unix/Windows/MacOSX we can access different RDBMS databases through db client C APIs...
We are now on mobile (iOS/Android), and we are looking for a cross-platform solution to access NoSQL mobile databases from our VM.
I don't think we should have wrappers for all CBLite native APIs, as classes in our language.
Our solution cannot be platform specific, and I suspect that CBLite Native APIs for iOS and Android are a bit different...

Why would the CBLite Native APIs be faster than the REST API?
I thought the native APIs are built on top of the REST API...
(I mean, the real native API of Couch* databases in REST, no?)

Seb

Jens Alfke

unread,
Mar 5, 2014, 1:14:03 PM3/5/14
to mobile-c...@googlegroups.com
On Mar 5, 2014, at 8:04 AM, Sebastien Flaesch <sebastie...@gmail.com> wrote:

I don't think we should have wrappers for all CBLite native APIs, as classes in our language.
Our solution cannot be platform specific, and I suspect that CBLite Native APIs for iOS and Android are a bit different…

The Couchbase Lite bridges to Titanium and MonoTouch use wrappers to the native APIs.
The Objective-C and Java APIs are conceptually the same, though there are differences because they’re in different languages.

Why would the CBLite Native APIs be faster than the REST API?
I thought the native APIs are built on top of the REST API…

No, the other way around. It’s a native implementation with native APIs, and there’s an adapter on top of that (the CouchbaseLiteListener framework, on iOS) that adds the HTTP handlers.

We had an earlier version where the native APIs were wrappers around REST calls, but it was significantly slower and required more code.

—Jens

Reply all
Reply to author
Forward
0 new messages