{"id":1441,"date":"2024-12-12T20:22:42","date_gmt":"2024-12-12T15:22:42","guid":{"rendered":"https:\/\/obsidianeducation.wordpress.com\/?page_id=1441"},"modified":"2026-03-03T18:14:33","modified_gmt":"2026-03-03T18:14:33","slug":"app-inventor-currency-converter-no-extension-currency-converter-app-inventor","status":"publish","type":"page","link":"https:\/\/obsidiansofteducation.com\/index.php\/app-inventor-currency-converter-no-extension-currency-converter-app-inventor\/","title":{"rendered":"App Inventor Currency Converter (NO EXTENSION | Currency Converter App Inventor"},"content":{"rendered":"\n<p class=\"has-medium-font-size\">Hello friends,<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Welcome to Obsidian Soft<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjmLQZt9W09lsu4WQPvMf3vJ2LSE5TvRyFmmex4dCwzv7f5ykCFFHrxWz5N2hd9GMzeVNvuSBF-9sXRj28kIO8Jz9TGl92F0GygXdNHioqqRbFOxAhXsMjmJVXQeTpN6RQIJkRZQnYAsIBp9VmlZjJ1CnhaIERFqHSXpDd2aLNaOetPh0GL3YJKoNOWpUE\/s1280\/maxresdefault.webp\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/1_maxresdefault.jpg\" alt=\"\"\/><\/a><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">Let&#8217;s make a simple but accurate Currency Converter app today.<br>First, we need to use a free API to get exchange rates. <a href=\"https:\/\/www.exchangerate-api.com\/docs\/overview\" target=\"_blank\" rel=\"noopener\">https:\/\/www.exchangerate-api.com\/docs\/overview<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Click on Get Free key button and provide your email address<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Check your email and go to the authentication link. Copy the FREE key.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/chrome_a3QsO7x00d.png\" alt=\"\"\/><\/figure>\n\n\n\n<p><a href=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEiV-01Bk44ONhh3-qaUTQKYq7S_GNSPypMcAiYQLkwtW7GHGMac6efUKl7WQ5HGTU5tx8-x7hwSWNIyDWBCx9upu1C0FAObSFuFfzmh7MLCsO_uo_iDXAFHmOBCnewNX9z6BqH-o2-jMLkmEZbRGdN9tYlLCtRX87QIltq7yA_rjg8JmTgR-_FT-j1L9xw\/s1920\/chrome_a3QsO7x00d.png\" target=\"_blank\" rel=\"noopener\"><\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Remember that this free API key will have limited usage and if you want to publish this app to the Play Store, you must get a proper billing plan.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Now, click on Standard API Requests on the left under the Documentation heading:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/1_chrome_a3QsO7x00d.png\" alt=\"\"\/><\/figure>\n\n\n\n<p><a href=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEga6lTWoO7Kz5xL_0_w71MOSdj_8_y-PwJ99jp-M301UH9DXIIpgzXORUdHZxDvHvJu0cD5oOxvuk_8YsvreIMXaORiCSUT7jDes5jxab_BCQIh1gj83_B8pGzZzcoFY_4mtIj459iUi3uLcQ2Ja4tbOsDl2svfRTeobPiyY3avQrCExyzdNEluqeSphUU\/s1920\/chrome_a3QsO7x00d.png\" target=\"_blank\" rel=\"noopener\"><\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Look at the standard response: A simple dictionary object with key-value pairs.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/chrome_rfrWZSSzFZ.png\" alt=\"\"\/><\/figure>\n\n\n\n<p><a href=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEhKmf4xXoy3UoYDhEZ9QFDqU6gCE-uC28vt3aW2-MSflMq_ew1j-5iEVji6mHhgfHTspqhx9Fwq9oIn-lU9N0KXeqfeAIFOKLw7zk6aVWETaBYOx6AeBNxJxbFlLeK_Sq2ZAJZIUkwrHsMyKCEiHu_R-xjQ8HeOmtlM0wdISpWTkQYZfREp4n_GsixT75o\/s1031\/chrome_rfrWZSSzFZ.png\" target=\"_blank\" rel=\"noopener\"><\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size\">You will notice that against the key: conversion_rates, we are getting another dictionary where keys are 3 lettered currencies and the value is the exchange rate relative to USD\u2026very very easy JSON so keeping all this in mind, let\u2019s proceed to MIT App inventor and start a new project and call it CurConverter.<br>I am going to make a simple screen so that I have more time to focus on the code. For screen1, in its properties, make align horizontal and align vertical both center. Make the background color white.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Drag and drop a text box from the User Interface palette onto the viewer. Rename it to amountTxt. Make font bold, font size 20 and change hint to \u201cEnter amount:\u201d Also, turn on the numbers only checkbox as the amount to be converted is a number.<br>Drag and drop a spinner from the User Interface onto the viewer below the text box. Rename it to fromSpinner.<br>Drag and drop another spinner below it. Rename it to toSpinner.<br>Drag and drop a button from the user interface below the second spinner. Rename it to convertBtn. Make the background color: orange, font bold, font size: 20, and shape rounded. Change the text on it to Convert. Drag and drop a label from the user interface below this button. Rename it to convertedAmount. Make its font bold and font size: 25. Remove all text from it.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">From the Connectivity palette, drag and drop a web component onto the viewer.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Our Screen design is done so let\u2019s go to the blocks section.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Make a global variable for our api key.<br><img loading=\"lazy\" decoding=\"async\" height=\"40\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXcJhT27byyavECpg_-ZeAIyn1vR9EToPhI_JPfH7PjLxNu3m6kWw-LqW8mrA9fbJ0JfYYCTYjsupyLeSQwdLGhT8FisxWfZSepBOFO9HiPmg7hNmKm3zVrK649_9MeLw_xecYdFix54JNDgaCa-Zp7Wp1sBw640-h40keyszJMdvsnMs9oucF8QMJT8g.png\" width=\"640\"><br>Copy the key from the exchangerate-api page.<br>And paste it here. Please don\u2019t use my key. Kindly get your own.<br>Make a global variable for currencies. This is an empty list.<br><img loading=\"lazy\" decoding=\"async\" height=\"43\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXc8_9bW4pRQwHdkohAOmHDcnmrY5ka1zv99VUSV4_UVTCBiEhd7dyp80IbVdRrg5ICFUI9XIIa1cL6-fPNhctiWko1J1sQhUJeJyrsYymP7R4RVLyoeeIqQsV5qbqdnSetGhqrwU3LN-P02YuUAQZmlYQcWw640-h43keyszJMdvsnMs9oucF8QMJT8g.png\" width=\"640\"><br>Make a global variable for exchange rates. This is an empty dictionary.<br><img loading=\"lazy\" decoding=\"async\" height=\"37\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXfyrJr9lq3BrxsQIxbh_TpbxwQ6UPzo82PA3DqU1lKabP13Sxf6oU82T_g6DB0mrz54U3vMK8K9lOTaO3oXsuWiE8Qmqm1xHkkBm8I31HbmfYSHqBJHKdEbEMZ816I2N5Hv0H9eqcudZN8WeRBs-PHYw80w640-h37keyszJMdvsnMs9oucF8QMJT8g.png\" width=\"640\"><br>Now, get the screen1\u2019s initialize event where we will make our api request to get data. Be very careful while constructing the link. Copy the example from the exchange rate page and break it down into 3 parts.<br><img loading=\"lazy\" decoding=\"async\" height=\"154\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXeOcfpjxoq3Zg7G0ggoIN0Y0yz1Zez9xdkWbo5QU9HMbpR5rdhNMD6UnGa7yTIqlcDh7-S9BnHf06Qpa1Ja_4UMCYS6xLV8CqBZGezbgRnZF7hWSLARlSc80cHW1G5si5Ijkf8CpwlIJBy7ogR2ekLOupMHw640-h154keyszJMdvsnMs9oucF8QMJT8g.png\" width=\"640\"><br>After setting the url for the Web component, call its Get procedure.<br>This call will trigger the Web\u2019s GotText event when some response is received from the server.<br>First, make a local variable called decodedDict and give it the decoded json from the response content.<br><img loading=\"lazy\" decoding=\"async\" height=\"117\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXdv3LDCEeylPFNTVQ4h6LNzZ0ZhufopuM8QM5ZaC_iIj6ULmRpe_lmThKdrs9ewCrMi9g8a93A6GUeyMnIvH2Jc2Q-jxiKMQAru9ooQLuHMGjW80LYhVTZE7L5FAWMFOWm_M3km-NCYO04j-lcb7NZUciZWw640-h117keyszJMdvsnMs9oucF8QMJT8g.png\" width=\"640\"><br>Now, we have to check if we get a successful response from the server. This we can know if we look at the value for the key \u201cresult\u201d inside our decoded dictionary i.e. responseDic<br><img loading=\"lazy\" decoding=\"async\" height=\"197\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXfi7ssBwqhDogIjhvanfLIzWsf4eoinJn9yHA5qZhR64oFTMCexWhaTJ9yBwZdd25PhgyJilAn4pp-gzUHoJXsPowTjQly_alIcoDAC3yMxz2qyUWi6JncgvCtjqkx6Sh8KXx8QMOc6BycCLawjUCEYe69Zw640-h197keyszJMdvsnMs9oucF8QMJT8g.png\" width=\"640\"><br>If it is equal to success, we are going to get the dictionary against key: \u201cconversion_rates\u201d and set it to our global exchangeRates variable.<br><img loading=\"lazy\" decoding=\"async\" height=\"242\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXczS5gnegqp-PlJKec5_8UuSeqbt5sWqId2VYJf8iOS8cEJTNvQxY3ELC7-8X4tZworrLYuFrVF0PYDcfUlINi3trdmkgDbTWuJTFU6-OnRn_7urDowprreN38RTUsC-a0ysT7KAfTuivJDM5Umbbnwh8d-w640-h242keyszJMdvsnMs9oucF8QMJT8g.png\" width=\"640\"><\/p>\n\n\n\n<p class=\"has-medium-font-size\"><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Now, here comes the interesting part:<br>Our exchangeRates variable is a dictionary with keys containing currencies and the corresponding values are the exchange rates. So, if we get only the keys from this dictionary, we have our list of currencies.<br>So, set the currencies global variable to the keys in our exchangeRates dictionary and provide this currencies list as elements to our two spinners.<br><img loading=\"lazy\" decoding=\"async\" height=\"302\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXcI4VdCeTfhKT_m_F0LkKQQnAM5wjd07KGZcmd7NdhMyEEhXEAc-KbxfGDIhSOZ8k6BFudVZ1EJQUZ0s0J0TDesBc0j29T6LtEY1WXNi16QMUcardzN9VWKj1FCfkkDbOalZItfReQSE3VhHgwZrYfZNPOBw640-h302keyszJMdvsnMs9oucF8QMJT8g.png\" width=\"640\"><br>If the app is used without being connected to the internet, we will get an error with code 1101.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">We can handle this error gracefully by getting the screen\u2019s error occurred event and if the code is 1101, we can disable the convert button and show an error message in our label.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><img loading=\"lazy\" decoding=\"async\" height=\"197\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXeEav4nlQBhIigeAPnVcRVrPpO0f15ZhsOT2Yw8Ury7UTrsW68YKoOSSWvX_Rm0AB4CiZl7da6FA10haUbxAxW84bbsXMOmrGxmjQc154kJGxOxCL-933eAVl_y2rN-uW3cIh52Knz1l8K7Jtdj71IKgl8w640-h197keyszJMdvsnMs9oucF8QMJT8g.png\" width=\"640\"><br>Now, let\u2019s work on our convert button but first remember that we are getting all interest rates relative to the US dollar so if the user wants to convert an amount from some other currency then we need to do some more calculations.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">For example, I want to convert \u00a350 into Saudi Riyals (SAR).<br>I need to first figure out how many US Dollars (USD) the British Pounds are worth.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Assume the API returns the following rates:<br><strong>usdToGbp = 0.76 (1 USD = 0.76 GBP)<br>usdToSar = 3.75 (1 USD = 3.75 SAR)<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\"><br><strong>1. Convert GBP to USD:<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">To find how much USD you get for 1 GBP, use: 1\u00f7usdToGbp=1\u00f70.76=1.31581<\/p>\n\n\n\n<p class=\"has-medium-font-size\">This means 1 GBP = 1.3158 USD.<br><strong><br>2. Convert USD to SAR:<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Now, multiply this USD value by the usdToSar rate (since we already have the USD-to-SAR rate): 1.3158\u00d73.75=4.9343<\/p>\n\n\n\n<p class=\"has-medium-font-size\">So, 1 GBP = 4.9343 SAR.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>3. Multiply by the Amount in GBP:<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">If the user wants to convert \u00a350, multiply the conversion rate by 50: 50\u00d74.9343=246.71550<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Therefore, \u00a350 = 246.71 SAR.<br>So, the final formula is<\/p>\n\n\n\n<p class=\"has-medium-font-size\">convertedAmount =<\/p>\n\n\n\n<p class=\"has-medium-font-size\">(1\u00f7usdToGbp) x usdToSar x enteredAmount<\/p>\n\n\n\n<p class=\"has-medium-font-size\">So, let\u2019s work on the convert button. First, do some error handling that the user has entered some amount:<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><img loading=\"lazy\" decoding=\"async\" height=\"173\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXe3U-jJlc3wYfEtD2l6YCaQ6IQ7vNbQdXa2c6dEtW3I05r4bRZSA6PESVyV81nuqyNlmI_Tuv828jY54lX8rsSi7Ehk4Iw4KZKylGLxoInvJVa7aY9PeLgcWzxYgjrOZaataQEiMFq5L2xnlqRj2BVrebUow640-h173keyszJMdvsnMs9oucF8QMJT8g.png\" width=\"640\"><br>Next, make a local variable amount and set it to 0.<br>And then, use the formula explained above:<br>We will use the selection from the fromSpinner and use it as a key and look for the exchange rate corresponding to it in our exchange rates dictionary. This will get us our \u201cfrom currency\u201d rate. We will do same for toSpinner to get the \u201cto currency\u201d rate.<br><img loading=\"lazy\" decoding=\"async\" height=\"141\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/AD_4nXc4f-8se4tejyeZia2rYqk10G_F8hvWW-Sn4kXXeiYfUqGbURf020X6PJl413cFwpkPjOS7mRoGjKwq3GU6DA1yhiPhgfVGw4TbBLONjG29hhox0R1poM_40S7JWbKgEMIovYn290W5K1LOkxEk2z98EorWw640-h141keyszJMdvsnMs9oucF8QMJT8g.png\" width=\"640\"><\/p>\n\n\n\n<p class=\"has-medium-font-size\">So, this is done. I hope you like this video. Have fun coding this app for your school or college projects or just for fun to impress your friends.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">You can have a look at the video tutorial here:<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<p class=\"responsive-video-wrap clr\"><iframe loading=\"lazy\" title=\"App Inventor Currency Converter (NO EXTENSION | Currency Converter App Inventor\" width=\"1200\" height=\"675\" src=\"https:\/\/www.youtube.com\/embed\/SrqC74hrzH4?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<\/div><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">Please like my videos and share them with your friends and family. Also, subscribe to my channel and press the bell icon so you don&#8217;t miss any of the great projects I have planned for you.<a href=\"https:\/\/www.blogger.com\/blog\/page\/edit\/4947000819484484884\/7140650632339107612#\" target=\"_blank\" rel=\"noopener\">https:\/\/www.youtube.com\/c\/obsidiansofteducation<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Please like my social media pages for more educational resources and tips.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Facebook:<a href=\"https:\/\/www.blogger.com\/blog\/page\/edit\/4947000819484484884\/7140650632339107612#\" target=\"_blank\" rel=\"noopener\">&nbsp;https:\/\/www.facebook.com\/ObsidianSoft\/<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Instagram:<a href=\"https:\/\/www.blogger.com\/blog\/page\/edit\/4947000819484484884\/7140650632339107612#\" target=\"_blank\" rel=\"noopener\">&nbsp;https:\/\/www.instagram.com\/obsidiansoftapps\/<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Pinterest:<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-pinterest wp-block-embed-pinterest\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"oceanwp-oembed-wrap clr\"><iframe loading=\"lazy\" title=\"Obsidian Soft\" src=\"https:\/\/assets.pinterest.com\/ext\/embed.html?grid=obsidiansoft&#038;src=oembed\" height=\"900\" width=\"450\" frameborder=\"0\" scrolling=\"no\" ><\/iframe><\/div>\n<\/div><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">For links to free educational apps, have a look at the&nbsp;<a href=\"https:\/\/www.blogger.com\/blog\/page\/edit\/4947000819484484884\/7140650632339107612#\" target=\"_blank\" rel=\"noopener\">educational apps page<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello friends, Welcome to Obsidian Soft Let&#8217;s make a simple but accurate Currency Converter app today.First, we need to use a free API to get exchange rates. https:\/\/www.exchangerate-api.com\/docs\/overview Click on Get Free key button and provide your email address Check your email and go to the authentication link. Copy the FREE key.&nbsp; Remember that this [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1441","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages\/1441","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/comments?post=1441"}],"version-history":[{"count":2,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages\/1441\/revisions"}],"predecessor-version":[{"id":6882,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages\/1441\/revisions\/6882"}],"wp:attachment":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/media?parent=1441"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}