Back to API Reference

Data Sources API

Unified management of all connected data sources (Google Sheets, Microsoft Excel, SQL Server).

---

Base URL

https://app.datapublisher.io/api/data-sources

---

Authentication

All endpoints require JWT authentication via Authorization: Bearer header.

---

Overview

The Data Sources API provides:

Supported Source Types:

---

List All Data Sources

Get all connected data sources across all types.

Endpoint: GET /

Headers:

Authorization: Bearer 

Query Parameters:

Response (200 OK):

{

"success": true,

"dataSources": [

{

"id": "uuid-1",

"type": "google-sheets",

"name": "Sales Tracking Spreadsheet",

"status": "active",

"metadata": {

"spreadsheetId": "1ABC-DEF",

"email": "user@gmail.com",

"sheetCount": 3

},

"createdAt": "2026-01-15T10:00:00Z",

"lastUsedAt": "2026-02-12T09:30:00Z",

"lastSyncAt": "2026-02-12T09:00:00Z"

},

{

"id": "uuid-2",

"type": "microsoft-excel",

"name": "Customer Database.xlsx",

"status": "active",

"metadata": {

"workbookId": "01AZJL5P...",

"email": "user@company.com",

"worksheetCount": 5

},

"createdAt": "2026-01-20T14:00:00Z",

"lastUsedAt": "2026-02-11T16:45:00Z",

"lastSyncAt": "2026-02-11T16:00:00Z"

},

{

"id": "uuid-3",

"type": "sql-server",

"name": "Production Database",

"status": "active",

"metadata": {

"server": "sql.company.com",

"database": "SalesDB",

"username": "app_user"

},

"createdAt": "2026-02-01T08:00:00Z",

"lastUsedAt": "2026-02-12T10:15:00Z",

"lastSyncAt": null

},

{

"id": "uuid-4",

"type": "csv",

"name": "imported-customers.csv",

"status": "active",

"metadata": {

"fileName": "imported-customers.csv",

"rowCount": 500,

"columnCount": 12,

"fileSize": 125000

},

"createdAt": "2026-02-10T12:00:00Z",

"lastUsedAt": "2026-02-12T08:30:00Z",

"lastSyncAt": null

}

],

"totalCount": 4,

"byType": {

"google-sheets": 1,

"microsoft-excel": 1,

"sql-server": 1,

"csv": 1

}

}

---

Get Data Source Details

Get detailed information about a specific data source.

Endpoint: GET /:sourceId

Headers:

Authorization: Bearer 

Path Parameters:

Response (200 OK) - Google Sheets:

{

"success": true,

"dataSource": {

"id": "uuid-1",

"type": "google-sheets",

"name": "Sales Tracking Spreadsheet",

"status": "active",

"connectionDetails": {

"spreadsheetId": "1ABC-DEF",

"spreadsheetName": "Sales Tracking 2026",

"email": "user@gmail.com",

"sheets": [

{ "name": "January", "rowCount": 150 },

{ "name": "February", "rowCount": 200 },

{ "name": "Summary", "rowCount": 12 }

],

"tokenExpiry": "2026-02-13T10:00:00Z"

},

"syncConfig": {

"enabled": true,

"frequency": "hourly",

"lastSync": "2026-02-12T09:00:00Z",

"nextSync": "2026-02-12T10:00:00Z"

},

"createdAt": "2026-01-15T10:00:00Z",

"lastUsedAt": "2026-02-12T09:30:00Z"

}

}

Response (200 OK) - SQL Server:

{

"success": true,

"dataSource": {

"id": "uuid-3",

"type": "sql-server",

"name": "Production Database",

"status": "active",

"connectionDetails": {

"server": "sql.company.com",

"database": "SalesDB",

"username": "app_user",

"port": 1433,

"encrypt": true

},

"syncConfig": null,

"createdAt": "2026-02-01T08:00:00Z",

"lastUsedAt": "2026-02-12T10:15:00Z"

}

}

---

Test Connection

Test connectivity to a data source.

Endpoint: POST /:sourceId/test

Headers:

Authorization: Bearer 

Response (200 OK):

{

"success": true,

"status": "active",

"message": "Connection test successful",

"details": {

"responseTime": "45ms",

"lastChecked": "2026-02-12T10:30:00Z"

}

}

Response (500 Internal Server Error) - Failed:

{

"success": false,

"status": "error",

"message": "Connection test failed",

"error": "Invalid credentials or server unreachable"

}

---

Refresh Data Source

Manually refresh data from connected source.

Endpoint: POST /:sourceId/refresh

Headers:

Authorization: Bearer 

Response (200 OK):

{

"success": true,

"message": "Data source refreshed successfully",

"dataSource": {

"id": "uuid-1",

"type": "google-sheets",

"lastSyncAt": "2026-02-12T10:45:00Z",

"rowsUpdated": 15,

"status": "active"

}

}

---

Delete Data Source

Remove a data source connection.

Endpoint: DELETE /:sourceId

Headers:

Authorization: Bearer 

Response (200 OK):

{

"success": true,

"message": "Data source deleted successfully"

}

Note: Deletes connection credentials but preserves previously imported CSV files.

---

Get Connection Statistics

Get usage statistics for all data sources.

Endpoint: GET /stats

Headers:

Authorization: Bearer 

Response (200 OK):

{

"success": true,

"statistics": {

"totalSources": 4,

"activeSources": 4,

"expiredSources": 0,

"errorSources": 0,

"byType": {

"google-sheets": {

"count": 1,

"totalSheets": 3,

"totalRows": 362

},

"microsoft-excel": {

"count": 1,

"totalWorkbooks": 1,

"totalWorksheets": 5

},

"sql-server": {

"count": 1,

"totalDatabases": 1,

"totalTables": 15

},

"csv": {

"count": 1,

"totalFiles": 1,

"totalSize": "125 KB"

}

},

"recentActivity": [

{

"sourceId": "uuid-3",

"type": "sql-server",

"name": "Production Database",

"action": "query_executed",

"timestamp": "2026-02-12T10:15:00Z"

},

{

"sourceId": "uuid-1",

"type": "google-sheets",

"name": "Sales Tracking Spreadsheet",

"action": "data_synced",

"timestamp": "2026-02-12T09:00:00Z"

}

]

}

}

---

Batch Operations

Test All Connections

Test all data sources in parallel.

Endpoint: POST /test-all

Headers:

Authorization: Bearer 

Response (200 OK):

{

"success": true,

"results": [

{

"id": "uuid-1",

"type": "google-sheets",

"name": "Sales Tracking Spreadsheet",

"status": "active",

"testResult": "success"

},

{

"id": "uuid-2",

"type": "microsoft-excel",

"name": "Customer Database.xlsx",

"status": "expired",

"testResult": "token_expired"

},

{

"id": "uuid-3",

"type": "sql-server",

"name": "Production Database",

"status": "active",

"testResult": "success"

}

],

"summary": {

"total": 3,

"success": 2,

"failed": 1

}

}

---

Usage Examples

JavaScript

// List all data sources

async function listDataSources() {

const response = await fetch('https://app.datapublisher.io/api/data-sources', {

headers: { 'Authorization': Bearer ${jwtToken} }

});

const { dataSources } = await response.json();

return dataSources;

}

// Get specific source details

async function getSourceDetails(sourceId) {

const response = await fetch(https://app.datapublisher.io/api/data-sources/${sourceId}, {

headers: { 'Authorization': Bearer ${jwtToken} }

});

return await response.json();

}

// Test connection

async function testConnection(sourceId) {

const response = await fetch(https://app.datapublisher.io/api/data-sources/${sourceId}/test, {

method: 'POST',

headers: { 'Authorization': Bearer ${jwtToken} }

});

return await response.json();

}

// Refresh data source

async function refreshSource(sourceId) {

const response = await fetch(https://app.datapublisher.io/api/data-sources/${sourceId}/refresh, {

method: 'POST',

headers: { 'Authorization': Bearer ${jwtToken} }

});

return await response.json();

}

// Delete source

async function deleteSource(sourceId) {

const response = await fetch(https://app.datapublisher.io/api/data-sources/${sourceId}, {

method: 'DELETE',

headers: { 'Authorization': Bearer ${jwtToken} }

});

return await response.json();

}

---

Best Practices

  • Regular Testing: Test connections periodically (especially OAuth2 sources)
  • Token Expiry: Monitor token expiry dates for Google/Microsoft
  • Error Handling: Handle expired tokens gracefully with re-authentication
  • Source Naming: Use descriptive names for easy identification
  • Cleanup: Delete unused sources to reduce clutter
  • Statistics: Use stats endpoint for dashboard views
  • Batch Testing: Use test-all for health monitoring
  • ---

    Related Documentation