Fetch API Data into Your Workspace
Load live JSON data directly from external REST or GraphQL APIs into your DataLensia workspace — no download required.
Last updated:
Instead of downloading a JSON file and re-uploading it every time the data changes, use the API Fetch input to pull live data directly from any HTTP endpoint and load it straight into your workspace.
🚩 The Scenario
You're working with a paginated REST API that returns product data:
GET https://api.example.com/products?page=1&limit=100
Authorization: Bearer <your-token>
You want to explore, filter, and transform the response without copying it into a file every time.
🛠️ Step-by-Step
- Open the Editor (home page workspace).
- In the Data Uploader, switch to the API Fetch tab.
- Enter the endpoint URL:
https://api.example.com/products?page=1&limit=100 - Set the HTTP Method —
GETfor most read operations. - Add Custom Headers as needed:
Authorization: Bearer eyJhbGci...Accept: application/json
- Click Fetch — the response is automatically parsed and loaded into your workspace.
🔐 Authentication Options
The API Fetch input supports three common auth patterns:
| Pattern | Header |
|---|---|
| Bearer Token | Authorization: Bearer <token> |
| API Key | X-API-Key: <key> or Authorization: <key> |
| Basic Auth | Authorization: Basic <base64> |
Add these in the Headers section using the key-value input fields.
🔄 GraphQL Queries
For GraphQL APIs, set the method to POST and include the query in the request body:
{
"query": "{ users { id name email role } }"
}
Add the header Content-Type: application/json and click Fetch. The data field of the GraphQL response is automatically extracted and loaded.
💾 Saving API Configurations
Once you've set up a fetch that works, you can save the API configuration to your workspace. This means:
- The URL, method, headers, and body are stored alongside your data.
- When you reload the workspace, you can re-fetch with one click.
- Configurations are updated whenever you modify and save the workspace.
Steps:
- After a successful fetch, click Save to Workspace.
- Give the workspace a name if it's new.
- Next time you open the workspace, click Re-fetch to get fresh data.
💡 Tips
- CORS errors: If the API doesn't allow browser requests, you may need a CORS proxy or to fetch server-side. Most public APIs with proper CORS headers work fine.
- Nested responses: If the API wraps its data (e.g.,
{ "data": { "items": [...] } }), use the JSON Tree View or Transform Builder to unwrap or flatten it. - Pagination: Fetch one page at a time, or use the Transform Builder with a concat operation to merge multiple pages.
🚀 Try it now
Open the Editor, switch to API Fetch in the uploader, and connect your first live endpoint.