Making Your First API Call
Once you have your credentials, you can start making API calls.
Environment Setup
Store your credentials securely using environment variables:
# .env file
MOUNTAIN_API_URL=https://api.mountain-dev.xyz
PUBLIC_API_ACCESS_TOKEN=your_access_token_here
PROJECT_API_KEY=your_project_api_key_here
Example: Get Your Projects
Using cURL
curl -X GET "https://api.mountain-dev.xyz/public-api/v3/project/get-projects" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "x-project-api-key: YOUR_PROJECT_API_KEY" \
-H "Content-Type: application/json"
Using JavaScript/TypeScript
const MOUNTAIN_API_URL = process.env.MOUNTAIN_API_URL;
const ACCESS_TOKEN = process.env.PUBLIC_API_ACCESS_TOKEN;
const PROJECT_API_KEY = process.env.PROJECT_API_KEY;
async function getProjects() {
const response = await fetch(`${MOUNTAIN_API_URL}/public-api/v3/project/get-projects`, {
method: 'GET',
headers: {
'Authorization': `Bearer ${ACCESS_TOKEN}`,
'x-project-api-key': PROJECT_API_KEY,
'Content-Type': 'application/json'
}
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return await response.json();
}
Response
{
"projects": [
{
"id": "your-project-id",
"name": "Your Project Name",
"status": "active"
}
]
}