An API for IoTanic apps Development server: https://iotanic-api.herokuapp.com/
User signup
POST /api/signUp
Body | Type | Description |
---|---|---|
email |
string |
Required. User email |
password |
string |
Required. User password |
TRUE : {
status: 200,
values: 'Success creating account'
}
FALSE: {
status: 200,
values: 'Account is already registered'
}
ERROR: {
status: 400,
values: 'Failed to create an account!'
}
User signin
POST /api/signin
Body | Type | Description |
---|---|---|
email |
string |
Required. User email |
password |
string |
Required. User password |
TRUE : {
status: 200,
values: {
account: {
_id: ObjectID(),
name: Sring,
age: Int32,
account: ObjectID()
},
msg: 'Success signin'
}
}
FALSE: {
status: 200,
values: {
account: null
}
}
ERROR: {
status: 400,
values: `Error getting user's profile`
}
Get all accounts
GET /api/account
Parameter | Type | Description |
---|---|---|
- |
- |
- |
TRUE : {
status: 200,
values: {
accounts: {
_id: ObjectID(),
email: Sring,
password: String,
created_date: Date()
account: ObjectID()
}
}
}
ERROR: {
status: 400,
values: {
accounts: null,
msg: `Error getting all accounts`
}
}
Get profile based on user's account
GET /api/profile/:id
Parameter | Type | Description |
---|---|---|
id |
String |
Required Need user's account _id |
TRUE : {
status: 200,
values: {
profile: {
_id: ObjectID(),
name: Sring,
age: Int32,
account: ObjectID()
},
msg: 'Success retrieving profile by Account ID: ID'
}
}
ERROR: {
status: 400,
values: {
profile: null,
msg: `Could not retrieve profile by Account ID: ID`
}
}
Update the user's profile
POST /api/profile
Body | Type | Description |
---|---|---|
id |
String |
Required to check the _id of the profile |
name |
String |
To update the profile's name |
age |
Int |
To udpate the profile's age |
TRUE : {
status: 200,
values: `Success updating user profile with ID: ID`
}
ERROR : {
status: 400,
values: `Failed to update the user profile with ID: ID`
}
Create a template for device. Used by the developers. Use this when you need a new device id
GET /api/device/create
Parameter | Type | Description |
---|---|---|
- |
- |
Initiated with default value |
TRUE : {
status: 200,
values: {
DeviceID: String,
msg: 'Success creating new device'
}
}
ERROR: {
status: 400,
values: {
DeviceID: null,
msg: `Failed creating new device`
}
}
When user going to add a new device. After input the device id, we need to verify wheter the device is already used or not.
POST /api/device/check
Body | Type | Description |
---|---|---|
device |
String |
Required to check the device |
TRUE : {
status: 200,
values: {
available: true,
msg: `Device doesn't have a user, user can register!`
}
}
FALSE: {
status: 200,
values: {
available: false,
msg: `Device already has the user with ID`
}
}
ERROR: {
status: 400,
values: {
available: null,
msg: `Error checking the device`
}
}
When user going to add a new device. After checking the availability, if its available, user can set the device
POST /api/device/set
Body | Type | Description |
---|---|---|
device |
String |
Required device _id |
name |
String |
Required device name |
profile |
String |
Required device profile _id |
TRUE : {
status: 200,
values: `Success updating device's user`
}
ERROR: {
status: 400,
values: `Failed updating device's user`
}
Get user's devices based on profile _id
POST /api/device/
Body | Type | Description |
---|---|---|
profile |
String |
Required profile _id |
TRUE : {
status: 200,
values: {
devices: {
_id: ObjectID(),
name: String,
user: ObjectID(),
records: Array
}
}
}
ERROR: {
status: 400,
values: `Failed getting user's device`
}
Saving records from the device to databse
GET /api/records/:id/:n/:p/:k/:ph
Parameter | Type | Description |
---|---|---|
id |
String |
Required device _id |
n |
Int32 |
Required value of n |
p |
Int32 |
Required value of p |
k |
Int32 |
Required value of k |
ph |
Int32 |
Required value of ph |
TRUE : {
status: 200,
values: {
record: {
n: Int32,
p: Int32,
k: Int32,
ph: Int32,
datetime: Date
},
msg: `Success saving records of ID: ID`
}
}
ERROR: {
status: 400,
values: {
record: null,
msg: `Error saving records to ID: ID`
}
}