How to retrieve a single field value using Bubble's API Connector?

I’m trying to retrieve a specific field value from an external API using Bubble’s API Connector. I followed the steps outlined in the Bubble documentation to set up the API call, but I’m only able to get a response that includes the full object with all its fields, like this:

    "_id": "1679577724774x977674034345263800",
    "Created By": "admin_user_integrity_test",
    "Created Date": "2023-03-23T13:22:04.774Z",
    "Modified Date": "2023-03-23T13:22:04.823Z",
    "__upright_height_number": 5,
    "accubend_number": 234324,
    "cnc_cad_number": 3243,
    "job_setup_number": 232,
    "pre_assembly_number": 3,
    "minutes_number": 32,
    "uv_printer_number": 32,
    "vinyl_number": 32,
    "Slug": "32"

Is there any way to extract just the value of a specific field, like “cnc_cad_number”, directly from the server using the API Connector? Or do I have to resort to extracting the field using JavaScript?
I have set up the API call to include the specific field name in the path parameter, but it seems like the API does not support retrieving a single field value directly from the server.

Any help or advice would be greatly appreciated. Thank you!

You always get the full object. When some field is not visible because of privacy rules you should still get the property in the object but with an empty value.

1 Like

Thank you for the response, dorilama.

I understand that I will always receive the full object, but my issue is that I only need to retrieve a specific field value, like “cnc_cad_number”, and not the entire object. Is there a way to extract just that field value from the object, or do I have to resort to using JavaScript to parse the response body and extract the value?

Thanks again for your help.

If you are calling the data API using the API connector then you have access to the properties of the object as usual.
When you initialize the call bubble creates a data type with the response data so that you can use it in the editor.

1 Like

Thank you @dorilama for your response.

I understand that I can access the properties of the object as usual when calling the data API using the API Connector in Bubble. I’ll take a look at the data type that Bubble creates with the response data and see if I can modify which field gets extracted using the properties of the object.

Thanks for your help!

Technically I could ignore all the fields I don’t want.

But then that wouldn’t allow me to be as flexible or dynamic.
I will continue to try more methods.

I could limit the field if I used it as data.
But that won’t work for me, because I need it to be more dynamic.

But then that wouldn’t allow me to be as flexible or dynamic.
I will continue to try more methods.

So what are you trying to do?

More methods for what exactly?

I really don’t see the problem here.
Bubble returns all the properties when you make a request to the data API, there is nothing to do about it.
The data you need is easily accessible from the editor when you build an expresion.
If your objective is to return only a single text you need to have a proxy between your frontend and the bubble’s data API to transform the response.

1 Like

Thank you, @adamhholmes and @dorilama , for your responses.
To clarify my use case, I’m building a product builder in where users can select from a list of products made of items kept in an inventory list. I want users to be able to customize inputs such as height, width, depth, and quantity, and have the system calculate the price of the materials in the component by multiplying them with their unit of measure. For example, a screw is a unit, and aluminum tubing is linear ft (LNFT). I want users to be able to change the amount of units based on a spreadsheet and multiply them by any input. I need to pull a single field from the spreadsheet and multiply certain things by that field.

I think I have found a way to do what I wanted by running some JavaScript.

  .then(response => response.json())
  .then(data => {
    const cncCadNumber = data.response.cnc_cad_number;
    console.log(cncCadNumber); // prints the value of the cnc_cad_number field
  .catch(error => console.error(error));

Thank you all for your help in answering my question. I’m now realizing that the solution I was considering may not work for me after all. I don’t think there is a way for a user to add a new column to the database on the front end, which shatters the structure I was looking to achieve. I’ll explore alternative structures to solve this problem instead.

Thanks again for your help and suggestions!

I still don’t understand what the issue is here?

Just access the data you need from the API call, and do what you need to do with it…

What exactly is the problem you’re having?

I’ve realized that the structure I was considering may not work for me after all. The issue is that I need to allow users to add new columns to their spreadsheet, and the current structure I had would require them to add columns to the database. From what I understand, this would be impossible to do on the frontend.
So, I may come back to pulling data with an API call in the future, but for now, I need to explore alternative structures to solve this problem instead.

Are you talking about Bubble?..

Or some external service you’re using to do this?

Yes, I’m using Bubble to build a service that runs on Bubble, but the end-user won’t need any knowledge of Bubble to use the custom product builder. The goal is to make it as user-friendly as possible, similar to how Bubble is run on JavaScript but without requiring users to know JavaScript.

In an ideal world, I would skip the Bubble part and build the software using JavaScript.

The reason I was trying to use the Bubble API Connector instead of just searching for the data in a workflow is because there is no way to define what type of data you want to search on the frontend outside of an API.