Git Product home page Git Product logo

cartodb-java-client's Introduction

#CartoDB Java Client

##Description Tiny CartoDB Java client that can be instantiated as regular (public) or secured (private). Once instantiated, you can send queries to CartoDB and get a JSON string as response.

##Building In order to build a new JAR for this SDK you need to have installed Gradle which is the building system.

Once you have Gradle installed, you must run gradle clean to remove previous builds and gradle build to generate the new JAR.

After the build process is finished you could find the new generated JAR in the gradleBuild/libs folder

##Usage

With this library you have access to private and public tables. In order to access to public tables you do not need to be authenticated but if you want to read or write data to a private table or write data to a public table you need to.

CartoDB provides two ways to auth, oauth or api key, please read CartoDB Authentication documentation for detailed info on this topic.

Using oAuth

//Access to your private table or update your table
CartoDBClientIF cartoDBCLient= new SecuredCartoDBClient("youraccount","yourpassword","consumerKey","consumerSecret");
System.out.println(cartoDBCLient.executeQuery("UPDATE yourtable SET yourvalue = 'test' WHERE yourid = 1"));

Using API key

//Access to your private table or update your table using the api key
CartoDBClientIF cartoDBCLient= new ApiKeyCartoDBClient("youraccount", YOUR_API_KEY);
System.out.println(cartoDBCLient.executeQuery("UPDATE yourtable SET yourvalue = 'test' WHERE yourid = 1"));

Access to Public tables (no auth required)

//Access to your public table
CartoDBClientIF cartoDBCLient= new CartoDBClient("youraccount");
System.out.println(cartoDBCLient.executeQuery("SELECT * FROM yourtable LIMIT 1"));

get results as java object

executeQuery method returns the raw json response. If you want to retrieve the json already parsed into a java object you can use request method, see next example:

// get rows as a Map
CartoDBResponse<Map<String, Object>> res = cartoDBCLient.request("select * from mytable limit 1");
System.out.print(res.getTotal_rows(), 1);
System.out.print(res.getRows().get(0).get("cartodb_id"));

##Dependencies Included in lib folder

##TODO

  • Include error JSON on HTTP response 400.

License

read LICENSE file

cartodb-java-client's People

Contributors

javisantana avatar cgendreau avatar eightysteele avatar grisaf avatar nachoorme avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.