Microshare Admin API

Microshare Admin API

Dev Server : dapp.microshare.io
Prod Server : app.microshare.io


Before tackling the concepts on this page, please follow the Microshare Share API guide first!

These requests allow you to outsource actions made on the Microshare Composer. Before exercising this ability, you must understand how an item works on Microshare before using the corresponding APIs.

For this part we will assume that you are comfortable with interacting with the Microshare APIs, and the Microshare platform..

Have a question not answered here? Do not hesitate to contact us at support@microshare.io!

Authentication

Request and revoke tokens used to authenticate to our API

POST

Request pipe Token

{{authHostname}}/oauth2/token?username={{username}}&password={{password}}&client_id={{apikey}}&grant_type=pipe&scope=ALL:ALL

Request a pipe Authentification token, required to stream data to your microshare account.

You will need to provide username, password, as well as a valid API Key. You can manage your API keys in our Keys Console.

The default scope is ALL:ALL, but you can replace it to request tokens that will allow limited operations. For example, if the scope is SHARE:READ the token will only allow you to read Shares.

PARAMS

username
{{username}}
password
{{password}}
client_id
{{apikey}}
grant_type
pipe
scope
ALL:ALL


Example Request
Request pipe Token
var settings = {
      "url": "{{authHostname}}/oauth2/token?username={{username}}&password={{password}}&client_id={{apikey}}&grant_type=pipe&scope=ALL:ALL",
      "method": "POST",
      "timeout": 0,
    };
    
    $.ajax(settings).done(function (response) {
      console.log(response);
    });
POST

Request Token

{{authHostname}}/oauth2/token?username={{username}}&password={{password}}&client_id={{apikey}}&grant_type=password&scope=ALL:ALL

Request an Authentification token required to use this API.

You will need to provide username, password, as well as a valid API Key. You can manage your API keys in our Keys Console.

The default scope is ALL:ALL, but you can replace it to request tokens that will allow limited operations. For example, if the scope is SHARE:READ the token will only allow you to read Shares.

PARAMS

username
{{username}}
password
{{password}}
client_id
{{apikey}}
grant_type
password
scope
ALL:ALL


Example Request
Request Token
var settings = {
      "url": "{{authHostname}}/oauth2/token?username={{username}}&password={{password}}&client_id={{apikey}}&grant_type=password&scope=ALL:ALL",
      "method": "POST",
      "timeout": 0,
    };
    
    $.ajax(settings).done(function (response) {
      console.log(response);
    });
POST

Request Token via Body

{{authHostname}}/oauth2/token

Request an Authentification token required to use this API.

You will need to provide username, password, as well as a valid API Key. You can manage your API keys in our Keys Console.

The default scope is ALL:ALL, but you can replace it to request tokens that will allow limited operations. For example, if the scope is SHARE:READ the token will only allow you to read Shares.

HEADERS

Content-Type
application/json
PARAMS

BODY raw


{
        "username":"{{username}}",
        "password":"{{password}}",
        "client_id":"{{apikey}}",
        "grant_type":"password",
        "scope":"ALL:ALL"
    }


Example Request
Request Token via Body

Shares

Each piece of data is called a "Share", here you can find all the requests to access your data.

GET

Get one Share

{{hostname}}/share/:recType/:id

Retrieve one share by recType and object id

HEADERS

Authorization
Bearer {{token}}
PATH VARIABLES

recType
io.microshare.test
id
59238b9346e0fb0352c2948b


Example Request
Get one Share
GET

Get Shares by recType

{{hostname}}/share/:recType?details=true

Retrieve all shares under a specific recType

Query parameters available
Parameter Type Description
details boolean true will return matching objects with their details, false will only return main information
page int Specifies the requested page, defaults to 1
perPage int Specifies the number of objects to be returned per page, defaults to 999
HEADERS

Authorization
Bearer {{token}}
PARAMS

details
true
PATH VARIABLES

recType
io.microshare.test


Example Request
Get Shares by recType
GET

Get Shares by Tags and recType

{{hostname}}/share/:recType/tags/:tag1/:tag2?details=true&page=&perPage=

Retrieve all shares under a specific recType and containing one or several tags. Specify as many tags as you need, and objects containing all of these tags will be returned.

Query parameters available
Parameter Type Description
details boolean true will return matching objects with their details, false will only return main information
page int Specifies the requested page, defaults to 1
perPage int Specifies the number of objects to be returned per page, defaults to 999
HEADERS

Authorization
Bearer {{token}}
PARAMS

details
true
page
perPage
PATH VARIABLES

recType
io.microshare.test
tag1
foo
tag2
bar


Example Request
Get Shares by Tags and recType
GET

Get Latest Shares by recType

{{hostname}}/share/:recType/tags/latest?details=true&page=&perPage=

Retrieve all shares under a specific recType

Query parameters available
Parameter Type Description
details boolean true will return matching objects with their details, false will only return main information
page int Specifies the requested page, defaults to 1
perPage int Specifies the number of objects to be returned per page, defaults to 999
sort string Specifies if sorting needs to be applied and to which field in the data
HEADERS

Authorization
Bearer {{token}}
PARAMS

details
true
page
perPage
PATH VARIABLES

recType
io.microshare.test


Example Request
Get Latest Shares by recType
GET

Get Data Through a View

{{hostname}}/share/:view_rectype?view_id=5e9ddb9b46e0fb0028665857&recType=io.microshare.test

Microshare give you access to a powerful tool called a "View", through a view you can query a huge amount of data, transform it, do some calculation and display it as you want.

This API call require the view_id, view_rectype, to use the right view and the rectype value correspond to your data rectype.

HEADERS

Authorization
Bearer {{token}}
PARAMS

view_id
5e9ddb9b46e0fb0028665857
recType
io.microshare.test
PATH VARIABLES

view_rectype


Example Request
Get Data Through a View
POST

Create one Share

{{hostname}}/share/:recType

Create a new share by recType. This inserts a new record into the Microshare data lake.

You must include a record type using the dot notation format (eg. io.microshare.test).

HEADERS

Content-Type
application/json
Authorization
Bearer {{token}}
PATH VARIABLES

recType
io.microshare.test
BODY raw


{
        "hello": "world"
    }


Example Request
Create one Share
POST

Create one Share with Tags

{{hostname}}/share/:recType/tags/:tag1/:tag2/:tag3

Create a new share by recType, with searchable tags. This inserts a new record into the Microshare data lake.

You must include a record type using the dot notation format (eg. io.microshare.test).

Tags allow you to later search objects with the same recType with a GET request. You can specify as many tags as you need.

HEADERS

Content-Type
application/json
Authorization
Bearer {{token}}
PATH VARIABLES

recType
io.microshare.test
tag1
Building
tag2
Floor
tag3
Room
BODY raw


{
        "hello": "world"
    }


Example Request
Create one Share with Tags
DEL

Delete one Share

{{hostname}}/share/:recType/:id

Permanently delete one share by recType and object id

HEADERS

Authorization
Bearer {{token}}
PATH VARIABLES

recType
io.microshare.test
id
592331ce46e0fb0352c293ed


Example Request
Delete one Share

Device

Upload your data and easily share it with the Share API

POST

Create one device

{{hostname}}/device/:recType

Create a new Device Cluster by recType. This creates a new Device Cluster (DC) into your account, this DC is going to handle your device and will start the unpacking process.

You must include a some informations in the body as explained below :

  • name : the name of your DC
  • desc : an optional description of your DC
  • data : contain all the data requested to create your DC
    • isActive : set true if you want your data to be unpacked
    • readAuth, writeAuth, leave it like this
    • devices : set the right informations for your devices so they can work, and their location tags will be assigned.
    • network : the selected Network Server
    • meta : the selected unpacker
    • recType : recType
HEADERS

Content-Type
application/json
Authorization
Bearer {{token}}
PATH VARIABLES

recType
io.microshare.test
BODY raw




Example Request
Create one device
POST

Create one device with Tags

{{hostname}}/device/:recType/tags/:tag1/:tag2

It works the same as the previous request, and the tags will be added as metatags to the DC.

HEADERS

Content-Type
application/json
Authorization
Bearer {{token}}
PATH VARIABLES

recType
io.microshare.test
tag1
foo
tag2
bar
BODY raw


{
      "_id": "foobar",
      "name": "test",
      "desc": "test via api",
      "data": {
        "devices": [],
        "network": {},
        "meta": {}
      }
    }


Example Request
Create one device with Tags
GET

Get All Devices

https://dapi.microshare.io/device/*?details=true&page=1&perPage=200&discover=false&field=name&search=

Get the list of all your device clusters. Including there settings and the devices they contain.

HEADERS

Authorization
Bearer {{token}}
PARAMS

details
true
page
1
perPage
200
discover
false
field
name
search


Example Request
Get All Devices
GET

Get one Device

{{hostname}}/device/:recType/:id

Retrieve one Device Cluster by recType and object id

HEADERS

Authorization
Bearer {{token}}
PATH VARIABLES

recType
io.microshare.test
id
59238b9346e0fb0352c2948b


Example Request
Get one Device
GET

Get Device by recType

{{hostname}}/device/:recType?details=true&page=&perPage=

Retrieve all Device Clusters under a specific recType

Query parameters available
Parameter Type Description
details boolean true will return matching objects with their details, false will only return main information
page int Specifies the requested page, defaults to 1
perPage int Specifies the number of objects to be returned per page, defaults to 999
HEADERS

Authorization
Bearer {{token}}
PARAMS

details
true
page
perPage
PATH VARIABLES

recType
io.microshare.test


Example Request
Get Device by recType
GET

Get Devices by Tags and recType

{{hostname}}/device/:recType/tags/:tag1/:tag2?details=true&page=&perPage=

Retrieve all Device Clusters under a specific recType and containing one or several tags. Specify as many tags as you need, and objects containing all of these tags will be returned.

Query parameters available
Parameter Type Description
details boolean true will return matching objects with their details, false will only return main information
page int Specifies the requested page, defaults to 1
perPage int Specifies the number of objects to be returned per page, defaults to 999
HEADERS

Authorization
Bearer {{token}}
PARAMS

details
true
page
perPage
PATH VARIABLES

recType
io.microshare.test
tag1
foo
tag2
bar


Example Request
Get Devices by Tags and recType
GET

Get Latest Device by recType

{{hostname}}/device/:recType/tags/latest?details=true&page=&perPage=

Retrieve the latest Device Cluster by recType.

Query parameters available
Parameter Type Description
details boolean true will return matching objects with their details, false will only return main information
page int Specifies the requested page, defaults to 1
perPage int Specifies the number of objects to be returned per page, defaults to 999
HEADERS

Authorization
Bearer {{token}}
PARAMS

details
true
page
perPage
PATH VARIABLES

recType
io.microshare.test


Example Request
Get Latest Device by recType
DEL

Delete one Device

{{hostname}}/device/:recType/:id

Permanently delete one Device Cluster by recType and object id

HEADERS

Authorization
Bearer {{token}}
PATH VARIABLES

recType
io.microshare.test
id
5ad9fedfc5d7677f81e4b873


Example Request
Delete one Device
PUT

Update one Device

{{hostname}}/device/:recType/:id

Update one Device Cluster by recType and object id. You will have to set in the Body the new settings of your device cluster. Be careful the changes are permanent.

HEADERS

Authorization
Bearer {{token}}
PATH VARIABLES

recType
io.microshare.test
id
5ad9fedfc5d7677f81e4b873
BODY raw


{
      "name": "test22",
      "desc": "test via api",
      "data": {
        "devices": [],
        "network": {},
        "meta": {}
      }
    }


Example Request
Update one Device

Rule

Access your Microshare sharing Rules directly from the API, get the list of your rules, create or modify a rule and finally if necessary you can delete a Rule.

GET

Get All Rules

{{hostname}}/rule/*?details=true&page=1

Get the list of all your Rules. You will be able to see what you are sharing with who like if you were on the Microshare Composer.

HEADERS

Content-Type
application/json
Authorization
Bearer {{token}}
PARAMS

details
true
page
1


Example Request
Get All Rules
GET

Get Rules by recType

{{hostname}}/rule/*?details=true&page=1

Get the list of your Rules by recType.

You will be able to see what you are sharing with who like if you were on the Microshare Composer.

HEADERS

Content-Type
application/json
Authorization
Bearer {{token}}
PARAMS

details
true
page
1


Example Request
Get Rules by recType
POST

Create Rule by recType

{{hostname}}/rule/:recType/

Create a share Rule directly form the API, simply complete the body to set which data you share with who.

Here are the details on the different body tags :

  • name : the name of your sharing rule
  • desc : (optional) add a description to this sharing rule
  • data :
    • resourceType : what are you looking to share ?
    • resourceId : are you looking to share only a specific resource so specify its id, otherwise leave "*"
    • ownerUser : put the email of the owner of the resource. Indeed it might be you, but if someone share you something with the "Policy" value you can share it from your account then.
    • ownerOrg : put the org of the owner of the resource.
    • ownerApp : put the owner AppKey, it's easier to leave "*"
    • callingUser, callingOrg, callingApp, callingRole, callingLoc : who should be able to get this resource ? leave as "*" for everyone, or specify at the right step (user/org/role ..) who should have access.
    • operations : which access do you give ?
      - Read : ability to simply read the resource
          - Query : ability to query the resource (through a view for instance)
          - Write : ability to modify the resource, or write a resource if it's an access to entire recType for instance
          - Delete : ability to delete the resource or part of it
          - Execute : ability to execute the resource (use a view for instance)
          - Policy : ability to share the resource again
          
      you can set many operations at once :
      • "operations":[ "Read", "Read","Execute" ]
HEADERS

Content-Type
application/json
Authorization
Bearer {{token}}
PATH VARIABLES

recType
io.microshare.test
BODY raw




Example Request
Create Rule by recType
PUT

Update Rule by recType and id

{{hostname}}/rule/:recType/:id

Modify a Rule by recType and Id, these changes are permanent.

Here are the details on the different body tags :

  • name : the name of your sharing rule
  • desc : (optional) add a description to this sharing rule
  • data :
    • resourceType : what are you looking to share ?
    • resourceId : are you looking to share only a specific resource so specify its id, otherwise leave "*"
    • ownerUser : put the email of the owner of the resource. Indeed it might be you, but if someone share you something with the "Policy" value you can share it from your account then.
    • ownerOrg : put the org of the owner of the resource.
    • ownerApp : put the owner AppKey, it's easier to leave "*"
    • callingUser, callingOrg, callingApp, callingRole, callingLoc : who should be able to get this resource ? leave as "*" for everyone, or specify at the right step (user/org/role ..) who should have access.
    • operations : which access do you give ?
      - Read : ability to simply read the resource
          - Query : ability to query the resource (through a view for instance)
          - Write : ability to modify the resource, or write a resource if it's an access to entire recType for instance
          - Delete : ability to delete the resource or part of it
          - Execute : ability to execute the resource (use a view for instance)
          - Policy : ability to share the resource again
          
      you can set many operations at once :
      • "operations":[ "Read", "Read","Execute" ]
HEADERS

Content-Type
application/json
Authorization
Bearer {{token}}
PATH VARIABLES

recType
io.microshare.test
id
5fab0544374c1e477994d78a
BODY raw




Example Request
Update Rule by recType and id
DEL

Delete Rules by recType and Id

{{hostname}}/rule/:recType/:id

Permanently delete a Rule by recType and Id.

HEADERS

Content-Type
application/json
Authorization
Bearer {{token}}
PATH VARIABLES

recType
io.microshare.test
id
5981f3c946e0fb00203b3796
BODY raw




Example Request
Delete Rules by recType and Id

Views

Create and manage Views directly from the API

GET

Get All Views

{{hostname}}/view/:recType?details=true&page=&perPage=

Get the list of all the views you owe and the views you have access to (shared).

HEADERS

Content-Type
application/json
Authorization
Bearer {{token}}
PARAMS

details
true
page
perPage
PATH VARIABLES

recType
io.microshare.fm.master.agg


Example Request
Get All Views
GET

Find Views by recType

{{hostname}}/view/:recType?details=true&page=&perPage=

Get the list of your Views by recType. Most of the Microshare Views are using the recType : io.microshare.fm.master.agg. Only few views are using an other recType for specific cases.

You will be able to see what you are sharing with who like if you were on the Microshare Composer.

HEADERS

Content-Type
application/json
Authorization
Bearer {{token}}
PARAMS

details
true
page
perPage
PATH VARIABLES

recType
io.microshare.fm.master.agg


Example Request
Find Views by recType
GET

Find Views by recType and Id

{{hostname}}/view/:recType/:id

Search a specific view by recType and Id.

HEADERS

Content-Type
application/json
Authorization
Bearer {{token}}
PARAMS

PATH VARIABLES

recType
io.microshare.fm.master.agg
id
5d37193746e0fb002a9cb09e


Example Request
Find Views by recType and Id
DEL

Delete View by Id

{{hostname}}/view/:recType/:id

Permanently delete a View by recType and Id.

HEADERS

Content-Type
application/json
Authorization
Bearer {{token}}
PATH VARIABLES

recType
io.microshare.test
id
5981f3c946e0fb00203b3796
BODY raw




Example Request
Delete View by Id

Robots

Create and manage Robots directly from the API

POST

Create a Robot

{{hostname}}/robo/:recType

Create a new Robot by recType. This creates a new Robot that automates the tasks associated with transforming, enriching, and annotating your data.

You must include a record type using the dot notation format (eg. io.microshare.test) this is the data source you are going to trigger.

HEADERS

Content-Type
application/json
Authorization
Bearer {{token}}
PATH VARIABLES

recType
io.microshare.test
BODY raw




Example Request
Create a Robot
GET

Get All Robots

{{hostname}}/robo/*?details=true&page=&perPage=1000

Retrieve all your Robots.

HEADERS

Authorization
Bearer {{token}}
PARAMS

details
true
page
perPage
1000


Example Request
Get All Robots
GET

Get Robots by recType

{{hostname}}/share/:recType?details=true&page=&perPage=1000

Retrieve all your Robots by recType/

HEADERS

Authorization
Bearer {{token}}
PARAMS

details
true
page
perPage
1000
PATH VARIABLES

recType


Example Request
Get Robots by recType
GET

Get Robot by recType and Id

{{hostname}}/robo/:recType/:id

Retrieve a specific Robot by recType and Id.

HEADERS

Content-Type
application/json
Authorization
Bearer {{token}}
PATH VARIABLES

recType
io.microshare.test
id
58fe78504d74e21f64ff511b


Example Request
Get Robot by recType and Id

Stream

Use the Microshare Streaming option to directly push your data to your big data tenancy

POST

Create one stream

{{hostname}}/stream/:recType

Create a new share by recType. This creates a new Streaming process into the Microshare data management.

You must include a record type using the dot notation format (eg. io.microshare.test).

HEADERS

Content-Type
application/json
Authorization
Bearer {{token}}
PATH VARIABLES

recType
io.microshare.test
BODY raw




Example Request
Create one stream
POST

Create one stream with Tags

{{hostname}}/stream/:recType/tags/:tag1/:tag2

Create a new Stream by recType, with searchable tags. This creates a new Streaming process into the Microshare data management.

You must include a record type using the dot notation format (eg. io.microshare.test).

Tags allow you to later search objects with the same recType with a GET request. You can specify as many tags as you need.

HEADERS

Content-Type
application/json
Authorization
Bearer {{token}}
PATH VARIABLES

recType
io.microshare.test
tag1
foo
tag2
bar
BODY raw


{
      "_id": "foobar",
      "name": "test",
      "desc": "test via api",
      "data": {
        "devices": [],
        "network": {},
        "meta": {}
      }
    }


Example Request
Create one stream with Tags
GET

Get one Stream

{{hostname}}/stream/:recType/:id

Retrieve one Stream by recType and object id

HEADERS

Authorization
Bearer {{token}}
PATH VARIABLES

recType
io.microshare.test
id
59238b9346e0fb0352c2948b


Example Request
Get one Stream
GET

Get Stream by recType

{{hostname}}/stream/:recType?details=true&page=&perPage=

Retrieve all Stream under a specific recType

Query parameters available
Parameter Type Description
details boolean true will return matching objects with their details, false will only return main information
page int Specifies the requested page, defaults to 1
perPage int Specifies the number of objects to be returned per page, defaults to 999
HEADERS

Authorization
Bearer {{token}}
PARAMS

details
true
page
perPage
PATH VARIABLES

recType
io.microshare.test


Example Request
Get Stream by recType
GET

Get Streams by Tags and recType

{{hostname}}/stream/:recType/tags/:tag1/:tag2?details=true&page=&perPage=

Retrieve all Streams under a specific recType and containing one or several tags. Specify as many tags as you need, and objects containing all of these tags will be returned.

Query parameters available
Parameter Type Description
details boolean true will return matching objects with their details, false will only return main information
page int Specifies the requested page, defaults to 1
perPage int Specifies the number of objects to be returned per page, defaults to 999
HEADERS

Authorization
Bearer {{token}}
PARAMS

details
true
page
perPage
PATH VARIABLES

recType
io.microshare.test
tag1
foo
tag2
bar


Example Request
Get Streams by Tags and recType
GET

Get Latest Device by recType

{{hostname}}/stream/:recType/tags/latest?details=true&page=&perPage=

Retrieve all Streams under a specific recType

Query parameters available
Parameter Type Description
details boolean true will return matching objects with their details, false will only return main information
page int Specifies the requested page, defaults to 1
perPage int Specifies the number of objects to be returned per page, defaults to 999
HEADERS

Authorization
Bearer {{token}}
PARAMS

details
true
page
perPage
PATH VARIABLES

recType
io.microshare.test


Example Request
Get Latest Device by recType
DEL

Delete one Stream

{{hostname}}/stream/:recType/:id

Permanently delete one Stream by recType and object id

HEADERS

Authorization
Bearer {{token}}
PATH VARIABLES

recType
io.microshare.test
id
5f9c9d6f3343a13b005fadab


Example Request
Delete one Stream
PUT

Update one Stream

{{hostname}}/stream/:recType/:id

Permanently delete one Stream by recType and object id

HEADERS

Authorization
Bearer {{token}}
PATH VARIABLES

recType
io.microshare.test
id
5f9c9d6f3343a13b005fadab
BODY raw




Example Request
Update one Stream