Getting Started with the API

Need a boost on using the API?

So, I thought i would post what i’ve learned while using Blynk.
At the time of this writing, im a Blynk beginner and like figuring stuff out for myself, with a little help along the way.

If you’ve never used an api before, think of it as a way other applications can communicate to your application (Blynk in this case).
Usually there are so many ways to do it, using different library’s for different scripting languages, its hard for everyone to know how to use them all.

In this case, we have an http interface, so you’re browser can do most of the work.
In some cases, you’ll have to use another method to do post/puts, curl it generally supported rather well. Curl is generally a unix command , but i’ve had it on windows as well.

Start by having your project up and online and get one of the easily readable pin identifiers ready to go.
My simple project uses my raspberry pi and a relay to turn on my fireplace.
Im going to use Digital pin 4, or d4. A gpio pin should be converted to the digital number.

You should already know your auth code, Im gonna call mine XXXYYYZZZ from now on out.

Make sure you are using your local server if you have one, or the blynk-cloud if you’re using that. Note the port difference from my local server

The format for the calls are

http :// <server><port if not 80> / <authcode> / <query>

Once you figure out the server/port and auth code, the queries are the only things you’ll need to modify.


Lets find out if your hardware is connected.

Its shows true in the browser window… that means my pi (or your hardware) is up and ready to go.
Note : false would mean you’re hardware is offline.


Are there any application clients listening to the data? Is my phone running the application?
I share the app with my wife, the assumption is that if one or both of us were connected, it would show true.

false? No apps are listening.


Blynk keeps your project on the server in txt format under your user id. When you use the project query, it gives you all the info on your project build, buttons, boards, pins, colors, options, etc.

It might be confusing to look at, but you will most likely recognize alot of your user interface in there.


Generate your project QR code


Get the value of your pin, remember i was using d4, you’ll have to edit this part.
Note: remember that pins that are on or off will show a 1 for on, 0 for off.
You may encounter some “true / false” as you go along, so consider checking the value format before going too far.

using curl as another example. Notice the Virtual Pin as well.

unix# curl http://mylocal.blynk.server:8080/XXXYYYZZZ/get/v1

write (using get)

Change the value of a pin

Turn my fireplace ON

Turn my fireplace OFF

To update a table
Note: this is way beyond an API FAQ writeup, but hey, its out there.
Borrowed from Dmitriy’s (and @rockmanqh’s) post here

instead of Blynk.virtualWrite(V1, “add”, rowIndex, “My Event”, “My Value”);
you can use

write (using put)

I used curl to send the data, but you could find your own method

Turn On my fireplace
unix# curl -X PUT -H "Content-Type: application/json" -d '["1"]'

Turn Off my fireplace
unix# curl -X PUT -H "Content-Type: application/json" -d '["0"]'

Map updates
Note: Again, way beyond an API’s FAQ.
Map location borrowed from @eugene

curl -v -L --include \
 --request PUT `\
 --header "Content-Type: application/json"  \
 --data-binary "[\"1\", \"52.2949\", \"-4.8610\", \"Test\"]"  \ 

Widget Properties

Right now, might be a good time to go back to the /project command and see what options you could change on your widgets. I had poor luck changing anything except the label and the pin value.

Here is my personal example.

This updated the app right away and worked pretty good.
I tried others like the font size


They didnt seem to work

I tried changing it to a pushbutton instead of a switch


That didnt work either.
try your own from the items in /project, you might find more that work.
You might be able to tell im getting tired at this point as im giving up early.

Edit !!
In the end, i was able to make this work
the %23 is a character symbol for the pound(#) in the html color code. Still more experimenting needed.


So, make sure you have a notify object in your app, then you can use curl to post data the notify api
Some browsers have posting abilities, i didnt mess around with it.
In the command below, the \ (slash) at the end of each line tells unix that the command is too long to be on one line and helps with human readability.

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"body": "My fireplace is on Blynk Powered."}' \

I havent tried, but the supposed limit is 255 chars.



curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"to": "","subj": "About My Fireplace","title": "Thats right !!! Its Blynk Powered!!"}' \


Hoping this helps, its not perfect, but hoping it gives you a start.

1 Like

It’s worth including a link to the official API documentation:

Also, you can a better idea of what can be done using the “set widget property via GET” section by reading this: