Skip to main content

List Data Sources

Retrieve all data sources in a bucket.

Endpoint

GET /api/buckets/:bucketId/sources

Authentication

Key TypeAllowed
Admin (dakkio_a_)✅ Yes
Write (dakkio_w_)✅ Yes
Read (dakkio_r_)✅ Yes

All key types can list data sources for their respective bucket.

Request

Headers

HeaderTypeRequiredDescription
X-API-Keystring✅ YesYour API key (Admin, Write, or Read)

Path Parameters

ParameterTypeRequiredDescription
bucketIdstring✅ YesThe bucket ID (24-character hex string)

Example Request

curl -X GET "https://api.dakkio.io/api/buckets/507f1f77bcf86cd799439011/sources" \
-H "X-API-Key: dakkio_w_your_write_key..."

Response

Success Response (200 OK)

{
"dataSources": [
{
"_id": "507f1f77bcf86cd799439015",
"name": "Temperature Sensor",
"type": "sensor",
"description": "DHT22 temperature and humidity sensor",
"schema": {
"temperature": {
"type": "number",
"unit": "celsius",
"description": "Temperature reading"
},
"humidity": {
"type": "number",
"unit": "percent",
"description": "Relative humidity"
}
},
"status": "active",
"createdAt": "2024-01-15T10:10:00Z",
"updatedAt": "2024-01-15T10:10:00Z"
},
{
"_id": "507f1f77bcf86cd799439016",
"name": "Pressure Sensor",
"type": "sensor",
"description": "BMP280 barometric pressure sensor",
"schema": {
"pressure": {
"type": "number",
"unit": "hPa",
"description": "Barometric pressure"
}
},
"status": "active",
"createdAt": "2024-01-15T10:15:00Z",
"updatedAt": "2024-01-15T10:15:00Z"
}
]
}

Empty Response (200 OK)

{
"dataSources": []
}

Error Responses

401 Unauthorized

{
"error": "Unauthorized",
"message": "Invalid or missing API key"
}

403 Forbidden

{
"error": "Forbidden",
"message": "API key does not have access to this bucket"
}

404 Not Found

{
"error": "Not Found",
"message": "Bucket not found"
}

Code Examples

JavaScript/Node.js

const axios = require('axios');

async function listDataSources(bucketId) {
const response = await axios.get(
`https://api.dakkio.io/api/buckets/${bucketId}/sources`,
{
headers: {
'X-API-Key': process.env.DAKKIO_WRITE_KEY
}
}
);

return response.data.dataSources;
}

// List all data sources
const sources = await listDataSources('507f1f77bcf86cd799439011');
console.log(`Found ${sources.length} data sources:`);
sources.forEach(s => {
console.log(`- ${s.name} (${s._id})`);
console.log(` Schema: ${Object.keys(s.schema).join(', ')}`);
});

Python

import requests
import os

def list_data_sources(bucket_id):
response = requests.get(
f'https://api.dakkio.io/api/buckets/{bucket_id}/sources',
headers={
'X-API-Key': os.environ['DAKKIO_WRITE_KEY']
}
)

if response.status_code == 200:
return response.json()['dataSources']
else:
print('Error:', response.json())
return []

# List all data sources
sources = list_data_sources('507f1f77bcf86cd799439011')
for source in sources:
print(f"- {source['name']} ({source['_id']})")
print(f" Schema fields: {', '.join(source['schema'].keys())}")

Response Fields

FieldTypeDescription
_idstringUnique data source identifier
namestringData source name
typestringData source type (e.g., sensor, application)
descriptionstringDescription of the data source
schemaobjectSchema defining the data structure
statusstringStatus: active or inactive
createdAtstringCreation timestamp (ISO 8601)
updatedAtstringLast update timestamp (ISO 8601)