API quick start
1. Make a key
Section titled “1. Make a key”You need to be one of your organisation’s owners or admins, or the admin of a project (for a key to that project only).
- On the website, open Organisation Settings and go to the Developers tab.
- Choose New key. Give it the name of the program that will use it, such as Architecture report.
- Choose what it reaches (the whole organisation, or one project), its role (Viewer is enough for reading), and when it expires.
- Choose Make key, then Copy key. The key is shown only this once: Farkitect keeps only a fingerprint of it. If it’s lost, make another.
A production key starts fk_live_.
2. Try it in your browser
Section titled “2. Try it in your browser”No terminal needed.
- Open the interactive reference.
- Paste your key into Bearer Token, under Authentication.
- On The key making the request, choose Test Request, then Send.
You should see 200 OK and your key: its name, organisation, role, expiry, and the projects it reaches.
3. Call it from a program
Section titled “3. Call it from a program”Keep the key out of your code: put it in an environment variable.
In a terminal (macOS, Linux, or Windows with Git Bash):
export FARKITECT_API_KEY='fk_live_…'curl https://api.farkitect.com/v1/me -H "Authorization: Bearer $FARKITECT_API_KEY"In Python (with requests):
import os, requests
response = requests.get( "https://api.farkitect.com/v1/me", headers={"Authorization": f"Bearer {os.environ['FARKITECT_API_KEY']}"},)response.raise_for_status()me = response.json()print(me["name"], [p["name"] for p in me["projects"]])In TypeScript or JavaScript (Node 18 or later):
const response = await fetch("https://api.farkitect.com/v1/me", { headers: { Authorization: `Bearer ${process.env.FARKITECT_API_KEY}` },});if (!response.ok) throw new Error(`${response.status}: ${(await response.json()).detail}`);const me = await response.json();console.log(me.name, me.projects.map((p) => p.name));4. See it in Developers
Section titled “4. See it in Developers”Back in Organisation Settings › Developers, your key shows when it was last used. Within ten minutes, Usage counts today’s requests, and any that failed appear under Failed requests, with their request ids.
5. Read a project
Section titled “5. Read a project”Next, list the projects your key reaches, then the metamodels of one of them:
curl https://api.farkitect.com/v1/projects -H "Authorization: Bearer $FARKITECT_API_KEY"curl https://api.farkitect.com/v1/projects/PROJECT_ID/metamodels -H "Authorization: Bearer $FARKITECT_API_KEY"Finding an id in the app: right-click any row in the Explorer or the Views panel, or a shape on a diagram, and choose Copy Id; the open project’s id is in Help › About Farkitect.
No project to try it on? Add the sample project, Farquind Yachts, from the Farketplace. Projects and Metamodels explain what comes back, and Lists and paging how to page through long lists.
If it doesn’t work
Section titled “If it doesn’t work”| You get | Because | Do |
|---|---|---|
401 missing_key |
No key was sent | Check the Authorization header, and that the environment variable is set in the shell running the program |
401 invalid_key |
The key isn’t recognised | Check it was copied whole; make a new one if it’s lost |
403 browser_not_allowed |
It was called from a web page | Call it from a server: see Build with an AI assistant |
429 rate_limited |
Too many requests, or too many at once | Wait the seconds in Retry-After, and send requests one after another |
Every error explains itself in its detail; Errors lists them all.