====== Air Lay API v2 ====== ==== Navigation ==== * [[en:first|Main page]] * [[en:api|AirLay API]] * [[en:api:air-lay|API Air Lay]] ---- **Структура запроса** /** * api/v2/{controller}/{action}?{parameter1=value¶meter1=value&...} * Где * controller - контролер в котором производится действие, * action - действие контроллера, * parameter1, parameter2 ... - параметры запроса, * value1, value2 ... - значение параметров */ /** * GET * Вход пользователя через name и password * @return JWT */ /user/auth /** *GET * Регистрация пользователя необходимые параметры * string name * string password * string email в формате example@mail ~ */ /user/registration /** * GET * Action for get menu * @return object free trees and private trees */ /user/getmenu /** * POST * Action for create tree. You can see JSON object descriptions below for more details. * @name string Name tree * @return object tree mongoDB object */ /node/createtree /** * GET * Get layer objects by parameters. * @id layer id * Coordinates * @lat1 * @lat2 * @lon1 * @lon1 * @return object tree mongoDB object */ /api/v2/node/getObjs /** * POST * Action get layer objects info * @collections json * {"collections" : [ * { * "name" : "layersId", * "layers" : [objectId, objectId, ...] * }, * ... * ]} * @return json */ /api/v2/node/getObjsInfo /** * Action for create Node(layerEntity/dir). You can see JSON object descriptions below for more details. * @name string Node name * @type string type of the node. Values : layerEntity/dir * @treeId ObjectId the id of the tree in which the node is inserted * @parentId ObjectId parent of the node * @order order in the parent's childs. default -1 * @return array ['node'=> nodeInfo] */ /api/v2/node/createNode /** * Action for upload objects. * @layerId object Layer Id * @_FILES['json'] file with the geojson feature collection * @return string 200 Ok */ /api/v2/uploadLayer /** * Action for download layer objects. * @layerId objectId Layer Id * @format string file format json/kml/dxf * @filename string file name * @return 200 Ok json/kml/dxf file */ /api/v2/node/downloadLayer /** * Action for changing node name. * @treeId string ObjectId * @nodeId string ObjectId * @name string node name * @return string 200 Ok */ /api/v2/node/updateNodeName /** * Action for changing node parent or order. * @treeId string ObjectId * @nodeId string ObjectId * @newParentId string ObjectId * @order string order number of node in new parent * @return string 200 Ok */ /api/v2/node/moveNode /** * Action for removing node. * @treeId object Layer Id * @nodeId object Layer Id * @return string 200 Ok */ /api/v2/node/removeNode /** * Search tree by name * @name string tree name * @return 200 Ok json tree */ /api/v2/node/searchTreeByName /** * Get srtm * @lat * @lon */ /api/v2/user/srtm /** * Action ensure layer db index. * @layerId * @indexName */ /api/v2/node/ensureLayerIndex /** * Action delete layer db index. * @layerId * @indexName */ /api/v2/node/deleteIndex /** * GET * @id layer id * @return josn layer option */ /api/v2/node/getLayerOptions /** * POST * @id layer id * @options json options * @return 200 Ok */ /api/v2/node/updateLayerOptions /** * POST * Action for group creation * @name group name * @return json group */ /api/v2/group/create /** * POST * Action update group name * @id ObjectId group id * @name string new group name * @return 200 Ok */ /api/v2/group/updateName /** * Action adds a tree to the group. * @treeId ObjectId tree which to add * @groupId ObjectId group where to add * @return string 200 Ok */ /api/v2/group/addTree /** * Action remove tree from group. * @treeId ObjectId tree which to remove * @groupId ObjectId group where to remove * @return string 200 Ok */ /api/v2/group/removeTree /** * Action return user groups. * @return string 200 Ok */ /api/v2/group/get /** * Action for adding user to group. * @userId string ObjectId. * @groupId string ObjectId. * @return string 200 Ok */ /api/v2/group/addUser /** * Action set user/tree permissions for group * @id string ObjectId * @groupId string ObjectId * @permissions string group_mask * @entityName string 'trees'/'users' * @return string 200 Ok */ /api/v2/group/setPermissions /** * Action for deleting user from group. * @userId string ObjectId. * @groupId string ObjectId. * @return string 200 Ok */ /api/v2/group/deleteUser /** * POST * Action remove group * @id group id * @return 200 OK */ /api/v2/group/remove /** * POST * Action for product creation. * @title string group name **necessarily** * @type string **necessarily** * @treetIds/@file json array ObjectId of entities which is trees or file with product in zip format **necessarily** * @groupId if owner of the group * @description string product description * @shortDescription string product short description * @access int interaction_mask * @icon string base64 icon * @cost int product cost, default 0, not used at the moment. * @translation string json product translations, example {"ru":{"title":"Заголовок", "description": "описание на русском", ...}, "en":{...}} * @return string 200 Ok */ /api/v2/purchase/createProduct /** * GET * Action for get product information. * @productId string ObjectId of entity which is product * @return string 200 product information */ /api/v2/purchase/getProduct /** * GET * Action return all available product, excluding users products. * Filters: * @access int interaction_mask, /in development * @type string (tree/map), /in development * @point json {"lon":86.696379, "lat":54.153597} /in development * @return string 200 products */ /api/v2/purchase/getProducts /** * GET * Action for purchase product * @productId string ObjectId of entity which is product * @return string 200 OK */ /api/v2/purchase/purchaseProduct /** * POST * Action for product update. * @productId string ObjectId of entity which is product **necessarily** * @title string product name * @treeIds json array ObjectId trees * @file file in zip format * @description string product description * @shortDescription string product short description * @access int interaction_mask * @icon string base64 icon * @cost map string - double. * @translation string json product translations, example {"ru":{"title":"Заголовок", "description": "описание на русском", ...}, "en":{...}} * @return string 200 Ok */ /api/v2/purchase/updateProduct /** * GET * Action for product remove from user or from bd if user is owner. * @productId string ObjectId of entity which is product * @return string 200 Ok */ /api/v2/purchase/removeProduct /** * GET * Action for product get version. * @productId string ObjectId of entity which is product * @return string 200 product version */ /api/v2/purchase/getProductVersion /** * Action for get user products * return string 200 user products */ /api/v2/purchase/getUserProducts /** * GET * @text string feedback text * @productId ObjectId product id * @return string 200 Ok */ public function postFeedbackAction() /** * GET * @productId ObjectId product id * @return array 200 product feedback */ public function getProductFeedbackAction() /** * GET * Action for get product file * @productId ObjectId product id * @return product file */ public function getProductFileAction() /** * Action set sidebar text pattern. * @layerId string ObjectId * @pattern string sidebar text pattern * @return string 200 Ok */ /api/v2/node/setSideBar /** * Action get sidebar text pattern. * @layerId string ObjectId * @return string 200 Ok */ /api/v2/user/getSideBar /** * Action find user by name. * @name string userName regexp. * if name =='' return all users, else search by regexp * @return string 200 [userId,name] */ /api/v2/user/findUsersByNames /** * Action find tree by name. * @name string treeName regexp. * @return string 200 [treeId,name] */ /api/v2/node/searchTreeByName /** * POST * Action create layers object * @layerId ObjectId layers id * @treeId ObjectId tree Id * @geometry string geo json geometry * @properties string json properties * @return 200 new objectId */ /api/v2/node/createObject /** * POST * Action update layers object * @objectId ObjectId layer object id * @layerId ObjectId layer id * @treeId ObjectId tree Id * @objectId ObjectId layer object id * @geometry geojson geometry * @properties json properties * @return 200 Ok */ /api/v2/node/updateObject /** * POST * Action remove layers object * @treeId ObjectId tree id * @layerId ObjectId layer id * @objectId ObjectId layer object id * @return 200 Ok */ /api/v2/node/removeObject /** * POST * Action change the layer for a layer object * @layerId objectId layers id * @newLayerId objectId new layers id * @treeId ObjectId tree id * @objectId ObjectId layer object id * @return 200 Ok */ /api/v2/node/changeLayerObject /** * Action activate users devices. * @request string * * @providerId string * * @receipt string for iOs devices. * @web int if from webbrowser * @os string devices OS * @purchaseId string purchaseToken or pincode * @return 200 Ok */ /api/v2/purchase/activate /** * POST * Action confirm paid products * @productId objectId product id * @purchaseName string purchases name * @return 200 Ok */ /api/v2/purchase/productPayConfirm /** * GET * Action get unconfirmed paid products * @return 200 Ok json */ /api/v2/purchase/getUnconfirmedPaidProduct /** * GET * Action get help objects * @return 200 Ok json help objects */ /api/v2/help/get /** * POST * Action add help object * @help json help object * @file file help media file * @return 200 Ok */ /api/v2/help/add /** * POST * Action update the help object * @helpObjectId objectId help object id * @help json help object * @file file help media file * @return 200 Ok */ /api/v2/help/update /** * POST * Action remove help object * @helpObjectId objectId help object id * @return 200 Ok */ /api/v2/help/remove /** * Rebuild user menu */ /api/v2/user/rebuildUserMenu /** * Upload track * @file gpx format */ /api/v2/node/uploadTrack /** * GET * Get user search */ /api/v2/user/getUserSearch /** * GET * Get user search */ /api/v2/user/getUserSearch /** * GET * Action get url * @url string needed url * @return 200 string url */ /api/v2/url/get /** * Action get tracker * @token QR token or auth token * @id tracker id * @return 200 array trackers */ /api/v2/tracker/get /** * Action create tracker * @tracker raw json data * @return 200 json tracker object */ /api/v2/tracker/create /** * Action update tracker * @tracker raw json data(id necessary) * @return 200 OK */ /api/v2/tracker/update /** * Action delete tracker * @id tracker id * @return 200 OK */ /api/v2/tracker/delete /** * POST * Action connect device to tracker * @token auth device token * @trackerId tracker id * @return 200 array trackers */ /api/v2/tracker/connect /** * POST * Action send data to tracker module * @token JWT auth device token * @type string type object (location/object) * @body json object * @schemeId scheme id(if type object) * @return 200 array trackers */ /api/v2/tracker/send /** * POST * Action get temp QR token * @trackerId/@layerId ObjectId tracker id/layer id * @return 200 Ok token */ /api/v2/QR/get /** * POST * Action get token for access to tracker module * @token temp QR token or auth token * @deviceId device id * @trackerId tracker module id for auth token * @return 200 Ok or errors array */ /api/v2/QR/auth /** * POST * Action get token with layer id * @layerId objectId layers id * @return 200 string JWT */ api/v2/node/getSubscriptionToken /** * POST * Action create scheme * Raw json data * @return 200 Ok json scheme object */ api/v2/scheme/create /** * GET * Action get scheme by id * @id ObjectId scheme id * @layerId ObjectId layer id(tracker id) * @type string scheme type (Verification, Collector, Tracker, Command) * @return 200 Ok json scheme object */ api/v2/scheme/get /** * POST * Action update scheme * Raw json data (necessarily "_id") * @return 200 Ok */ api/v2/scheme/update /** * POST * Action delete scheme by id * @id scheme id * @return 200 Ok */ api/v2/scheme/delete /** * POST * Action verification object * @schemeId ObjectId scheme id * @objectId ObjectId object id * @return 200 Ok or errors array * Error codes: * 1: Fields not found * 2: Empty value * 3: Invalid type. Value must be string/int/bool * 4: Invalid value, must be one of the list [...] */ api/v2/scheme/verification /** * GET * Get upload logs * @layerId ObjectId layer id * @return 200 OK log urls */ /api/v2/user/getUploadLogs /** * GET * Action for get user organization. * @return string json object organization */ /api/v2/organization/get /** * POST * Action for update organization info. * @name new organization name * @return 200 OK */ /api/v2/organization/update /** * GET * Action for get portal. * @return 200 json object all connection portals */ /api/v2/portal/get /** * POST * Action for create portal. * @name string portal name * @settings json portal settings * @productId array portal products * @open string 'true'/'false' * @private string 'true'/'false' * @groups array portal groups * @helps array portal helps * @return object tree mongoDB object */ /api/v2/portal/create /** * POST * Action for delete portal. * @id string portal id, if id is empty remove all portals * @return 200 OK */ /api/v2/portal/remove /** * POST * Action for delete all organization portals. And create default portal. * @return 200 OK */ /api/v2/portal/removeAll /** * POST * Action for update portal. * @id portal id * @name string portal name * @settings array portal settings * @productId array portal products * @open string 'true'/'false' or int 1/0 * @private string 'true'/'false' or int 1/0 * @groups array portal groups * @helps array portal helps * @return object tree mongoDB object */ /api/v2/portal/update **Tree** { _id: ObjectID; "properties": { "type": "tree", "name": string, "ownerId": ObjectID, "shared": "free"/"private", }, "children": []/null; } **Directory** { _id: ObjectID; "properties": { "type": "dir"; "name": string; }, "children": []/null; } **Layer** { "properties": { "type": "layer", "api": string, "alias": ObjectID }, "children": []/null } **Layer Entity** { _id: ObjectID; "properties": { "type": "layerEntity", "name": string, "index": [], "api": string/null }, "children": []/null, "options": [standartLayerOptions] } **Map** { _id: ObjectID; properties: { type: "map"; typeMap: "osm"/"2gis"/"mapbox"/"yandex"/"google", name: string; url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", urlCache: "http://cache.mrgis02.mrsks.local/osm/{z}/{x}/{y}.png", options: { maxZoom: 18 }, checked: 1, cache: 0, } } **overlayLayer** { "properties": { "type": "overlayLayer", "name": "Зоны с особыми условиями использования территории", "url": "//pkk5.rosreestr.ru/arcgis/rest/services/Cadastre/ZONES/MapServer/export?", "options": { "format": "image/png", "transparent": "true", "tileSize": 256, "zIndex": 100, "shiftX": 0, "shiftY": 0, "maxZoom": 18 }, "checked": false } } **Tokens** Response header // Access open Authorization: 0; // Expired token Authorization: 1; // Access denied Authorization: 2; // Some error Authorization: 3; // Refresh Token refresh_token : some_token; // Access Token access_token : some_token; **Users** { _id: ObjectID, name: string, email: string, password: bcrypt, time: time, groups: [ groupId(ObjectID), groupId(ObjectID) ], products: [ productId(ObjectID), productId(ObjectID) ] } **Interaction mask (interaction_mask)** // 0 uses for invisible groups or products. Users can get access from owner invite only. 0 - invite // Users can sent invite to owner groups or products. 1 - private // Users can join to group without limitations. 2 - public // Users can buy product. 3 - buy // Users can get product, if they have premium account. 4 - premium **Mask of access for groups (group_mask)** // Mask of access to group/product. Can take 3 values 1 - read, 2 - write, 4- access. // For groups Read allows to see group members, write allows to add group members, access allows do delete and configure group. // For example // User doesn't have access to group/product. 0 //user has access to group/product. 4 **Groups** { _id: ObjectID, name: string access: interaction_mask, users: [ { userId: ObjectID, mask: group_mask } ], tree: [ { treeId: ObjectID, mask: group_mask } ], } **Products** { _id: ObjectID, owner: { userId/groupId : ObjectID }, treeIds[]/file: ObjectID/filepath, type: string(tree/map), access: interaction_mask, title: string, description: text, shortDescription: text, shortDescription: text, icon: icon, cost: [ string(ISO 3166-1 alpha-3) : double, ... ], users: [ ObjectID ], purchaseId : string } **Translations** { "_id" : ObjectId, "language" : string, "code" : string, "phrases" : { "phrases" : "phrases translate", ... } } **Orders** { "_id" : ObjectId, "userId" : ObjectId, "providerId" : ObjectId, "productId" : ObjectId/string, "softExpire" : int, "hardExpire" : int, "cost" : float, "date" : Date, "activation" : { "token" : string, "activated" : boolean, "activatedDate" : Date, "deviceId" : string, "serialNumber" : stirng, "expired" : boolean } } **Helps** { title : string, order : int, text: string, url: string, type: string("Video"/"Image") } **Device** { "_id" : ObjectId, "properties" : { "deviceId" : string, "trackers" : [ { "trackerId" : ObjectId, "status" : 0/1 } ] }, "geometry" : { "type" : "Point", "coordinates" : [ double, double ] } } **Scheme** { "_id" : ObjectId, "type" : string Tracker/Verification/Collector/Command, "import" : ObjectId, "export" : ObjectId, "name" : string, "owner" : ObjectId, "icon": string base64 svg\png, "geometryType": string Point/Line/Polygon, "api": string(API, для приложения, на него идёт отправка данных), /* Не обязательное поле fields */ "fields": array [ 0: { "name": string, "placeholder": string, "type": string(string, int, bool, list, check box, media) /* Для типов list, check box обязательное поле list */ "list" : array[ String...] } } **Trackers** { "_id" : ObjectId, "owner" : ObjectId, "name" : string, "OpenAPI" : bool, "QR" : bool, "Auth" : array[ ObjectId, ... ] } **Tracks** { "_id" : ObjectId, "deviceId" : string, "lon" : double, "lat" : double, "time" : ISODate } **Tracks body /api/v2/tracker/send** { "deviceId" : string, "lon" : double, "lat" : double } **Upload file log** { "_id" : ObjectId, "time" : ISODate, "userId" : ObjectId, "logFile" : string, "status" : string upload/progress/success/error, "layerId" : ObjectId } **Organization** { _id: ObjectId, name: string organization name ownerId: Objectid user id, portals: [] ObjectId portals } **Portal** { _id: ObjectId, name: string portal name, url: string portal url, setting: {}, organizationId: ObjectId organization id productId: [], searchId: [], open: bool, private: bool, groups: [], helps: [] } **PortalConnection ** { userId: ObjectId, portalId: ObjectId, access: bool }