Help Me! About Snap! API.

Hello everyone. I am new to snap. and I need a real world sample on how to use the Snap API
to access and control maybe snap from the outside. I already try all whats in the API documentation but to no avail up until now. Its been 5 days I am working for this. Can anyone help for any sample on how to Implement Snap! API?

TIA.

Snap! does not have cloud variables. If you need cloud variables, then you need to run your own server. If you want to save projects, there is an XML generator where you can replace the variable with another example. I found this from the Firefox network log, but even with chrome it is probably possible.

Hi @jezsnap,
Some comments...

  • Maybe you already know it, but Snap! Api docs are here.
  • Aside this, maybe the main "problem" is how to implement this. I don't know if you are working on a web page, a server, a web service... This forum topic may be useful to you.
  • And if you don't need an online use, you also can use Snap4Arduino desktop edition. It has a webserver to connect http request directly to our Snap! world. Then, you can connect other webpages, other Snap! projects, other PCs from your network, mobile apps... Snap4Arduino http protocol docs here

Joan

Thank you so much Sir @jguille2 for the Snap4Arduino http protocol Link, but my question is so much related to @ericstein post

Is there any working sample of this API for me to start with?
That would be a great help for me.

What realy i am working on is a Snap Modification so that it can Access a Database using Blocks. I want Snap to be able to Read and Write a database by building a new Block that can Build Database Queries Like - "Select * From TableStudents" or
UPDATE table_name
SET column1 = value1 , column2 = value2 , ...
WHERE condition ;

This is what i come up so far:
SnapAPI2

I want to capture and execute the value of the abc varible from outside Snap. Can I do that using Snap API?

Hi @jezsnap,

If you want to interact with a DB, I think you don't need any Snap! API, because you have an url block. What you need is "an API for your DB".

Mounting your DB with a WebServer you can build simple web files to make responses for web queries (and also, for Snap! queries).
An example... (using PHP):

<?php
//Your DB connection info
$servername = "localhost";
$username = "public";
$password = "public";
$dbname = "public";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
$sql = $_GET["query"];
$result = $conn->query($sql);
$conn->close();
// Returning data
while ($row = $result->fetch_assoc()) {
    print_r($row);
}
?>

And then, your Snap! can call your DB:

Is this useful?

Joan

Thank you for this. This is Great wow. Thank you so much.

A few years ago Eckart Modrow presented at #scratch2015AMS a SQL Snap mod. It looks like it's still updated at http://snapextensions.uni-goettingen.de/

Thank you i am looking at it now.

Wow this is i am looking for THANK YOU so much @xota

Use js,it has a sql module.If you want to do only db,then use php.