# How to compare 2 values from local data source to api response

**URL:** <https://community.thunkable.com/t/how-to-compare-2-values-from-local-data-source-to-api-response/3561029>\
**Category:** Web API's\
**Created:** [February 12, 2025, 6:39am UTC](https://community.thunkable.com/t/how-to-compare-2-values-from-local-data-source-to-api-response/3561029 "2025-02-12T06:39:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shamirbhuiyan23rp2oy](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@shamirbhuiyan23rp2oy](https://community.thunkable.com/u/shamirbhuiyan23rp2oy)\
**Post date:** [February 12, 2025, 6:39am UTC](https://community.thunkable.com/t/how-to-compare-2-values-from-local-data-source-to-api-response/3561029/1 "2025-02-12T06:39:43Z")

</div>

I want to fill the local data source with the data from the api response but before adding i want to check if 2 values exists or not if 2 values exists in row dont add if not add data

 ![IMG_2421](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/1/1100c6d5eb761435c4c5d5ad493c57dfe5b59bae.jpeg)  
 ![IMG_2420](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/c/eca26e0cc437818baac7fcc7837d4899869a8df4.jpeg)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [February 12, 2025, 7:21am UTC](https://community.thunkable.com/t/how-to-compare-2-values-from-local-data-source-to-api-response/3561029/2 "2025-02-12T07:21:00Z")

</div>

I’m having trouble understanding what you’re trying to do. Can you give some specific examples?

---

<div class="post-metadata">

**Author:** ![shamirbhuiyan23rp2oy](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@shamirbhuiyan23rp2oy](https://community.thunkable.com/u/shamirbhuiyan23rp2oy)\
**Post date:** [February 12, 2025, 7:45am UTC](https://community.thunkable.com/t/how-to-compare-2-values-from-local-data-source-to-api-response/3561029/3 "2025-02-12T07:45:19Z")

</div>

I have an API that sends JSON data containing username, server, port, password, and version. In my local Thunkable database, I have created tables to store this data. I want to sync the API data with my local database while avoiding duplicates. The way I want to validate duplicates is by checking two values: username and server. If an incoming record has the same username and server as an existing record in my database, it should not be synced. How can I implement this validation in Thunkable?

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [February 12, 2025, 8:13am UTC](https://community.thunkable.com/t/how-to-compare-2-values-from-local-data-source-to-api-response/3561029/4 "2025-02-12T08:13:49Z")

</div>

You’ll need to:

1. Get the two values from the API data
2. Get the two values from the local data source
3. Compare each of the two values and if they are not both the same, add the API “row”/record to the local data source

The current API response is:

`[{"username":"Test","server":"astcart.shop","port":25565,"version":"1.20.1","password":"Samir","enabledPlugins":[]},{"username":"Test2","server":"Astcart.shop","port":25565,"version":"1.21.1","password":"77889900","enabledPlugins":["Test"]},{"username":"Samir","server":"Samir","port":"25565","password":"888283","version":"1.21"}]`

You would loop through the array by using a for each item j in app variable bots, like you have in the screenshot. In that loop, check to see if the list of values in the username column of your local data source contains the property “username” of the object j. Also check for the server. Then sync if necessary.

---

<div class="post-metadata">

**Author:** ![shamirbhuiyan23rp2oy](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@shamirbhuiyan23rp2oy](https://community.thunkable.com/u/shamirbhuiyan23rp2oy)\
**Post date:** [February 12, 2025, 8:36am UTC](https://community.thunkable.com/t/how-to-compare-2-values-from-local-data-source-to-api-response/3561029/5 "2025-02-12T08:36:30Z")

</div>

Can you make a example i am a complete beginner to thunkable and i didnt find and example codes online
