Will this microcontroller example work without using username/apikey?

I’m trying to run this non-arduino/non-nodejs example:

I’ve created a plot.ly account, but unlike the plotly examples here, it looks like they just open a socket and then start streaming packets to it… I don’t see anywhere where I should transmit my username/apikey. Does this example use an obsolete API?

SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
// unsigned char PLOTLY[] = 	 "POST /clientresp HTTP/1.1\r\nHost:\r\nUser-Agent: MSP430F5529/0.5.1\r\nContent-Length: 261\r\n\r\nversion=2.2&origin=plot&platform=Stellaris&un=Kas&key=123456789k&args=[{\"y\": [], \"x\": [], \"type\": \"scatter\", \"stream\": {\"token\": \"ABCDEFGHI\", \"maxpoints\": 7200}}]&kwargs={\"fileopt\": \"overwrite\", \"filename\": \"Element14 Temperature Plot\", \"world_readable\": true}\r\n";
// unsigned char initPlotly[] = "POST /clientresp HTTP/1.1\r\nHost:\r\nUser-Agent: MSP430F5529/0.5.1\r\nContent-Length: 243\r\n\r\n";
// unsigned char initStream[] = "version=2.2&origin=plot&platform=Stellaris&un=Kas&key=123456789&args=[{\"y\": [], \"x\": [], \"type\": \"scatter\", \"stream\": {\"token\": \"ABCDEFGHI\", \"maxpoints\": 500}}]&kwargs={\"fileopt\": \"overwrite\", \"filename\": \"test plot\", \"world_readable\": true}\r\n\r\n\r\n\r\n\r\n";
unsigned char openStream[] = "POST / HTTP/1.1\r\nHost: stream.plot.ly\r\nUser-Agent: Python\r\nTransfer-Encoding: chunked\r\nConnection: keep-alive\r\nplotly-streamtoken: ABCDEFGHI\r\n\r\n";
packetTx(socketIDD, openStream, (sizeof(openStream) - 1), 0);

What would I need to change to make it work with the current PlotLy API? Are there any examples that have a similar setup (i.e. don’t use linux/node-js)?


Hey @chrisg

You’re right, the socket connection doesn’t require an API key, just a streaming token. However, before you make a socket connection, you’ll need to make an empty graph with the token embedded inside it. Creating this empty graph is just a POST to /clientresp, and that requires a username and API key.

Learn more about streaming in our docs here: https://plot.ly/streaming/