API Quick Start

Get started with the Treedis API in minutes.

Base URL

All API endpoints are available at:

  • Production: https://api.treedis.com/v1/api
  • Staging: https://stage-api.treedis.com/v1/api

Authentication

Option 1: API Key

Include your API key in the request header:

curl -X GET "https://api.treedis.com/v1/api/users" \
  -H "X-API-Key: your-api-key-here"

Option 2: Bearer Token (User Login)

First, log in to get a token:

curl -X POST "https://api.treedis.com/v1/api/auth/user/login" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your-api-key" \
  -d '{
    "email": "user@example.com",
    "password": "your-password"
  }'

Then use the token in subsequent requests:

curl -X GET "https://api.treedis.com/v1/api/users" \
  -H "Authorization: Bearer your-token-here"

Option 3: OAuth2

Obtain an OAuth2 access token:

curl -X POST "https://api.treedis.com/v1/api/oauth2/token" \
  -H "Content-Type: application/json" \
  -d '{
    "grant_type": "password",
    "client_id": "your-client-id",
    "client_secret": "your-client-secret"
  }'

Your First API Call

Let's retrieve a list of users:

curl -X GET "https://api.treedis.com/v1/api/users?page=0" \
  -H "X-API-Key: your-api-key-here"

Or search for projects:

curl -X POST "https://api.treedis.com/v1/api/projects/search" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-token" \
  -d '{
    "page": 0,
    "limit": 20
  }'

Response Format

All API responses follow a consistent format:

{
  "success": true,
  "data": {
    // Response data here
  },
  "message": "Success"
}

Common Endpoints

Authentication

  • POST /auth/user/login - Login as user
  • POST /auth/client/login - Login as client
  • POST /auth/agent/login - Login as agent
  • POST /oauth2/token - Get OAuth2 token

Projects

  • POST /projects/search - Search projects
  • GET /projects/{id} - Get project by ID
  • POST /projects - Create or update project
  • DELETE /projects/{id} - Delete project

Users

  • GET /users - Get all users
  • GET /users/{id} - Get user by ID
  • POST /users/create - Create user
  • PUT /users/{id} - Update user

Next Steps

Documentation Site Setup

If you're working on the documentation site itself, you can run the Scalar CLI locally.

Install the CLI
npm -g install @scalar/cli
Or, run without install

If you prefer not to install the cli, just prefix all commands with npx @scalar/cli instead of scalar.

Start a Project

No scalar config file? No problem!

Add a config file

Fill this in what your prefered subdomain.

cat >> scalar.config.json5 <<'EOF'
{
  "subdomain": "your-prefered-subdomain.apidocumentation.com",
  "references": [],
  "guides": []
}
EOF
Start the local preview server
npx @scalar/cli project preview

Your (currently empty) documentation site should now be up and running!

Publish

Add some docs to your config

Add an entry to your guides section of the scalar.config.json5. This can be as simple as:

{
  "name": "Guide Name",
  "sidebar":[
    {
      name: "Guide entry name",
      type: "page",
      path: "relative/path/from/scalar-config/to/file.md"
    },
  ]
},
Authorization

Before we can publish we need to authorize!

This command will redirect you to your browser to log in

npx @scalar/cli auth login

After logging in we can create a project. You'll need to pass a name and slug.

npx @scalar/cli project create --name your-preferred-project-name \
--slug costasiella-kuroshimae
Publish your site
npx @scalar/cli project publish

That's it! You can now visit your published site at <your-prefered-subdomain>.apidocumentation.com

Our phone lines are open, 24/7.

Chat with us on Discord

Set up a call

Star us on GitHub