Rainmaker dashboart rest API

ondro1234
Posts: 3
Joined: Thu Aug 01, 2024 12:00 pm

Rainmaker dashboart rest API

Postby ondro1234 » Thu Aug 01, 2024 12:32 pm

Hello,

I tried to use rainmaker REST API in Swagger (https://swaggerapis.rainmaker.espressif.com/) for communication with dashboard but it seems that it doesn't exist. I tried to launch the following command but I received html code which is exactly the same as I obtained from a web browser when I login to http://dashboard.rainmaker.espressif.com page.

Code: Select all

curl -X 'POST'   'http://dashboard.rainmaker.espressif.com/v1/login2'   -H 'accept: application/json'   -H 'Content-Type: application/json'   -d '{
  "user_name": "user@server.domain",
  "password": "*********"
}' 
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"/><link rel="preconnect" href="https://fonts.gstatic.com"/><link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,300;0,400;0,500;1,700&display=swap" rel="stylesheet"/><link href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&display=swap" rel="stylesheet"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="shortcut icon" href="../favicon.ico"/><link rel="”manifest”" href="”/manifest.json”"><title>ESP RainMaker Dashboard</title><link href="/static/css/2.bca2624e.chunk.css" rel="stylesheet"><link href="/static/css/main.ae86e2c1.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><div id="modal-root"></div><script src="/config.js"></script><script>!function(e){function r(r){for(var n,a,l=r[0],f=r[1],i=r[2],c=0,s=[];c<l.length;c++)a=l[c],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&s.push(o[a][0]),o[a]=0;for(n in f)Object.prototype.hasOwnProperty.call(f,n)&&(e[n]=f[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,i||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var f=t[l];0!==o[f]&&(n=!1)}n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={1:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,function(r){return e[r]}.bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="/";var l=this.webpackJsonpdashboard=this.webpackJsonpdashboard||[],f=l.push.bind(l);l.push=r,l=l.slice();for(var i=0;i<l.length;i++)r(l[i]);var p=f;t()}([])</script><script src="/static/js/2.a7519adc.chunk.js"></script><scripcurl -X 'POST'   'http://dashboard.rainmaker.espressif.com'/html>
I used URL http://dashboard.rainmaker.espressif.com according to this topic(https://esp32.com/viewtopic.php?t=27436). It seems that REST API worked well in the previous year. Now, it doesn't. Is it a bug or an intention?
Maybe I used the wrong URL but the original URL (https://api.rainmaker.espressif.com) from Swagger seems to be intended for the private rainmaker and there I had a problem with unauthorized operations.

BR,
Ondro
Last edited by ondro1234 on Mon Aug 05, 2024 1:34 pm, edited 1 time in total.

ESP_Piyush
Posts: 307
Joined: Wed Feb 20, 2019 7:02 am

Re: Rainmaker dashboart rest API

Postby ESP_Piyush » Fri Aug 02, 2024 3:19 am

The dashboard (https://dashboard.rainmaker.espressif.com/) is a web front-end for ESP RainMaker whereas https://api.rainmaker.espressif.com is the API end point. If you want to try APIs directly (from swagger or postman or curl), you should use the API endpoint. All authenticated APIs will require the access token (returned in login2 API) to be passed.

Meanwhile, most functionality is already exposed in phone apps or the web dashboard. What exactly is your use case here, requiring direct API access?

ondro1234
Posts: 3
Joined: Thu Aug 01, 2024 12:00 pm

Re: Rainmaker dashboart rest API

Postby ondro1234 » Fri Aug 02, 2024 8:04 am

Thank you for the fast reply. I had tried to log in without password because I used google account and there was a problem. I used verification code as access token which was a bad idea. Now I've tried again and it works correctly. If anybody is confused like me, here a short example:

Code: Select all

$ curl -X 'POST'   'https://api.rainmaker.espressif.com/v1/login2'   -H 'accept: application/json'   -H 'Content-Type: application/json'   -d '{
  "user_name": "user@gmail.com" 
}'
{"status":"success","description":"Login request successful. Verification code sent. Please check phone or email","session":"AYABeLfMtNPTXo2XUp80..."}

$ curl -X 'POST'   'https://api.rainmaker.espressif.com/v1/login2'   -H 'accept: application/json'   -H 'Content-Type: application/json'   -d '{
  "user_name": "user@gmail.com",
  "verification_code": "766260",
  "session": "AYABeLfMtNPTXo2XUp80..." }'
{"status":"success","description":"Login successful",
"idtoken":"eyJraWQiOiIrQVwvTW5yc0JXOHhkXC..."
,"accesstoken":"eyJraWQiOiJxK0Y2Nkk1eE1nOWo2..."
,"refreshtoken":"eyJjdHkiOiJKV1QiLCJlbmMiOiJBMj..."
}

$ curl -X 'GET'   'https://api.rainmaker.espressif.com/v1/user/nodes?node_details=true&status=true&config=true&params=true&show_tags=true&is_matter=false'   -H 'accept: application/json'   
-H 'Authorization: eyJraWQiOiJxK0Y2Nkk1eE1nOWo2...'
{"nodes":["58CF79E3B8B4"],"node_details":[...],"total":1}
The verification code is from an email response.

And here is a login to a different account but with a password:

Code: Select all

$ curl -X 'POST'   'https://api.rainmaker.espressif.com/v1/login2'   -H 'accept: application/json'   -H 'Content-Type: application/json'   -d '{
  "user_name": "user@server.domain",
  "password": "*********"
}'
{"status":"success","description":"Login successful"
,"idtoken":"eyJraWQiOiIrQVwvTW5yc..."
,"accesstoken":"eyJraWQiOiJxK0Y2Nk..."
,"refreshtoken":"eyJjdHkiOiJKV1QiL..."
}

$ curl -X 'GET'   'https://api.rainmaker.espressif.com/v1/user/nodes?node_details=true&status=true&config=true&params=true&show_tags=true&is_matter=true'   -H 'accept: application/json'   
-H 'Authorization: eyJraWQiOiJxK0Y2Nk...'
{"nodes":[]}

To your question...
I've played with Python Rainmaker CLI, but it seems to be a bit obsolete. I wanted something up to date. Dashboard looks up to date but it is not very user friendly.

ESP_Piyush
Posts: 307
Joined: Wed Feb 20, 2019 7:02 am

Re: Rainmaker dashboart rest API

Postby ESP_Piyush » Mon Aug 05, 2024 6:18 am

The python CLI is for claiming and end user operations whereas the dashboard is for admin operations, meaning that their feature sets would mostly be mutually exclusive. So, the requirement is still not clear. If you can elaborate with specific points, we can check what can be added/improved.

ondro1234
Posts: 3
Joined: Thu Aug 01, 2024 12:00 pm

Re: Rainmaker dashboart rest API

Postby ondro1234 » Mon Aug 05, 2024 1:44 pm

My goal was to create an app which can login, logout, get an info about devices/nodes, get/set their parameters and maybe to launch OTA.

I started to read a documentation from here: https://rainmaker.espressif.com/docs/api/ and REST APIs, Python APIs, Phone Apps looked almost the same.

Who is online

Users browsing this forum: No registered users and 6 guests