Coder Social home page Coder Social logo

storm-api's Introduction

smart-api Build Status Codacy Badge

WebAPI for getting data from IoT and pushing them to the Kafka queue

Adding measurements via a POST request

Adding measurements data for a sensor is a fairly simple task. What you need to do is to send a POST request to this URL:
http://alfa.smartstorm.io/api/v1/measure
You will need to set the herein specified fields in your request:

  1. user_id - set this to your alfa.smartstorm.io site login, eg. "[email protected]",
  2. sensor_id - the id of the sensor you wish to upload data for, eg. "1234567890abcdefedcba098",
  3. desc - a description for your measurement. This can be pretty much anything, for example: "humidity"
  4. measure_value - the measured value, for example 10.

Sample code in python using requests library is provided here:

import requests
url = "http://alfa.smartstorm.io/api/v1/measure"
data = {"user_id": "[email protected]",
        "sensor_id": "1234567890abcdef",
        "desc" : "some_random_description",
        "measure_value" : "10"}
r = requests.post(url,data)

Fetching measurements via a GET request

Fetching of given sensor's measurement is achieved via a HTTP GET request send to the following URL address:
http://alfa.smartstorm.io/api/v1/measure
This request should be sent with following GET parameters (appended to the URL address):

  1. user_id - set this to your alfa.smartstorm.io site login, eg. "[email protected]",
  2. sensor_id - the id of the sensor which data you wish to fetch, eg. "1234567890abcdefedcba098",
  3. offset - an integer value equal to the value of the "created_epoch" field of the latest measurement you would like to skip. Eg. If you wish to load measurements newer than your recently fetched sample whose created_epoch == 1554, set the offset parameter to 1554. Offset parameter equal to 0 returns all available measurements for the given sensor.

A sample GET /measure request taken from an iOS client app looks like this:

NSString *userId = @"[email protected]";
NSString *sensorId = @"sensorId-from-smartstorm";
NSString * targetUrl = [NSString stringWithFormat:@"http://alfa.smartstorm.io/api/v1/measure?user_id=%@&sensor_id=%@&offset=%@",userId, sensorId, self.offset];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setHTTPMethod:@"GET"];
[request setURL:[NSURL URLWithString:targetUrl]];

storm-api's People

Contributors

jwszolek avatar vashingmachine avatar baaarteeek avatar mol9 avatar opiechow avatar jakardas avatar

Watchers

James Cloos avatar  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.