{"id":25332613,"url":"https://github.com/ubidots/ubidots-java","last_synced_at":"2025-10-29T07:30:37.050Z","repository":{"id":57729259,"uuid":"12837546","full_name":"ubidots/ubidots-java","owner":"ubidots","description":"A Java API client for Ubidots","archived":false,"fork":false,"pushed_at":"2016-10-25T23:35:46.000Z","size":3580,"stargazers_count":5,"open_issues_count":0,"forks_count":8,"subscribers_count":19,"default_branch":"master","last_synced_at":"2023-12-07T18:22:00.048Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"ubidots.com/docs/libraries/java.html","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ubidots.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-14T23:19:01.000Z","updated_at":"2023-12-07T18:22:00.049Z","dependencies_parsed_at":"2022-09-10T23:41:51.748Z","dependency_job_id":null,"html_url":"https://github.com/ubidots/ubidots-java","commit_stats":null,"previous_names":[],"tags_count":7,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ubidots%2Fubidots-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ubidots%2Fubidots-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ubidots%2Fubidots-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ubidots%2Fubidots-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ubidots","download_url":"https://codeload.github.com/ubidots/ubidots-java/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238785247,"owners_count":19529931,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-14T04:52:47.186Z","updated_at":"2025-10-29T07:30:31.499Z","avatar_url":"https://github.com/ubidots.png","language":"Java","readme":"===================================\nUbidots Java API Client\n===================================\n\nThe Ubidots Java API Client makes calls to the `Ubidots API \u003chttp://things.ubidots.com/api\u003e`_.  You can get the library from our `Github account \u003chttps://github.com/ubidots/ubidots-java\u003e`_.\n\nMaven\n------\n\nAdd this dependency to your project's POM::\n\n    \u003cdependency\u003e\n      \u003cgroupId\u003ecom.ubidots\u003c/groupId\u003e\n      \u003cartifactId\u003eubidots-java\u003c/artifactId\u003e\n      \u003cversion\u003e1.6.6\u003c/version\u003e\n    \u003c/dependency\u003e\n\n\nDependencies\n-----------------------------\n\nUbidots for Java is available as an unbundled jar, with the following dependencies:\n\n\n* `Gson \u003chttp://code.google.com/p/google-gson/\u003e`_, the open-source Google JSON library\n* `Apache HttpCore \u003chttp://hc.apache.org/downloads.cgi\u003e`_, Apache's open-source implementation of HTTP\n* `Apache HttpClient \u003chttp://hc.apache.org/downloads.cgi\u003e`_, Apache's open-source implementation of an HTTP agent\n* `Apache Commons - Logging \u003chttp://commons.apache.org/proper/commons-logging/\u003e`_, a dependency of Apache HttpClient (no logging is actually used)\n\n\nFor the latest version of the dependencies, follow the above links. To download the latest versions *at the time of writing*, use the commands below:\n\n.. code-block:: bash\n\n    $ wget http://google-gson.googlecode.com/files/google-gson-2.2.4-release.zip\n    $ wget http://apache.claz.org//httpcomponents/httpcore/binary/httpcomponents-core-4.3.1-bin.tar.gz\n    $ wget http://apache.claz.org//httpcomponents/httpclient/binary/httpcomponents-client-4.3.3-bin.tar.gz\n    $ wget http://mirror.sdunix.com/apache//commons/logging/binaries/commons-logging-1.1.3-bin.tar.gz\n\n\nConnecting to the API\n----------------------\n\nBefore playing with the API you must be able to connect to it using your private API key, which can be found `in your profile \u003chttp://app.ubidots.com/userdata/api/\u003e`_.\n\nIf you don't have an account yet, you can `create one here \u003chttp://app.ubidots.com/accounts/signup/\u003e`_.\n\nOnce you have your API key, you can connect to the API by creating an ApiClient instance. First, import all classes from the com.ubidots package:\n\n.. code-block:: java\n\n    import com.ubidots.*;\n\nLet's assume your API key is: \"7fj39fk3044045k89fbh34rsd9823jkfs8323\" then your code would look like this:\n\n.. code-block:: java\n\n    ApiClient api = new ApiClient(\"7fj39fk3044045k89fbh34rsd9823jkfs8323\");\n\nNow you have an instance of the ApiClient class (\"api\") which can be used to connect to the API service.\n\n\nCreating a DataSource\n----------------------\n\nAs you might know by now, a data source represents a device or a virtual source.\n\nThis line creates a new data source:\n\n.. code-block:: java\n\n    DataSource dataSource = api.createDatasource(\"myNewDs\");\n\n\nThis new data source can be used to track different variables, so let's create one.\n\n\nCreating a Variable\n--------------------\n\nA variable is a time-series containing different values over time. Let's create one:\n\n\n.. code-block:: java\n\n    Variable variable = dataSource.createVariable(\"myNewVar\");\n\n\nNow you have a new variable, so let's create a new value for this variable.\n\n\nSaving a new Value to a Variable\n--------------------------------\n\nGiven the instantiated variable, you can save a new value with the following line:\n\n.. code-block:: java\n\n    variable.saveValue(10);\n\nUnlike the Python library, the timestamp for the value is automatically created for the value on the client-side.\n\n\nSaving Values in Bulk\n---------------------\n\nValues may also be added in bulk. This is especially useful when data is gathered offline and connection to the internet is limited.\n\n.. code-block:: java\n\n    int[] values = new int[5];        // double[] values also accepted\n    values[0] = 10;\n    values[1] = 1;\n    values[2] = 8;\n    values[3] = 3;\n    values[4] = 5;\n\n    long[] timestamps = new long[5];\n    timestamps[0] = 1380558972614l;\n    timestamps[1] = 1380558972915l;\n    timestamps[2] = 1380558973516l;\n    timestamps[3] = 1380558973617l;\n    timestamps[4] = 1380561122434l;\n\n    var.saveValues(values, timestamps);\n\n\nGetting Values\n--------------\n\nTo get the values for a variable, use the method getValues() in an instance of the class Variable.\n\n.. code-block:: java\n\n    Value[] values = variable.getValues();\n\n\nGetting all the Data sources\n-----------------------------\n\nIf you want to get all your data sources you can use the instance of the API directly:\n\n.. code-block:: java\n\n    DataSource[] dataSources = api.getDataSources();\n\n\nGetting a specific Data source\n------------------------------\n\nEach data source has a unique id that tells the server which one to retrieve.\n\nFor example, if a data source has the id 51c99cfdf91b28459f976414, it can be retrieved using the method getDatasource(String) of the ApiClient instance:\n\n\n.. code-block:: java\n\n    DataSource mySpecificDataSource = api.getDataSource(\"51c99cfdf91b28459f976414\");\n\n\nGetting All Variables from a Data source\n-----------------------------------------\n\nYou can also retrieve all the variables of a data source:\n\n.. code-block:: java\n\n    Variable[] allDataSourceVariables = dataSource.getVariables();\n\n\nGetting a specific Variable\n------------------------------\n\nAs with data sources, use your variable's id to retrieve the details about a variable:\n\n.. code-block:: java\n\n    Variable mySpecificVariable = api.getVariable(\"56799cf1231b28459f976417\");\n\n\nGetting basic statistic data\n----------------------------\n\nYou can use the Ubidots statistics endpoint by calling the specific method:\n\n* *getMean()*\n* *getVariance()*\n* *getMin()*\n* *getMax()*\n* *getCount()*\n* *getSum()*\n\nThis methods are present in your variable instance.\n\nUsage example\n\n.. code-block:: java\n\n    Variable mySpecificVariable = api.getVariable(\"56799cf1231b28459f976417\");\n    double mean = mySpecificVariable.getMean();\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fubidots%2Fubidots-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fubidots%2Fubidots-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fubidots%2Fubidots-java/lists"}