API Documentation


Set up socket.io

const socket = io('https://api.interaction.gd/your-name').connect();

Send any data type to other connected users.

socket.emit('broadcast', 'hi');

Receive messages

socket.on('broadcast', data => {
	console.log(data);
});

Save an object to the database. Arrays of objects are allowed too.

socket.emit('insert', {cool: 'stuff'});

Optionally, you can access the returned object

socket.emit('insert', {cool: 'stuff'}, data => {
	console.log(data);
});

You can also have the other users receive what was saved.

socket.on('insert', data => {
	console.log(data);
});

Retrieve information by either sending an empty object to retrieve everything from the db, or an object with the values you wish to see.

socket.emit('find', {}, data => {
	console.log(data);
});