Parsing API responses in Bubble requires understanding how the API Connector maps JSON fields and how to handle nested objects, arrays, and unexpected formats. This tutorial covers initializing API calls to map response structures, accessing nested JSON data in workflows and elements, extracting items from lists, and building error handling for malformed responses.
Overview: Formatting and Parsing API Responses in Bubble
This tutorial explains how to work with API response data in Bubble. You will learn how the API Connector's initialization process maps JSON fields, how to navigate nested objects, how to display API data in Repeating Groups, and how to handle cases where the API returns errors or unexpected formats.
Prerequisites
- A Bubble app with the API Connector plugin installed
- At least one API call configured in the API Connector
- Basic understanding of JSON structure (objects, arrays, key-value pairs)
- Familiarity with Bubble data sources and dynamic data
Step-by-step guide
Initialize an API call to map the response structure
Initialize an API call to map the response structure
In the API Connector, after configuring your API call (URL, method, headers, parameters), click Initialize call. Bubble sends a real request and uses the JSON response to create a field mapping. Each top-level key becomes an accessible field. Nested objects appear as sub-fields accessible with dot notation. Arrays become lists you can iterate over. If the API returns different structures for different requests (e.g., error vs success), initialize with a successful response first, then manually map error fields later. The initialization data becomes part of your app's schema — use sample or non-sensitive data.
Pro tip: If the API response structure changes (new fields added or removed), re-initialize the call. Warning: removing fields may break existing references in your app.
Expected result: The API call is initialized with all response fields mapped and accessible in Bubble's expression editor.
Access nested JSON objects in expressions
Access nested JSON objects in expressions
After initialization, nested JSON objects appear as chained field names in Bubble's expression editor. For example, if the response is {"user": {"name": "John", "address": {"city": "NYC"}}}, you access the city as: API Response's user's address's city. When using the response as a data source in elements, the expression builder shows each nested level as you click through. For deeply nested objects (3+ levels), the expression can get long — consider creating a workflow that extracts key values into custom states for cleaner access throughout the page.
Expected result: You can access any nested field in the API response using chained field references in Bubble's expression editor.
Display API response lists in Repeating Groups
Display API response lists in Repeating Groups
When an API response contains an array (e.g., {"results": [{"name": "Item 1"}, {"name": "Item 2"}]}), set the API call's Use as to Data. In your Repeating Group, set the data source to Get data from an external API → your API call. Bubble treats the array as a list. Inside each cell, reference Current Cell's fields (e.g., Current Cell's API Response's name). If the list is nested inside the response object, you may need to reference it as: API call's results (where results is the array field name). For pagination, pass page or offset parameters to the API call dynamically.
Expected result: API response arrays display as rows in a Repeating Group with individual fields accessible in each cell.
Handle mixed response formats and errors
Handle mixed response formats and errors
APIs may return different structures for success vs error responses. For example, a 200 success might return {"data": [...]} while a 400 error returns {"error": "message"}. In the API Connector, check 'Include errors in response and allow workflow actions to continue.' This prevents your workflow from stopping on API errors. After the API call action, add a condition checking if the error field exists or if the status code indicates failure. Route to error handling — display an error message group, log the error, or retry the call. For robustly handling missing fields, use the :default operator to provide fallback values.
Pro tip: Always check 'Include errors in response and allow workflow actions to continue' in the API Connector for any call that might fail — otherwise your entire workflow stops on an error.
Expected result: Your workflows handle both successful and error API responses without crashing.
Transform API data for display
Transform API data for display
Raw API data often needs formatting before display. Use Bubble's built-in operators to transform data: :formatted as for dates and numbers, :truncated to for long text strings, :find & replace for cleaning text, and :split by for parsing delimited strings. For more complex transformations (e.g., converting Unix timestamps to dates, parsing CSV within a JSON field), create a custom workflow that processes the raw API data and stores the formatted results in custom states or database records. This also serves as a caching layer — display the stored data instead of calling the API on every page load.
Expected result: API data is formatted and displayed in a user-friendly way with proper date formats, number formatting, and text truncation.
Complete working example
1API RESPONSE PARSING REFERENCE2================================34INITIALIZATION:5 API Connector → Configure call → Initialize6 Bubble maps JSON response to typed fields7 Re-initialize when response structure changes89ACCESSING NESTED DATA:10 JSON: {"user": {"name": "John", "address": {"city": "NYC"}}}11 Bubble: API Response's user's name → "John"12 Bubble: API Response's user's address's city → "NYC"1314WORKING WITH ARRAYS:15 JSON: {"results": [{"name": "A"}, {"name": "B"}]}16 Repeating Group data source: Get data from API → Call Name17 Cell reference: Current Cell's name18 Specific item: API Response's results :first item's name19 Count: API Response's results :count2021ERROR HANDLING:22 API Connector: Check 'Include errors in response...'23 Workflow:24 Step 1: API call (Action or Data)25 Step 2: Only when Result of step 1's error is not empty26 → Show error message27 → Log error to database28 Step 3: Only when Result of step 1's error is empty29 → Process successful response3031DATA TRANSFORMATION OPERATORS:32 :formatted as → Format dates/numbers33 :truncated to → Limit text length34 :find & replace → Clean or modify text35 :split by → Parse delimited strings36 :default → Fallback for empty values37 :converted to number → Text to number38 :formatted as date → Text to dateCommon mistakes when formatting API responses for easy parsing in Bubble.io workflows: Step-by-Ste
Why it's a problem: Not re-initializing API calls when the response structure changes
How to avoid: Re-initialize the API call whenever you know the response structure has changed, and update any broken references
Why it's a problem: Not checking 'Include errors in response' on API calls
How to avoid: Check 'Include errors in response and allow workflow actions to continue' in the API Connector for every call that might fail
Why it's a problem: Calling the API on every page load instead of caching results
How to avoid: Cache API responses in your Bubble database and refresh on a schedule or when the user explicitly requests updated data
Best practices
- Initialize API calls with representative sample data to map all possible response fields
- Always enable 'Include errors in response' for production API calls
- Cache API responses in your database to reduce calls and improve page load speed
- Use the :default operator to provide fallback values for fields that may be empty
- Extract deeply nested data into custom states for cleaner access across the page
- Re-initialize API calls when you know the response schema has changed
- Log API errors to a database for monitoring and debugging
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I am working with API responses in Bubble.io and struggling to access nested JSON data. The API returns an object with nested arrays and objects. How do I initialize the call and access deep fields in my Repeating Groups?
Set up an API Connector call that returns a JSON response with nested user data and an array of orders. Initialize it to map all fields. Display the orders in a Repeating Group and show the user's name from the nested object. Add error handling for failed API responses.
Frequently asked questions
How do I access nested JSON fields in Bubble?
After initializing the API call, nested fields appear as chained references: API Response's parent's child's field. Click through each level in the expression builder.
What happens if the API response structure changes?
Existing field references may break. Re-initialize the API call to update the mapping, then fix any broken references in your app.
Can I parse JSON strings stored in text fields?
Bubble does not have native JSON parsing for text fields. To parse JSON text, use a JavaScript-based plugin or send the text to an API endpoint that returns it as structured JSON.
How do I handle API rate limits?
Cache API responses in your Bubble database, use backend scheduled workflows to fetch data at controlled intervals, and add retry logic with increasing delays when rate limit errors occur.
Can RapidDev help with complex API integrations in Bubble?
Yes. RapidDev can configure API Connector calls, handle complex response parsing, build caching layers, and implement robust error handling for any external API integration in your Bubble app.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation