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 userPOST /auth/client/login- Login as clientPOST /auth/agent/login- Login as agentPOST /oauth2/token- Get OAuth2 token
Projects
POST /projects/search- Search projectsGET /projects/{id}- Get project by IDPOST /projects- Create or update projectDELETE /projects/{id}- Delete project
Users
GET /users- Get all usersGET /users/{id}- Get user by IDPOST /users/create- Create userPUT /users/{id}- Update user
Next Steps
- Explore the API Reference for complete endpoint documentation
- Check out Development Guide for local setup
- Review Project Settings for configuration
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