background image

Getting Started

Create a project and a table, get an access token and make your first API call.

Getting Started with Stellar DataStore

This guide takes you from a new account to reading and writing your first records through the REST API. Along the way you will:

  1. Create a table and define its fields.
  2. Get an access token, either directly or through OAuth 2.0.
  3. Add, read, filter and update records.

Every API call is shown in cURL, JavaScript, Python, C# and Delphi, using plain HTTP: pick your language on one example and the others follow. The API reference lists every endpoint the same way. If you prefer a client library, see the TMS FNC Cloud Pack, TMS WEB Core, Javascript or Python guides.

Set up your data

1. Sign in

If you don't have an account yet, sign up and confirm your email address. Then sign in to the Stellar DataStore application.

2. Find your project ID

After signing in you land on your project's start page. It shows usage statistics (requests, tables, connected users) and recent activity. Your project ID is shown beneath the project name; you need it in every API call.

The project start page, with the project ID beneath the project name

3. Create a table

  1. Open Tables and click + Create New Table.
  2. Give the table a unique name and, optionally, a description. The new table appears in the list with its table ID.
  3. Click Manage on the table's card (or choose Manage from the ... menu). Here you can edit the table's fields, set permissions for each role and browse its data.

4. Add fields

On the Fields tab, click + Add Field. Use + Add New Field in the dialog to add several fields in one go.

For this guide, create a table called Persons with these three fields:

Field Type Notes
Name NVarChar Maximum size 255
YearOfBirth Int
Married Boolean

An NVarChar field needs a maximum size between 1 and 32767.

Every table also has an id field. It is the primary key and is numbered automatically, so you never send it when adding records.

Authenticate

Every API call needs an access token in the Authorization header:

Authorization: Bearer ACCESS_TOKEN

There are two ways to get one. An access token is the quickest way to start; OAuth 2.0 is the right choice for apps other people sign in to.

Option A: Access token

  1. Open Applications and go to the Access Tokens tab.
  2. Add a token. Give it a name, a lifetime and a role; for a web app, also enter the domain it will be used from.
  3. Copy the token straight away.

The token is shown only once. If you lose it, create a new one.

Anyone who has the token can act with its role, so don't embed access tokens in public apps. Use OAuth 2.0 there instead.

Option B: OAuth 2.0

Register your application

Open Applications, go to the OAuth Applications tab and add an application of type Normal (OAuth 2.0). Give it a name, a role and the callback URLs your app will receive the sign-in result on (up to 5). You get a client ID and a client secret.

For AI assistants that connect through the MCP server, choose MCP client (OAuth 2.1) instead. The OAuth guide explains both types, PKCE and the other endpoints.

Let the user sign in

Send the user's browser to the sign-in page:

https://stellards.io/oauth?response_type=code&client_id=CLIENT_ID&redirect_uri=REDIRECT_URI

redirect_uri must match one of the callback URLs you registered. After the user signs in, the browser is sent back to that URL with an authorization code in the query string.

Exchange the code for tokens

Post the code to the token endpoint as a form-encoded body:

curl -X POST 'https://api.stellards.io/v1/oauth/token' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'grant_type=authorization_code&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&redirect_uri=REDIRECT_URI&code=AUTHORIZATION_CODE'
const response = await fetch("https://api.stellards.io/v1/oauth/token", {
  method: "POST",
  headers: {
    Accept: "application/json",
  },
  body: new URLSearchParams({
    grant_type: "authorization_code",
    client_id: "CLIENT_ID",
    client_secret: "CLIENT_SECRET",
    redirect_uri: "REDIRECT_URI",
    code: "AUTHORIZATION_CODE",
  }),
});
const result = await response.json();
import requests

response = requests.post(
    "https://api.stellards.io/v1/oauth/token",
    headers={"Accept": "application/json"},
    data={
        "grant_type": "authorization_code",
        "client_id": "CLIENT_ID",
        "client_secret": "CLIENT_SECRET",
        "redirect_uri": "REDIRECT_URI",
        "code": "AUTHORIZATION_CODE",
    },
)
result = response.json()
using System.Net.Http.Headers;

using var client = new HttpClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

var body = new FormUrlEncodedContent(new Dictionary<string, string>
{
    ["grant_type"] = "authorization_code",
    ["client_id"] = "CLIENT_ID",
    ["client_secret"] = "CLIENT_SECRET",
    ["redirect_uri"] = "REDIRECT_URI",
    ["code"] = "AUTHORIZATION_CODE",
});
var response = await client.PostAsync("https://api.stellards.io/v1/oauth/token", body);
var result = await response.Content.ReadAsStringAsync();
uses
  System.Classes, System.SysUtils, System.Net.HttpClient, System.Net.URLClient;

var
  Client: THTTPClient;
  Response: IHTTPResponse;
  Form: TStringList;
begin
  Client := THTTPClient.Create;
  Form := TStringList.Create;
  try
    Client.Accept := 'application/json';
    Form.Values['grant_type'] := 'authorization_code';
    Form.Values['client_id'] := 'CLIENT_ID';
    Form.Values['client_secret'] := 'CLIENT_SECRET';
    Form.Values['redirect_uri'] := 'REDIRECT_URI';
    Form.Values['code'] := 'AUTHORIZATION_CODE';
    Response := Client.Post('https://api.stellards.io/v1/oauth/token', Form);
    Writeln(Response.ContentAsString);
  finally
    Form.Free;
    Client.Free;
  end;
end;

The response contains the tokens and how many seconds the access token stays valid:

{
  "access_token": "eyJhbGciOi...",
  "refresh_token": "eyJhbGciOi...",
  "expires_in": 1770
}

Refresh the access token

An access token is valid for 30 minutes; a refresh token for 30 days. Before the access token expires, trade the refresh token for a new pair:

curl -X POST 'https://api.stellards.io/v1/oauth/token' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'grant_type=refresh_token&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&refresh_token=REFRESH_TOKEN'
const response = await fetch("https://api.stellards.io/v1/oauth/token", {
  method: "POST",
  headers: {
    Accept: "application/json",
  },
  body: new URLSearchParams({
    grant_type: "refresh_token",
    client_id: "CLIENT_ID",
    client_secret: "CLIENT_SECRET",
    refresh_token: "REFRESH_TOKEN",
  }),
});
const result = await response.json();
import requests

response = requests.post(
    "https://api.stellards.io/v1/oauth/token",
    headers={"Accept": "application/json"},
    data={
        "grant_type": "refresh_token",
        "client_id": "CLIENT_ID",
        "client_secret": "CLIENT_SECRET",
        "refresh_token": "REFRESH_TOKEN",
    },
)
result = response.json()
using System.Net.Http.Headers;

using var client = new HttpClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

var body = new FormUrlEncodedContent(new Dictionary<string, string>
{
    ["grant_type"] = "refresh_token",
    ["client_id"] = "CLIENT_ID",
    ["client_secret"] = "CLIENT_SECRET",
    ["refresh_token"] = "REFRESH_TOKEN",
});
var response = await client.PostAsync("https://api.stellards.io/v1/oauth/token", body);
var result = await response.Content.ReadAsStringAsync();
uses
  System.Classes, System.SysUtils, System.Net.HttpClient, System.Net.URLClient;

var
  Client: THTTPClient;
  Response: IHTTPResponse;
  Form: TStringList;
begin
  Client := THTTPClient.Create;
  Form := TStringList.Create;
  try
    Client.Accept := 'application/json';
    Form.Values['grant_type'] := 'refresh_token';
    Form.Values['client_id'] := 'CLIENT_ID';
    Form.Values['client_secret'] := 'CLIENT_SECRET';
    Form.Values['refresh_token'] := 'REFRESH_TOKEN';
    Response := Client.Post('https://api.stellards.io/v1/oauth/token', Form);
    Writeln(Response.ContentAsString);
  finally
    Form.Free;
    Client.Free;
  end;
end;

Keep the client secret on your server. Never ship it in browser or mobile code.

Work with records

The examples below use the Persons table from earlier, with project ID 223fazf3-9s6dc-4685-ec30-08ec3ez37ds78 and table ID 100. Replace them with your own.

Every response has the same shape: isSuccess tells you whether the call worked, messages explains what went wrong when it didn't, and data holds the result. Record queries also return count.

Add records

Send one or more records in the records array. Leave out id; it is assigned for you.

curl -X POST 'https://api.stellards.io/v1/data/table?project=PROJECT_ID&table=TABLE_ID' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -d '{
    "records": [
      { "Name": "Mark Smith",   "YearOfBirth": 1970, "Married": true  },
      { "Name": "Paula Garcia", "YearOfBirth": 1982, "Married": false },
      { "Name": "Eva Jones",    "YearOfBirth": 1993, "Married": true  }
    ]
  }'
const response = await fetch("https://api.stellards.io/v1/data/table?project=PROJECT_ID&table=TABLE_ID", {
  method: "POST",
  headers: {
    Accept: "application/json",
    Authorization: "Bearer ACCESS_TOKEN",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "records": [
      {
        "Name": "Mark Smith",
        "YearOfBirth": 1970,
        "Married": true
      },
      {
        "Name": "Paula Garcia",
        "YearOfBirth": 1982,
        "Married": false
      },
      {
        "Name": "Eva Jones",
        "YearOfBirth": 1993,
        "Married": true
      }
    ]
  }),
});
const result = await response.json();
import requests

response = requests.post(
    "https://api.stellards.io/v1/data/table?project=PROJECT_ID&table=TABLE_ID",
    headers={"Accept": "application/json", "Authorization": "Bearer ACCESS_TOKEN"},
    json={
        "records": [
            {"Name": "Mark Smith", "YearOfBirth": 1970, "Married": True},
            {"Name": "Paula Garcia", "YearOfBirth": 1982, "Married": False},
            {"Name": "Eva Jones", "YearOfBirth": 1993, "Married": True},
        ],
    },
)
result = response.json()
using System.Net.Http.Headers;
using System.Text;

using var client = new HttpClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "ACCESS_TOKEN");

var body = new StringContent("""
    {
      "records": [
        {
          "Name": "Mark Smith",
          "YearOfBirth": 1970,
          "Married": true
        },
        {
          "Name": "Paula Garcia",
          "YearOfBirth": 1982,
          "Married": false
        },
        {
          "Name": "Eva Jones",
          "YearOfBirth": 1993,
          "Married": true
        }
      ]
    }
    """, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.stellards.io/v1/data/table?project=PROJECT_ID&table=TABLE_ID", body);
var result = await response.Content.ReadAsStringAsync();
uses
  System.Classes, System.SysUtils, System.Net.HttpClient, System.Net.URLClient;

var
  Client: THTTPClient;
  Response: IHTTPResponse;
  Body: TStringStream;
begin
  Client := THTTPClient.Create;
  Body := TStringStream.Create(
      '{' +
      '  "records": [' +
      '    {' +
      '      "Name": "Mark Smith",' +
      '      "YearOfBirth": 1970,' +
      '      "Married": true' +
      '    },' +
      '    {' +
      '      "Name": "Paula Garcia",' +
      '      "YearOfBirth": 1982,' +
      '      "Married": false' +
      '    },' +
      '    {' +
      '      "Name": "Eva Jones",' +
      '      "YearOfBirth": 1993,' +
      '      "Married": true' +
      '    }' +
      '  ]' +
      '}',
      TEncoding.UTF8);
  try
    Client.Accept := 'application/json';
    Client.CustomHeaders['Authorization'] := 'Bearer ACCESS_TOKEN';
    Client.ContentType := 'application/json';
    Response := Client.Post('https://api.stellards.io/v1/data/table?project=PROJECT_ID&table=TABLE_ID', Body);
    Writeln(Response.ContentAsString);
  finally
    Body.Free;
    Client.Free;
  end;
end;

The response returns the new records with their IDs:

{
  "count": 3,
  "data": [
    { "id": 1, "Name": "Mark Smith",   "YearOfBirth": 1970, "Married": true  },
    { "id": 2, "Name": "Paula Garcia", "YearOfBirth": 1982, "Married": false },
    { "id": 3, "Name": "Eva Jones",    "YearOfBirth": 1993, "Married": true  }
  ],
  "messages": [],
  "isSuccess": true
}

Look up your project and table IDs

If you don't have the IDs at hand, you can ask the API for them.

List your projects:

curl -X GET 'https://api.stellards.io/v1/schema/project' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer ACCESS_TOKEN'
const response = await fetch("https://api.stellards.io/v1/schema/project", {
  headers: {
    Accept: "application/json",
    Authorization: "Bearer ACCESS_TOKEN",
  },
});
const result = await response.json();
import requests

response = requests.get(
    "https://api.stellards.io/v1/schema/project",
    headers={"Accept": "application/json", "Authorization": "Bearer ACCESS_TOKEN"},
)
result = response.json()
using System.Net.Http.Headers;

using var client = new HttpClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "ACCESS_TOKEN");

var response = await client.GetAsync("https://api.stellards.io/v1/schema/project");
var result = await response.Content.ReadAsStringAsync();
uses
  System.Classes, System.SysUtils, System.Net.HttpClient, System.Net.URLClient;

var
  Client: THTTPClient;
  Response: IHTTPResponse;
begin
  Client := THTTPClient.Create;
  try
    Client.Accept := 'application/json';
    Client.CustomHeaders['Authorization'] := 'Bearer ACCESS_TOKEN';
    Response := Client.Get('https://api.stellards.io/v1/schema/project');
    Writeln(Response.ContentAsString);
  finally
    Client.Free;
  end;
end;
{
  "data": [
    {
      "id": "223fazf3-9s6dc-4685-ec30-08ec3ez37ds78",
      "name": "My Project",
      "description": "My first project",
      "isMultitenant": false
    }
  ],
  "messages": [],
  "isSuccess": true
}

List the tables in a project (add &table=NAME to look up a single table by name):

curl -X GET 'https://api.stellards.io/v1/schema/table?project=223fazf3-9s6dc-4685-ec30-08ec3ez37ds78' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer ACCESS_TOKEN'
const response = await fetch("https://api.stellards.io/v1/schema/table?project=223fazf3-9s6dc-4685-ec30-08ec3ez37ds78", {
  headers: {
    Accept: "application/json",
    Authorization: "Bearer ACCESS_TOKEN",
  },
});
const result = await response.json();
import requests

response = requests.get(
    "https://api.stellards.io/v1/schema/table?project=223fazf3-9s6dc-4685-ec30-08ec3ez37ds78",
    headers={"Accept": "application/json", "Authorization": "Bearer ACCESS_TOKEN"},
)
result = response.json()
using System.Net.Http.Headers;

using var client = new HttpClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "ACCESS_TOKEN");

var response = await client.GetAsync("https://api.stellards.io/v1/schema/table?project=223fazf3-9s6dc-4685-ec30-08ec3ez37ds78");
var result = await response.Content.ReadAsStringAsync();
uses
  System.Classes, System.SysUtils, System.Net.HttpClient, System.Net.URLClient;

var
  Client: THTTPClient;
  Response: IHTTPResponse;
begin
  Client := THTTPClient.Create;
  try
    Client.Accept := 'application/json';
    Client.CustomHeaders['Authorization'] := 'Bearer ACCESS_TOKEN';
    Response := Client.Get('https://api.stellards.io/v1/schema/table?project=223fazf3-9s6dc-4685-ec30-08ec3ez37ds78');
    Writeln(Response.ContentAsString);
  finally
    Client.Free;
  end;
end;
{
  "data": [
    { "id": 100, "name": "Persons",     "description": "Table to help with the user guide", "isMultitenant": false },
    { "id": 106, "name": "Other table", "description": "An additional table",                "isMultitenant": false }
  ],
  "messages": [],
  "isSuccess": true
}

Read records

curl -X GET 'https://api.stellards.io/v1/data/table?project=223fazf3-9s6dc-4685-ec30-08ec3ez37ds78&table=100' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer ACCESS_TOKEN'
const response = await fetch("https://api.stellards.io/v1/data/table?project=223fazf3-9s6dc-4685-ec30-08ec3ez37ds78&table=100", {
  headers: {
    Accept: "application/json",
    Authorization: "Bearer ACCESS_TOKEN",
  },
});
const result = await response.json();
import requests

response = requests.get(
    "https://api.stellards.io/v1/data/table?project=223fazf3-9s6dc-4685-ec30-08ec3ez37ds78&table=100",
    headers={"Accept": "application/json", "Authorization": "Bearer ACCESS_TOKEN"},
)
result = response.json()
using System.Net.Http.Headers;

using var client = new HttpClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "ACCESS_TOKEN");

var response = await client.GetAsync("https://api.stellards.io/v1/data/table?project=223fazf3-9s6dc-4685-ec30-08ec3ez37ds78&table=100");
var result = await response.Content.ReadAsStringAsync();
uses
  System.Classes, System.SysUtils, System.Net.HttpClient, System.Net.URLClient;

var
  Client: THTTPClient;
  Response: IHTTPResponse;
begin
  Client := THTTPClient.Create;
  try
    Client.Accept := 'application/json';
    Client.CustomHeaders['Authorization'] := 'Bearer ACCESS_TOKEN';
    Response := Client.Get('https://api.stellards.io/v1/data/table?project=223fazf3-9s6dc-4685-ec30-08ec3ez37ds78&table=100');
    Writeln(Response.ContentAsString);
  finally
    Client.Free;
  end;
end;
{
  "count": 3,
  "data": [
    { "id": 1, "Name": "Mark Smith",   "YearOfBirth": 1970, "Married": true  },
    { "id": 2, "Name": "Paula Garcia", "YearOfBirth": 1982, "Married": false },
    { "id": 3, "Name": "Eva Jones",    "YearOfBirth": 1993, "Married": true  }
  ],
  "messages": [],
  "isSuccess": true
}

Query parameters

Parameter Required Description
project Yes The ID of your project.
table Yes The ID of the table to read.
offset No How many records to skip.
take No How many records to return.
whereQuery No Filters the records. See Filter records.
sortQuery No Sorts the records, as FIELD;asc or FIELD;desc. Sort on several fields by joining them with &, for example Name;asc&YearOfBirth;desc. Each field can be used once.
joinQuery No Joins a second table in the same request, as TABLE_A;FOREIGN_KEY=TABLE_B;id.
select No The fields to return, separated by ;, for example id;Name. Returns all fields when left out.
distinct No Set to true together with select to return only unique values.

URL-encode every query value. For example, Name;asc&YearOfBirth;desc becomes Name%3Basc%26YearOfBirth%3Bdesc.

Filter records

A filter has the form FIELD;OPERATOR;VALUE. To combine filters, end one with & (and) or | (or) and follow it with the next:

Married;equal;true&YearOfBirth;smallerthan;1980
Operator Aliases Matches when the field
equal = equals the value
not_equal !=, <> differs from the value
largerthan >, lt is greater than the value
smallerthan <, st is less than the value
largerthan_equal >= is greater than or equal to the value
smallerthan_equal <= is less than or equal to the value
like matches a pattern (use % as a wildcard)
notlike doesn't match a pattern
in is one of the values, separated by commas (id;in;1,3)
notin is none of the values, separated by commas
null is empty with value true (Name;null;true), or not empty with false

lt means larger than and st means smaller than, not "less than".

For example, to get everyone who is married, filter on Married;equal;true, URL-encoded:

curl -X GET 'https://api.stellards.io/v1/data/table?project=223fazf3-9s6dc-4685-ec30-08ec3ez37ds78&table=100&whereQuery=Married%3Bequal%3Btrue' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer ACCESS_TOKEN'
const response = await fetch("https://api.stellards.io/v1/data/table?project=223fazf3-9s6dc-4685-ec30-08ec3ez37ds78&table=100&whereQuery=Married%3Bequal%3Btrue", {
  headers: {
    Accept: "application/json",
    Authorization: "Bearer ACCESS_TOKEN",
  },
});
const result = await response.json();
import requests

response = requests.get(
    "https://api.stellards.io/v1/data/table?project=223fazf3-9s6dc-4685-ec30-08ec3ez37ds78&table=100&whereQuery=Married%3Bequal%3Btrue",
    headers={"Accept": "application/json", "Authorization": "Bearer ACCESS_TOKEN"},
)
result = response.json()
using System.Net.Http.Headers;

using var client = new HttpClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "ACCESS_TOKEN");

var response = await client.GetAsync("https://api.stellards.io/v1/data/table?project=223fazf3-9s6dc-4685-ec30-08ec3ez37ds78&table=100&whereQuery=Married%3Bequal%3Btrue");
var result = await response.Content.ReadAsStringAsync();
uses
  System.Classes, System.SysUtils, System.Net.HttpClient, System.Net.URLClient;

var
  Client: THTTPClient;
  Response: IHTTPResponse;
begin
  Client := THTTPClient.Create;
  try
    Client.Accept := 'application/json';
    Client.CustomHeaders['Authorization'] := 'Bearer ACCESS_TOKEN';
    Response := Client.Get('https://api.stellards.io/v1/data/table?project=223fazf3-9s6dc-4685-ec30-08ec3ez37ds78&table=100&whereQuery=Married%3Bequal%3Btrue');
    Writeln(Response.ContentAsString);
  finally
    Client.Free;
  end;
end;
{
  "count": 2,
  "data": [
    { "id": 1, "Name": "Mark Smith", "YearOfBirth": 1970, "Married": true },
    { "id": 3, "Name": "Eva Jones",  "YearOfBirth": 1993, "Married": true }
  ],
  "messages": [],
  "isSuccess": true
}

To get everyone born before 1980, use YearOfBirth;smallerthan;1980.

Update records

Paula got married, so record 2 needs updating. Send the IDs to change in idList and the new field values in record. Fields you leave out keep their current value.

curl -X PUT 'https://api.stellards.io/v1/data/table?project=223fazf3-9s6dc-4685-ec30-08ec3ez37ds78&table=100' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -d '{ "idList": [2], "record": { "Married": true } }'
{
  "count": 1,
  "data": [
    { "id": 2, "Name": "Paula Garcia", "YearOfBirth": 1982, "Married": true }
  ],
  "messages": [],
  "isSuccess": true
}

Without idList, the update would change every record in the table, so the API refuses it unless you add force=true to the URL.

Next steps

  • Browse every endpoint, with examples in your language, in the API reference, or import the collection with Run in Postman in the sidebar.
  • Use Stellar DataStore from Delphi with TMS FNC Cloud Pack or TMS WEB Core.
  • Use it from the browser or Node.js with the Javascript guide, or from Python.
  • Let an AI assistant such as Claude work with your projects through the MCP server.