Skip to main content

Quick Start

Get up and running with Najeeb Health Suite in 5 minutes! This guide will walk you through making your first API call.

Prerequisites

  • API credentials (Client ID and Client Secret)
  • HTTP client (cURL, Postman, or your preferred tool)
  • Basic understanding of REST APIs

Step 1: Get Your Credentials

If you haven't already, sign up for Najeeb Health Suite and obtain your:

  • Client ID
  • Client Secret

These will be provided in your dashboard after registration.

Step 2: Authenticate

First, obtain an access token:

curl -X POST https://api.najeeb.com/v1/auth/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-d "client_id=YOUR_CLIENT_ID" \
-d "client_secret=YOUR_CLIENT_SECRET"

You'll receive a response like:

{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "Bearer",
"expires_in": 3600
}

Save the access_token for the next step.

Step 3: Make Your First API Call

Let's retrieve a list of patients:

curl -X GET https://api.najeeb.com/v1/patients \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json"

Response

{
"data": [
{
"id": "pat_123456",
"national_id": "1234567890",
"first_name": "أحمد",
"last_name": "محمد",
"date_of_birth": "1990-01-15",
"gender": "male",
"insurance_number": "INS-12345",
"created_at": "2024-01-15T10:30:00Z"
}
],
"meta": {
"page": 1,
"per_page": 20,
"total": 1
}
}

Step 4: Create a Patient

Now let's create a new patient:

curl -X POST https://api.najeeb.com/v1/patients \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"national_id": "9876543210",
"first_name": "فاطمة",
"last_name": "علي",
"date_of_birth": "1985-05-20",
"gender": "female",
"insurance_number": "INS-67890"
}'

Response

{
"data": {
"id": "pat_789012",
"national_id": "9876543210",
"first_name": "فاطمة",
"last_name": "علي",
"date_of_birth": "1985-05-20",
"gender": "female",
"insurance_number": "INS-67890",
"created_at": "2024-01-15T11:00:00Z"
}
}

Complete Example

Here's a complete example in JavaScript:

// Step 1: Get access token
async function getAccessToken(clientId, clientSecret) {
const response = await fetch('https://api.najeeb.com/v1/auth/token', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams({
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret,
}),
});

const data = await response.json();
return data.access_token;
}

// Step 2: Make API call
async function getPatients(accessToken) {
const response = await fetch('https://api.najeeb.com/v1/patients', {
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
},
});

return await response.json();
}

// Usage
const clientId = 'YOUR_CLIENT_ID';
const clientSecret = 'YOUR_CLIENT_SECRET';

const token = await getAccessToken(clientId, clientSecret);
const patients = await getPatients(token);
console.log(patients);

What's Next?

Now that you've made your first API calls, explore: