# How to Compare API 1 data and putting logic for API 2 data?

**URL:** <https://community.postman.com/t/how-to-compare-api-1-data-and-putting-logic-for-api-2-data/15222>\
**Category:** Help Hub\
**Created:** [August 21, 2020, 2:25pm UTC](https://community.postman.com/t/how-to-compare-api-1-data-and-putting-logic-for-api-2-data/15222 "2020-08-21T14:25:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![shahbaz.shiekhqa](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@shahbaz.shiekhqa](https://community.postman.com/u/shahbaz.shiekhqa)\
**Post date:** [August 21, 2020, 2:25pm UTC](https://community.postman.com/t/how-to-compare-api-1-data-and-putting-logic-for-api-2-data/15222/1 "2020-08-21T14:25:16Z")

</div>

Hi,

I have two APIs,

One API gets License information for the site 697  
and 2nd api gets Products Activity for site 697 …

How can i make it that if a specific Mock Survey and Tracers with AMP plus CMS Hospital license  
expiration date is \> todays date - 30  
then  
for API 2  
ProductID =3 should be isActive: True else Not…

API 1:

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/8/e/8ef71e7e6ecc87f25d6208e1cd87887ee19a0850.png)

API 2:

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/0/4/04a009a5ab1a2d71501fa4965553e81b194889e2.png)

---

<div class="post-metadata">

**Author:** ![vdespa](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/vdespa/32/2770_2.png) [@vdespa](https://community.postman.com/u/vdespa)\
**Post date:** [August 27, 2020, 1:33pm UTC](https://community.postman.com/t/how-to-compare-api-1-data-and-putting-logic-for-api-2-data/15222/2 "2020-08-27T13:33:30Z")

</div>

You need to set all relevant data in Postman variables.

Do the computations and write a Postman test.

---

<div class="post-metadata">

**Author:** ![shahbaz.shiekhqa](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@shahbaz.shiekhqa](https://community.postman.com/u/shahbaz.shiekhqa)\
**Post date:** [August 28, 2020, 10:00pm UTC](https://community.postman.com/t/how-to-compare-api-1-data-and-putting-logic-for-api-2-data/15222/3 "2020-08-28T22:00:27Z")

</div>

> [@vdespa](#):
>
> Do the computations and write a Postman test.

I do get that but how would i go about with the proper javascript string … and connect it with API2… ?

---

<div class="post-metadata">

**Author:** ![vdespa](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/vdespa/32/2770_2.png) [@vdespa](https://community.postman.com/u/vdespa)\
**Post date:** [August 29, 2020, 4:20pm UTC](https://community.postman.com/t/how-to-compare-api-1-data-and-putting-logic-for-api-2-data/15222/4 "2020-08-29T16:20:03Z")

</div>

Step #1: Did you set the data that you need in Postman variables?

---

<div class="post-metadata">

**Author:** ![jerry-li](https://avatars.discourse-cdn.com/v4/letter/j/439d5e/32.png) [@jerry-li](https://community.postman.com/u/jerry-li)\
**Post date:** [September 1, 2020, 11:54am UTC](https://community.postman.com/t/how-to-compare-api-1-data-and-putting-logic-for-api-2-data/15222/5 "2020-09-01T11:54:39Z")

</div>

Hi @shahbaz.shiekhqa

There are a few things you may need to do to have Postman perform the calculations for you:

1. Check out the article below to understand how to extract and use specific strings from your JSON responses in additional APIs. This article was written by @abhinav: [https://blog.postman.com/extracting-data-from-responses-and-chaining-requests/](https://blog.postman.com/extracting-data-from-responses-and-chaining-requests/)

2. You can use [test scripts](https://learning.postman.com/docs/writing-scripts/test-scripts/) to perform the date calculations in JavaScript after API 1 receives the JSON response. Store the calculation results in [Environment variables](https://learning.postman.com/docs/sending-requests/variables/#variable-scopes).

3. We will need further context and information to understand how to use API 2 to display the appropriate Boolean value for each ProductID.

---

<div class="post-metadata">

**Author:** ![gpub1](https://avatars.discourse-cdn.com/v4/letter/g/f6c823/32.png) [@gpub1](https://community.postman.com/u/gpub1)\
**Post date:** [September 1, 2020, 3:28pm UTC](https://community.postman.com/t/how-to-compare-api-1-data-and-putting-logic-for-api-2-data/15222/6 "2020-09-01T15:28:05Z")

</div>

save your api1 data in variables and use that logic in api2 data [testscripts](https://community.postman.com/t/verify-dynamic-variable-and-body-value-in-test/15023). as mentioned by @jerry-li in 1st point.

---

<div class="post-metadata">

**Author:** ![shahbaz.shiekhqa](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@shahbaz.shiekhqa](https://community.postman.com/u/shahbaz.shiekhqa)\
**Post date:** [September 4, 2020, 9:22pm UTC](https://community.postman.com/t/how-to-compare-api-1-data-and-putting-logic-for-api-2-data/15222/7 "2020-09-04T21:22:30Z")

</div>

I did this for a similar one,  
API 1 -

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/5/a/5a6810e5baefddf1be58a778ee3013145573f031.png)

API2 - Need to verify the variables in API1 - match or = to the same in API2

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/c/a/ca36bbfb9270aa55b767d27729ed7ab5fdd3c46c.png)
