In the main dashboard, there is a section called “Custom Apps”. In the docs, it shows being able to install a meta data app. As a developer, can I write my own custom app somehow and install it here for my organization to use? Or is that restricted to Threekit supported apps?
Hi Alex,
You can certainly develop your own custom apps so they can interface with the platform. I don’t have the guide ready yet to detail everything.
Most of our Rest API endpoints documented here: Introduction
require a backend server, instead of making the calls from the front-end client of your custom web application. There are a few GET calls that can be made from the client-side as well, but most require authentication with a bearer token.
The bearer token can only be a token that you have created inside your org. Using a bearer token allows you to use a custom web app without the need for it to be embedded to your org through the Apps section, although you can still do that.
There’s a secondary way to authenticate an app without using a bearer token, by using a Cookie which ThreeKit provides the app when you do choose to embed it to an org like the way our doc shows for the Metadata App. The Cookie is provided in the request query parameters of the URL, so you can grab it from there inside your app. Then you have to pass it to the fetch api using the Cookie: "<insert your Cookie here>"
header. Authenticating with a Cookie always requires that you also pass the orgId. Both the orgId and Cookie token can be received through the query parameters, with something like this in plain JavaScript:
const searchResult = new URL(window.location.href);
const appid = searchResult.searchParams.get("appid");
const token = searchResult.searchParams.get("token");
const orgId = searchResult.searchParams.get("orgId");
Then, you can call one of the API endpoints using the token and orgId like this, within a try/catch of course:
const tag = "TEST";
const response = await fetch(`https://preview.threekit.com/api/assets?orgId=${orgId}&tags=${tag}&perPage=100`,
{
method: 'GET',
headers: {
Cookie: token,
accept: 'application/json',
'content-type': 'application/json',
}
});
This example makes use of the Get Assets API endpoint documented here: Get Assets, to get a list of assets from the current org which are tagged with the tag TEST. The example in the docs uses only the bearer token authentication method, where you have to supply your own token.
Does this help for the time being? Hopefully I will soon have a more in-depth guide using a template repo as well. Going forward we also provide the hosting service for custom apps, but only if they’re written within our template where we use React + TypeScript + Koa backend server + Zod for some easier typing of body data.
On your own however, you can write your custom apps using whatever language you want. The only thing that matters to the ThreeKit platform is the authentication token being used with the Rest API endpoints, and the orgId if you use the Cookie token.
I’m more referring to the last part of your comment. Where we could install our own app into the Threekit platform just as you do the metadata application. I would be interested to learn more about how to do that. We’d be happy to use your approved tech stack that you mentioned in the comment.
Oh, I see. The web application can be deployed anywhere you want. It doesn’t need to be deployed through the service that ThreeKit offers. All you need is a URL to access the application. If you don’t want to deal with deploying your own app yourself, then we can handle that.
To request a GitHub repo for deployment you just need to message [email protected], and we provide the repo. You could then simply upload your code into the repo, and we take care of the deployment. You would receive a URL to use for the app. You can then also make changes to the github repo and the deployed app will be updated automatically (giving it a few of minutes after you push the changes).
I will check with the team today to make sure we have the template ready.
In the meantime, you can test a custom app locally using the http://localhost:PORT URL, such as localhost:3000. There is a small limitation at the moment with the URL when you add it as an app to the org. The dialog box to add an app requires a URL that has a period . in the URL. For this reason, I usually use either http://localhost:3000/index.html, or if I use react I make a folder with a . in the name, such as http://localhost:3000/home.page/
I hope that makes sense. You don’t have this limitation if you just access the localhost url in your browser outside of the ThreeKit platform (keep in mind that in that case the Rest APIs can only be used with a bearer token).
As an FYI, we are currently using Cloudflare as the host for the apps.
Okay thanks. We are still ironing out the best way to roll out the application we’re speaking of, but knowing this is an option is a huge help.
Thanks again.