Data logging
API points
There are two API end-points available:
https://api.2minlog.com/log
- preferredhttps://api1.2minlog.com/log
- backup with different sets of TLS/SSL certificates/ciphers available. Suitable for some IoT devices which cannot access the standard set.- Port 443
HTTPS
only. We do not supportHTTP
.- You can use both GET and POST types of HTTP operations. The system does not distinguish between the two types.
- Successful attempt returns HTTP code 200 and message “OK”.
- Maximum rate is 1 message per minute.
Format & payload
- All values as text. You are responsible for the conversion from string to numbers as needed in Graph Python code.
- It prevents unintended or wrong conversions. You need to convert it by yourself, as, e.g.,
df = df['temperature'].astype(float)
.
- It prevents unintended or wrong conversions. You need to convert it by yourself, as, e.g.,
- There are two basic options for how to log data. You can combine both options.
Option 1
- The request URL can contain the payload’s Dataset Secret and key/value pair.
- It is the simplest solution.
- Example saving
key1=value1
andkey2=value2
ishttps://api.2minlog.com/log?datasetSecret=SEC-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&key1=value1&key2=value2
Option 2
- HTTP basic authorization
- Username: 2minlog
- Passwd the Secret of Data set - in form of
SEC-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- JSON payload is flattened
Examples
We’ve set up a project already for you to be able to test:
- Secret code: SEC-d811574a-b61e-4844-b61b-e06da34c6ef7
- Public code: PUB-5ae1e592-7bfc-417c-b14a-169d22f48d49
Example 1 - parameters in URL:
curl "https://api.2minlog.com/log?datasetSecret=SEC-d811574a-b61e-4844-b61b-e06da34c6ef7&temperature=451&humidity=80"
Example 2 - parameters in request payload:
curl -X POST --user "2minlog:SEC-d811574a-b61e-4844-b61b-e06da34c6ef7" https://api.2minlog.com/log -d "{\"temperature\":\"451\", \"humidity\":\"80\"}"
(Both examples works in Windows command and Linux system.) You should see answer “OK” in both cases. Next, let’s retrieve the data. Download the csv here: https://api.2minlog.com/img?filenameExtension=csv&datasetPublic=PUB-5ae1e592-7bfc-417c-b14a-169d22f48d49. It is a public Dataset, and anybody (including, e.g., web crawlers) may send and get the data. But you should be able to see what you sent with the current UTC timestamp.