[SOLVED] Connection to UBI API using Socket library in C

Hi all ,

Need your help in connecting to API using socket library in C. If you have any applications developed , please point me in that direction.

Waiting for your reply !!

Avinash

Hi @avinash_386, sure; did you check our C library? https://github.com/ubidots/ubidots-c

A quick example:

#include <ubidots.h>

int main() {
  UbidotsClient *client = ubidots_init(API_KEY);

  while ( keepGoing() ) {
    double value = getValue();
    ubidots_save_value(client, VARIABLE_ID, value, TIMESTAMP_NOW);
  }

  ubidots_cleanup(client);

  return 0;
}

Hi ,

I wish not to use ubidots header file.
Find below the use of third party headers like httparty to connect with your API.

class Ubidots
    require   'httparty'
base_uri  'things.ubidots.com'
#format :json
port = '80'

def initialize(api)
	@ApiClient = "API_KEY_GOES_HERE"
end

def initialize(test_variable)
	@api.get_variable 	"Variable_goes_here"
end


self.class.get("http://things.ubidots.com/api/v1.6/" )

end

If there is any example code to achieve this please let me know.

Hi @avinash_386, sorry I couldn’t find an example with third party headers. Is httparty a Ruby library? if so, here’s a ruby example: http://ubidots.com/docs/libraries/ruby.html