How to use API in case, you are not a programmer? May be, it is easier, than you think. There is probably some "programming", you already do. Excel functions, VBA script, SQL ...
In case, you're a programmer, please, do not read this. I will simplify a lot of things. You can go directly to https://tabidoo.docs.apiary.io.
There is everything you need.
HTTP API is simple and powerful.
This example will be in javascript. You need to have Node.js installed. As an editor I use VS Code, but any code editor works here.
To access data, you need a token (something as a password) and for request we have to specify application ID and schema ID.
Token
Never publish your token. It is your secret.
Create a user in the Tabidoo application, where you want to work with data. We will use this user for authentication and authorization. Give the user as little of user rights as you have to. This is our service account.
Login under this "service account" and go to "User Settings". In the section API create a token and save it. Be careful, this is your key to data. Do not publish that.
Application/Schema id
As you are in the application, browsing your data, the url (address line in the browser) looks like
https://app.tabidoo.cloud/#/app/9acd7367-12c8-42d3-92cf-49d62ca483f8/schema/7cf922fa-e26d-4238-95b9-6890779cdf03
Obviously the first id is the application id, the second one is the schema id.
Code
Congratulation. We are ready.
Now, for the scripting. Open VS Code (or any other text editor, notepad++?) and create a new js file. In my case "program.js". We will define our variables:
Please replace the values with your ids and token!
Then, we can load data from schema
main();
async function main() {
try {
// insert data
await insertRows(5);
// load data from a schema
const response = await loadData();
console.log(response.data);
} catch (error) {
console.log(error);
}
}
Nothing interesting yet. This is just a call of functions, we did not implemented yet.
Load data. Nothing special. Loads data from schema.
function loadData() {
return new Promise((resolve, reject) => {
request({
url: urlPath,
json: true,
headers: {
"Authorization": "Bearer " + bearerToken
}
},
(error, response, body) => {
if (error) {
reject(error);
} else {
resolve(body);
}
});
});
}
Insert row. Again. Nothing special.
function insertRow(item) {
return new Promise((resolve, reject) => {
request({
method: 'POST',
url: urlPath,
json: true,
body: item,
headers: {
"Authorization": "Bearer " + bearerToken
}
},
(error, response, body) => {
if (error) {
reject(error);
} else {
resolve(body);
}
});
});
}
All the previous method are not unique at all. This is just a load and insert. Now, let's create something just for us.
When you work with API, you should use internal names of schema items (columns). It is good to change them, otherwise you need to use names like re8Sd98xT.
Schema Items -> Advanced features -> Developer level -> Schema item internal name.
So, here is a simple method for inserting some rows to schema. We setup properties and store the values. Works even with linked schemas.
async function insertRows(count) {
// id of the item from linked schema
const externalLinkID = "96d79e87-76ac-48d8-8f4f-45b89dff47f6";
for (let i = 0; i < count; i++) {
const row = {
fields: {
code: 'C' + i.toString().padStart(4, '0'),
price: (i * 457) % 456,
nextMeeting: new Date().toISOString(),
externalLink: {
"id": externalLinkID
}
}
};
await insertRow(row);
console.log('Inserted ' + i, row)
}
}
Very simple. We set code to ""C0001", price to some random value, nextMeeting to today and we assign a record from linked schema.
The whole script (program.js)
var request = require('request');
// When you are in schema, you can take applicationId and schemaId from url ;)
// https://app.tabidoo.cloud/#/app/8ecd7367-12c8-42d3-92cf-49d62ca483f8/schema/b5f922fa-e26d-4238-95b9-6890779cdf03
const applicationId = '9acd7367-12c8-42d3-92cf-49d62ca483f8';
const schemaId = '7cf922fa-e26d-4238-95b9-6890779cdf03';
const urlPath = `https://app.tabidoo.cloud/api/v2/apps/${applicationId}/schemas/${schemaId}/data`;
// Tabidoo, User Settings, API
let bearerToken = 'Tabidoo -> User Settings -> API';
main();
async function main() {
try {
// insert data
await insertRows(5);
// load data from a schema
const response = await loadData();
console.log(response.data);
} catch (error) {
console.log(error);
}
}
// Function definitions
// ---------------------------------------------------------------------------------------------------------------------------------
// insert X rows
async function insertRows(count) {
// link to another schema
const externalLinkID = "96d79e87-76ac-48d8-8f4f-45b89dff47f6";
for (let i = 0; i < count; i++) {
const row = {
fields: {
code: 'C' + i.toString().padStart(4, '0'),
price: (i * 457) % 456,
nextMeeting: new Date().toISOString(),
externalLink: {
"id": externalLinkID
}
}
};
await insertRow(row);
console.log('Inserted ' + i, row)
}
}
// General calls to Tabidoo
// ---------------------------------------------------------------------------------------------------------------------------------
function loadData() {
return new Promise((resolve, reject) => {
request({
url: urlPath,
json: true,
headers: {
"Authorization": "Bearer " + bearerToken
}
},
(error, response, body) => {
if (error) {
reject(error);
} else {
resolve(body);
}
});
});
}
function insertRow(item) {
return new Promise((resolve, reject) => {
request({
method: 'POST',
url: urlPath,
json: true,
body: item,
headers: {
"Authorization": "Bearer " + bearerToken
}
},
(error, response, body) => {
if (error) {
reject(error);
} else {
resolve(body);
}
});
});
}
And - how to run our example?
First, you need to download the "request" package. So in the same directory as we have program.js, run this command from a command line (and confirm defaults).
npm init
Then
npm install request --save
And finally, everything is ready and we can run our code by this command
node program
In case you are new to javascript, the first steps can be a little annoying. However, as you get over first troubles, it can save you a lot of time.