API Endpoints for JSON Datasets
Explore every powerful feature of the Sample JSON API including filtering, deep search, sorting modes, pagination, schema validation, field selection, and invalid JSON diagnostics.
🎯 Base API Endpoint
https://api.jsons.live/employees/5-level/10-KB/formatted

📦 Standard API Response Format
- ✓file – Source JSON file path
- ✓type – JSON type (formatted/minified/invalid)
- ✓total – Total available records
- ✓page – Current page number
- ✓limit – Records per page
- ✓count – Records returned in response
- ✓data – Final processed dataset

🔍 Single Filter Using Query Parameters
You can filter records by passing a field name and value as a query parameter. The API matches records dynamically.
https://api.jsons.live/employees/5-level/10-KB/formatted?name=Jodi Reyes

🔗 Multiple Filters – Combined Query Parameters
The API supports multiple filters at the same time. All conditions must match for a record to be included in the response.
https://api.jsons.live/employees/5-level/10-KB/formatted?name=Jodi Reyes&taskId=T386

🌳 Nested Field Filtering
Use dot notation to filter deeply nested JSON fields.
https://api.jsons.live/employees/5-level/10-KB/formatted?employee.department.manager.contact.email=eodom@example.net

📊 Sorting – Multi Field & Natural Sort
Sort by ascending order A-Z.
https://api.jsons.live/employees/5-level/10-KB/formatted?sort=employee.name

Sort by descending order Z-A.
https://api.jsons.live/employees/5-level/10-KB/formatted?sort=-employee.name

🔄 Multi-Field Sorting
Sort by one or multiple fields. Supports ascending and descending order.
https://api.jsons.live/employees/5-level/10-KB/formatted?sort=employee.name,-employee.position

🔢 Natural Sorting
Ensures numeric values inside strings are sorted correctly (e.g., emp2 before emp10).
⚡ Advanced Sorting Modes
Sort Modes
- •first – Default value
- •max – Maximum numeric value
- •min – Minimum numeric value
- •sum – Sum of numeric arrays
- •avg – Average of numeric arrays
https://api.jsons.live/employees/5-level/10-KB/formatted?sort=employee.projects.tasks.details.hoursSpent:sum

📄 Pagination and Limit
https://api.jsons.live/employees/5-level/10-KB/formatted?page=2&limit=2

⚙️ Limit Parameter – Control Data Size
The limit query parameter controls how many records are returned in a single API call. This is useful for previews, testing, and performance optimization.
https://api.jsons.live/employees/5-level/10-KB/formatted?limit=3

🎯 Field Selection – Return Only What You Need
Reduces payload size and improves performance.
https://api.jsons.live/employees/5-level/10-KB/formatted?fields=employee.id,employee.name

🏷️ Field Alias Support
Short field names are automatically mapped to nested paths.
https://api.jsons.live/employees/5-level/10-KB/formatted?fields=id,name
✅ Schema Validation
Validates consistency of field types across all records and reports mismatches.
https://api.jsons.live/employees/5-level/10-KB/formatted?schema=true

⚠️ Invalid JSON Validation
Invalid JSON datasets can be analyzed and validated using the validate endpoint.
https://api.jsons.live/employees/5-level/10-KB/invalid/validate

🔦 Error Highlight & Auto Fix Suggestions
Returns exact line, column position, highlights the error, and provides suggestions like missing comma or missing bracket.
Features
- ✓Detects JSON parsing errors
- ✓Extracts exact error position
- ✓Returns line & column number
- ✓Highlights problematic line
- ✓Provides auto-fix suggestions

⭐ Feature List
- →Apply deep recursive filtering
- →Apply dot-path filtering
- →Perform natural multi-field sorting
- →Apply advanced aggregation sorting
- →Apply pagination
- →Select requested fields
- →Validate schema (if requested)
- →Return structured metadata response
💡 Best Practice
Best performance order: Filter → Sort → Paginate → Select Fields.
The Employees API demonstrates a full-featured JSON query engine capable of behaving like a production-grade backend system without a traditional database.
🌟 Key Benefits
💡 Pro Tip
Apply filters before pagination for optimal performance and accurate results.
With advanced query-based API endpoints, Sample JSON now behaves like a production-ready REST API system—empowering developers to build, test, and simulate real-world data workflows effortlessly.
💻 API Usage Examples (JavaScript & Python)
Below are comprehensive examples demonstrating all API features using JavaScript (Fetch API) and Python (Requests library). Each example shows practical usage patterns for real-world applications.
1. Basic API Request
// Basic fetch request
async function fetchEmployees() {
try {
const response = await fetch('https://api.jsons.live/employees/5-level/10-KB/formatted');
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
console.log('✅ Success!');
console.log('Total records:', data.total);
console.log('Current page:', data.page);
console.log('Records returned:', data.count);
console.log('First employee:', data.data[0]);
return data;
} catch (error) {
console.error('❌ Error fetching data:', error.message);
}
}
// Execute
fetchEmployees();2. Filtering Examples
Single Filter
// Filter by exact name match
async function filterByName(name) {
const response = await fetch(
`https://api.jsons.live/employees/5-level/10-KB/formatted?name=${encodeURIComponent(name)}`
);
const data = await response.json();
console.log(`Found ${data.count} employees named "${name}"`);
data.data.forEach(emp => {
console.log(` - ${emp.employee.name} (${emp.employee.position})`);
});
}
filterByName('Jodi Reyes');Multiple Filters
// Filter with multiple conditions
async function filterMultiple() {
const params = new URLSearchParams({
'employee.department.name': 'Engineering',
'employee.position': 'Senior Developer',
'sort': '-employee.name'
});
const response = await fetch(
`https://api.jsons.live/employees/5-level/10-KB/formatted?${params}`
);
const data = await response.json();
console.log(`Found ${data.count} senior developers in Engineering`);
data.data.forEach(emp => {
console.log(` - ${emp.employee.name}`);
});
}
filterMultiple();Nested Field Filtering
// Filter using dot notation for nested fields
async function filterByManager(email) {
const response = await fetch(
`https://api.jsons.live/employees/5-level/10-KB/formatted?employee.department.manager.contact.email=${email}`
);
const data = await response.json();
console.log(`Employees under manager with email ${email}:`);
data.data.forEach(emp => {
const manager = emp.employee.department.manager;
console.log(` - ${emp.employee.name} (Manager: ${manager.name})`);
});
}
filterByManager('eodom@example.net');3. Sorting Examples
Basic Sorting
// Sort ascending (A-Z)
async function sortAscending() {
const response = await fetch(
'https://api.jsons.live/employees/5-level/10-KB/formatted?sort=employee.name'
);
const data = await response.json();
console.log('Employees sorted A-Z:');
data.data.forEach((emp, i) => {
console.log(` ${i + 1}. ${emp.employee.name}`);
});
}
// Sort descending (Z-A)
async function sortDescending() {
const response = await fetch(
'https://api.jsons.live/employees/5-level/10-KB/formatted?sort=-employee.name'
);
const data = await response.json();
console.log('Employees sorted Z-A:');
data.data.forEach((emp, i) => {
console.log(` ${i + 1}. ${emp.employee.name}`);
});
}
sortAscending();
sortDescending();Multi-Field Sorting
// Sort by multiple fields
async function multiFieldSort() {
const response = await fetch(
'https://api.jsons.live/employees/5-level/10-KB/formatted?sort=employee.department.name,-employee.position'
);
const data = await response.json();
console.log('Employees sorted by department (A-Z) and position (Z-A):');
data.data.forEach(emp => {
console.log(` ${emp.employee.department.name} - ${emp.employee.position} - ${emp.employee.name}`);
});
}
multiFieldSort();Aggregation Sorting
// Sort by aggregated values
async function sortByTotalHours() {
const response = await fetch(
'https://api.jsons.live/employees/5-level/10-KB/formatted?sort=employee.projects.tasks.details.hoursSpent:sum&limit=10'
);
const data = await response.json();
console.log('Employees sorted by total hours worked:');
data.data.forEach(emp => {
// Calculate total hours for display
let totalHours = 0;
emp.employee.projects?.forEach(project => {
project.tasks?.forEach(task => {
totalHours += task.details?.hoursSpent || 0;
});
});
console.log(` ${emp.employee.name}: ${totalHours} hours`);
});
}
sortByTotalHours();4. Pagination Examples
Basic Pagination
// Fetch specific page with custom limit
async function getPage(page = 1, limit = 5) {
const response = await fetch(
`https://api.jsons.live/employees/5-level/10-KB/formatted?page=${page}&limit=${limit}`
);
const data = await response.json();
console.log(`Page ${data.page} of ${Math.ceil(data.total / data.limit)}`);
console.log(`Showing ${data.count} of ${data.total} records`);
data.data.forEach(emp => {
console.log(` - ${emp.employee.name}`);
});
return data;
}
// Fetch first 3 pages
async function fetchMultiplePages() {
for (let page = 1; page <= 3; page++) {
console.log(`\n📄 Page ${page}:`);
await getPage(page, 3);
}
}
fetchMultiplePages();Infinite Scroll Simulation
// Simulate infinite scroll pagination
async function* paginateGenerator(limit = 5) {
let page = 1;
let hasMore = true;
while (hasMore) {
const response = await fetch(
`https://api.jsons.live/employees/5-level/10-KB/formatted?page=${page}&limit=${limit}`
);
const data = await response.json();
yield data;
hasMore = data.page * data.limit < data.total;
page++;
}
}
// Usage
async function loadAllPages() {
const generator = paginateGenerator(3);
for await (const page of generator) {
console.log(`📦 Page ${page.page}: ${page.count} items`);
page.data.forEach(emp => {
console.log(` ${emp.employee.name}`);
});
}
}
loadAllPages();5. Field Selection Examples
// Select specific fields to reduce payload
async function selectFields() {
// Get only id, name, and position
const response = await fetch(
'https://api.jsons.live/employees/5-level/10-KB/formatted?fields=employee.id,employee.name,employee.position&limit=5'
);
const data = await response.json();
console.log('Selected fields only (reduced payload):');
data.data.forEach(emp => {
console.log(` ID: ${emp.employee.id}`);
console.log(` Name: ${emp.employee.name}`);
console.log(` Position: ${emp.employee.position}`);
console.log(' ---');
});
// Calculate size reduction
const fullSize = JSON.stringify(data).length;
console.log(`Response size: ${fullSize} bytes`);
}
selectFields();Using Field Aliases
// Use short field names (automatically mapped)
async function useAliases() {
const response = await fetch(
'https://api.jsons.live/employees/5-level/10-KB/formatted?fields=id,name,position&limit=5'
);
const data = await response.json();
console.log('Using field aliases:');
data.data.forEach(emp => {
// Aliases automatically map to nested paths
console.log(` ${emp.id}: ${emp.name} - ${emp.position}`);
});
}
useAliases();6. Complete JavaScript API Client
// Full-featured API client class
class EmployeesAPI {
constructor(baseURL = 'https://api.jsons.live/employees/5-level/10-KB/formatted') {
this.baseURL = baseURL;
this.cache = new Map();
}
async request(params = {}) {
// Build URL with parameters
const url = new URL(this.baseURL);
Object.entries(params).forEach(([key, value]) => {
if (value !== undefined && value !== null) {
url.searchParams.append(key, value);
}
});
// Check cache
const cacheKey = url.toString();
if (this.cache.has(cacheKey)) {
console.log('📦 Returning cached response');
return this.cache.get(cacheKey);
}
// Make request
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
}
const data = await response.json();
// Cache for 5 minutes
this.cache.set(cacheKey, data);
setTimeout(() => this.cache.delete(cacheKey), 5 * 60 * 1000);
return data;
} catch (error) {
console.error('❌ Request failed:', error);
throw error;
}
}
// Filter methods
async findByName(name, options = {}) {
return this.request({ 'employee.name': name, ...options });
}
async findByDepartment(department, options = {}) {
return this.request({ 'employee.department.name': department, ...options });
}
async findByManager(email, options = {}) {
return this.request({ 'employee.department.manager.contact.email': email, ...options });
}
// Sorting methods
async getSorted(field, ascending = true, options = {}) {
const sort = ascending ? field : `-${field}`;
return this.request({ sort, ...options });
}
async getByTotalHours(options = {}) {
return this.request({
sort: 'employee.projects.tasks.details.hoursSpent:sum',
...options
});
}
// Pagination
async getPage(page = 1, limit = 10, options = {}) {
return this.request({ page, limit, ...options });
}
async getAllPages(options = {}) {
const pages = [];
let page = 1;
let hasMore = true;
while (hasMore) {
const data = await this.getPage(page, 100, options);
pages.push(...data.data);
hasMore = data.page * data.limit < data.total;
page++;
}
return pages;
}
// Field selection
async selectFields(fields, options = {}) {
const fieldsStr = Array.isArray(fields) ? fields.join(',') : fields;
return this.request({ fields: fieldsStr, ...options });
}
// Schema
async getSchema() {
return this.request({ schema: 'true' });
}
// Utility methods
async getStats() {
const data = await this.request({
fields: 'employee.id,employee.name,employee.projects',
limit: 100
});
const stats = {
total: data.total,
withProjects: 0,
totalHours: 0,
byDepartment: {}
};
data.data.forEach(item => {
const emp = item.employee;
const dept = emp.department?.name || 'Unknown';
// Department count
stats.byDepartment[dept] = (stats.byDepartment[dept] || 0) + 1;
// Project stats
if (emp.projects?.length) {
stats.withProjects++;
emp.projects.forEach(project => {
project.tasks?.forEach(task => {
stats.totalHours += task.details?.hoursSpent || 0;
});
});
}
});
return stats;
}
}
// Usage example
async function demonstrateAPI() {
const api = new EmployeesAPI();
// 1. Find by name
console.log('🔍 Finding Jodi Reyes...');
const jodi = await api.findByName('Jodi Reyes');
console.log('Found:', jodi.data[0]?.employee.name);
// 2. Get sorted engineers
console.log('
📊 Engineering department sorted by name:');
const engineers = await api.findByDepartment('Engineering', {
sort: 'employee.name',
limit: 5
});
engineers.data.forEach(emp => {
console.log(' -', emp.employee.name);
});
// 3. Pagination example
console.log('
📄 Page 2 of employees:');
const page2 = await api.getPage(2, 3);
page2.data.forEach(emp => {
console.log(' -', emp.employee.name);
});
// 4. Get statistics
console.log('
📊 Employee Statistics:');
const stats = await api.getStats();
console.log('Total employees:', stats.total);
console.log('Employees with projects:', stats.withProjects);
console.log('Total hours logged:', stats.totalHours);
console.log('By department:', stats.byDepartment);
}
// Run the demonstration
demonstrateAPI().catch(console.error);🚀 Performance Tips
- • Use field selection to reduce payload
- • Set appropriate limits for pagination
- • Cache responses when possible
- • Filter before pagination
🛡️ Error Handling
- • Always use try/catch blocks
- • Check response.ok status
- • Handle rate limiting (429)
- • Implement retry logic
💡 Best Practices
- • Use URLSearchParams for parameters
- • Encode special characters
- • Implement request timeouts
- • Log API responses for debugging
📋 Quick Parameter Reference
| Parameter | Example | Description |
|---|---|---|
| filter | ?name=John | Filter by field value |
| sort | ?sort=-name | Sort (ascending/descending) |
| page | ?page=2 | Page number |
| limit | ?limit=10 | Records per page |
| fields | ?fields=id,name | Field selection |
| schema | ?schema=true | Get JSON schema |