First Api Request
Making Your First API Request
Now that you have your API credentials, let's make your first API request to retrieve data from your Tadabase application. This guide uses simple examples you can try immediately.
What We'll Build
In this tutorial, you'll:
- List all data tables in your application
- Retrieve records from a specific table
- Understand the response format
- Handle common errors
Example 1: List All Tables
The simplest first request is to list all data tables in your application. This helps you find the table IDs you'll need for other operations.
Request
GET https://api.tadabase.io/api/v1/data-tables
Headers:
X-Tadabase-App-id: your_app_id
X-Tadabase-App-Key: your_app_key
X-Tadabase-App-Secret: your_app_secret
Using curl
curl --location 'https://api.tadabase.io/api/v1/data-tables' \
--header 'X-Tadabase-App-id: your_app_id' \
--header 'X-Tadabase-App-Key: your_app_key' \
--header 'X-Tadabase-App-Secret: your_app_secret'
Using JavaScript (fetch)
fetch('https://api.tadabase.io/api/v1/data-tables', {
method: 'GET',
headers: {
'X-Tadabase-App-id': 'your_app_id',
'X-Tadabase-App-Key': 'your_app_key',
'X-Tadabase-App-Secret': 'your_app_secret'
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
Using Python (requests)
import requests
url = "https://api.tadabase.io/api/v1/data-tables"
headers = {
"X-Tadabase-App-id": "your_app_id",
"X-Tadabase-App-Key": "your_app_key",
"X-Tadabase-App-Secret": "your_app_secret"
}
response = requests.get(url, headers=headers)
data = response.json()
print(data)
Expected Response
{
"type": "success",
"data_tables": [
{
"id": "lGArg7rmR6",
"name": "Customers"
},
{
"id": "mH8s2pQtS9",
"name": "Orders"
},
{
"id": "nK9t3qRuT0",
"name": "Products"
}
],
"total_items": 3
}
🎉 Congratulations! You just made your first successful API request. The response shows all tables in your application with their IDs.
Example 2: Get Records from a Table
Now that you have a table ID, let's retrieve records from that table. We'll use the Customers table from the previous example (ID: lGArg7rmR6).
Request
GET https://api.tadabase.io/api/v1/data-tables/lGArg7rmR6/records
Headers:
X-Tadabase-App-id: your_app_id
X-Tadabase-App-Key: your_app_key
X-Tadabase-App-Secret: your_app_secret
Using curl
curl --location 'https://api.tadabase.io/api/v1/data-tables/lGArg7rmR6/records' \
--header 'X-Tadabase-App-id: your_app_id' \
--header 'X-Tadabase-App-Key: your_app_key' \
--header 'X-Tadabase-App-Secret: your_app_secret'
Expected Response
{
"type": "success",
"items": [
{
"id": "5e3f4a2b1c9d8e7f",
"first_name": "John",
"last_name": "Doe",
"email": "john@example.com",
"status": "Active",
"created_at": "2024-01-14 10:30:00"
},
{
"id": "6f4g5b3c2d0e9f8g",
"first_name": "Jane",
"last_name": "Smith",
"email": "jane@example.com",
"status": "Active",
"created_at": "2024-01-15 14:22:00"
}
],
"total_items": 150,
"total_pages": 2,
"current_page": 1,
"limit": 100
}
Understanding the Response
Response Structure
All successful API responses follow this general structure:
| Field | Type | Description |
|---|---|---|
type |
string | Either "success" or "error" |
items |
array | Array of records (for list endpoints) |
item |
object | Single record (for single record endpoints) |
total_items |
number | Total count of records matching query |
total_pages |
number | Number of pages available |
current_page |
number | Current page number |
limit |
number | Records per page |
Response Headers
Pay attention to these response headers - they provide important information:
| Header | Description |
|---|---|
X-RateLimit-Limit |
Your per-minute rate limit |
X-RateLimit-Remaining |
Requests remaining this minute |
X-RateLimit-Reset |
Unix timestamp when limit resets |
Content-Type |
Always application/json |
Adding Query Parameters
You can customize your requests with query parameters. Here are some common ones:
Limit Number of Records
GET https://api.tadabase.io/api/v1/data-tables/lGArg7rmR6/records?limit=10
This returns only 10 records instead of the default 100.
Get a Specific Page
GET https://api.tadabase.io/api/v1/data-tables/lGArg7rmR6/records?page=2&limit=50
This returns records 51-100 (page 2, with 50 records per page).
Select Specific Fields
GET https://api.tadabase.io/api/v1/data-tables/lGArg7rmR6/records?fields=first_name,email
This returns only the first_name and email fields, reducing response size.
Sort Records
GET https://api.tadabase.io/api/v1/data-tables/lGArg7rmR6/records?order=last_name&order_by=asc
This sorts records by last name in ascending order.
Common Errors and Solutions
401 Unauthorized
{
"type": "error",
"msg": "API Not Found",
"status": 401
}
Cause: Invalid API credentials
Solution: Verify your App ID, App Key, and App Secret are correct
404 Not Found
{
"type": "error",
"msg": "Table Not Found",
"status": 404
}
Cause: Invalid table ID in the URL
Solution: Use the /data-tables endpoint to get correct table IDs
429 Too Many Requests
{
"type": "error",
"msg": "Too Many Attempts In Minute",
"status": 429
}
Cause: Exceeded rate limit
Solution: Wait for the rate limit to reset (check X-Retry-After header)
Testing with the API Tester
Instead of writing code, you can test these requests in our built-in API Tester:
- Go to /api in your Tadabase instance
- Enter your API credentials (they'll be saved in your browser)
- Select
GET /api/v1/data-tablesfrom the dropdown - Click "Send Request"
- View the response
The API Tester is perfect for:
- Testing endpoints before writing code
- Debugging API issues
- Exploring your data structure
- Exporting requests as curl or Postman collections
Next Steps
Now that you can make basic API requests, let's learn about the different authentication methods available:
→ Authentication Methods Explained
Understand API key authentication vs. bearer token authentication, and when to use each.
Complete Working Example
Here's a complete Node.js script you can run to list tables and fetch records:
const axios = require('axios');
const API_BASE = 'https://api.tadabase.io/api/v1';
const headers = {
'X-Tadabase-App-id': 'your_app_id',
'X-Tadabase-App-Key': 'your_app_key',
'X-Tadabase-App-Secret': 'your_app_secret'
};
async function getTables() {
try {
const response = await axios.get(`${API_BASE}/data-tables`, { headers });
console.log('Tables:', response.data.data_tables);
return response.data.data_tables;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
}
}
async function getRecords(tableId) {
try {
const response = await axios.get(
`${API_BASE}/data-tables/${tableId}/records`,
{ headers }
);
console.log(`Records from table ${tableId}:`, response.data.items);
return response.data.items;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
}
}
// Run the examples
(async () => {
const tables = await getTables();
if (tables && tables.length > 0) {
await getRecords(tables[0].id);
}
})();
Save this as test-api.js, install axios (npm install axios), update the credentials, and run with node test-api.js.
We'd love to hear your feedback.