List Data Sources
Retrieve all data sources in a bucket.
Endpoint
GET /api/buckets/:bucketId/sources
Authentication
| Key Type | Allowed |
|---|---|
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
| Header | Type | Required | Description |
|---|---|---|---|
X-API-Key | string | ✅ Yes | Your API key (Admin, Write, or Read) |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
bucketId | string | ✅ Yes | The 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
| Field | Type | Description |
|---|---|---|
_id | string | Unique data source identifier |
name | string | Data source name |
type | string | Data source type (e.g., sensor, application) |
description | string | Description of the data source |
schema | object | Schema defining the data structure |
status | string | Status: active or inactive |
createdAt | string | Creation timestamp (ISO 8601) |
updatedAt | string | Last update timestamp (ISO 8601) |
Related Endpoints
- Create Data Source - Create a new data source
- Ingest Data - Send data to a data source