{"id":2615,"date":"2022-04-06T07:20:52","date_gmt":"2022-04-06T07:20:52","guid":{"rendered":"https:\/\/www.reloadly.com\/blog\/?p=2615"},"modified":"2022-04-19T10:39:15","modified_gmt":"2022-04-19T10:39:15","slug":"airtime-top-ups-should-you-go-sync-or-async","status":"publish","type":"post","link":"https:\/\/blog.reloadly.com\/blog\/airtime-top-ups-should-you-go-sync-or-async\/","title":{"rendered":"Airtime top-ups: should you go sync or async?"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_46 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"ez-toc-toggle-icon-1\"><label for=\"item-69d2ced803ca5\" aria-label=\"Table of Content\"><span style=\"display: flex;align-items: center;width: 35px;height: 30px;justify-content: center;direction:ltr;\"><svg style=\"fill: #000000;color:#000000\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #000000;color:#000000\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/label><input  type=\"checkbox\" id=\"item-69d2ced803ca5\"><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-visibility-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/blog.reloadly.com\/blog\/airtime-top-ups-should-you-go-sync-or-async\/#What_is_the_difference_between_a_synchronous_and_an_asynchronous_top-up\" title=\"What is the difference between a synchronous and an asynchronous top-up\">What is the difference between a synchronous and an asynchronous top-up<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/blog.reloadly.com\/blog\/airtime-top-ups-should-you-go-sync-or-async\/#When_should_you_prefer_a_synchronous_top-up\" title=\"When should you prefer a synchronous top-up\">When should you prefer a synchronous top-up<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/blog.reloadly.com\/blog\/airtime-top-ups-should-you-go-sync-or-async\/#When_should_you_prefer_an_asynchronous_top-up\" title=\"When should you prefer an asynchronous top-up\">When should you prefer an asynchronous top-up<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/blog.reloadly.com\/blog\/airtime-top-ups-should-you-go-sync-or-async\/#Conclusion\" title=\"Conclusion\">Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n\n<p>When developing an application that relies on Reloadly&#8217;s top-up API sooner or later you&#8217;ll have to make a decision: sync or async.<\/p>\n\n\n\n<p>While both options help in achieving the end goal of providing credit to a recipient mobile phone, the way the operation is performed is different so you need to understand their differences in order to make an informed decision that matches your specific requirements.<\/p>\n\n\n\n<p>Let&#8217;s start exploring those differences.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_is_the_difference_between_a_synchronous_and_an_asynchronous_top-up\"><\/span>What is the difference between a synchronous and an asynchronous top-up<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>There are two main difference between a synchronous and an asynchronous operation:<\/p>\n\n\n\n<ol><li>When you receive an answer from the server<\/li><li>How do you know when your operation has been carried out<\/li><\/ol>\n\n\n\n<p>In the case of the synchronous call you won&#8217;t get an answer until the operation has finished, regardless of the result being success or failure.<\/p>\n\n\n\n<p>In the asyuncrhonous call you&#8217;ll get an immediate response from the server informing you that the operation has started, but that doesn&#8217;t give you any information as to the result of it.<\/p>\n\n\n\n<p>In order to get status updates you must do a polling cycle or implement a webhook.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"When_should_you_prefer_a_synchronous_top-up\"><\/span>When should you prefer a synchronous top-up<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If your application can&#8217;t do anything until the top-up operation has finished you&#8217;ll probably prefer to use a synchronous call.<\/p>\n\n\n\n<p>These usually work well in environments where the concurrency is low.<\/p>\n\n\n\n<p>Check out the documentation to get a better idea on <a href=\"https:\/\/docs.reloadly.com\/airtime\/top-ups\/top-up\" target=\"_blank\" rel=\"noreferrer noopener\">how to use synchronous calls<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"When_should_you_prefer_an_asynchronous_top-up\"><\/span>When should you prefer an asynchronous top-up<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If you&#8217;re in a high concurrency environment you&#8217;ll probably want to maximize parallelism so users don&#8217;t suffer from bottlenecks.<\/p>\n\n\n\n<p>In these scenarios, although a little harder to implement, asynchronous operations are preferrable.<\/p>\n\n\n\n<p>Read <a rel=\"noreferrer noopener\" href=\"https:\/\/docs.reloadly.com\/airtime\/top-ups\/async-top-up\" target=\"_blank\">here<\/a> to get information about how to issue asynchronous calls and <a rel=\"noreferrer noopener\" href=\"https:\/\/docs.reloadly.com\/airtime\/top-ups\/top-up-status\" target=\"_blank\">here<\/a> for how to check the status of previously issued calls.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this post you learned the difference between synchronous and asynchronous topups, their pros and cons and a criteria to choose between them.<\/p>\n\n\n\n<p>Now it&#8217;s your turn to select the best fit for your needs and implement it in your application and, as always, if you need further help you can reach out to us via the usual channels.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When putting together an application featuring airtime topups the choice between sync and async is not a trivial one. Here you can read about the differences between them and how to choose the one that better fits your needs<\/p>\n","protected":false},"author":22,"featured_media":2646,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[274],"tags":[369],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v15.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Airtime top-ups: should you go sync or async? - Reloadly<\/title>\n<meta name=\"description\" content=\"Are you implementing Reloadly&#039;s top-up APIs? Are you having trouble deciding whether to go sync or async? Read this to make the right choice.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.reloadly.com\/blog\/airtime-top-ups-should-you-go-sync-or-async\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Airtime top-ups: should you go sync or async? - Reloadly\" \/>\n<meta property=\"og:description\" content=\"Are you implementing Reloadly&#039;s top-up APIs? Are you having trouble deciding whether to go sync or async? Read this to make the right choice.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.reloadly.com\/blog\/airtime-top-ups-should-you-go-sync-or-async\/\" \/>\n<meta property=\"og:site_name\" content=\"Reloadly\" \/>\n<meta property=\"article:published_time\" content=\"2022-04-06T07:20:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-04-19T10:39:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/blog.reloadly.com\/blog\/wp-content\/uploads\/2022\/04\/blog-image50a-01.png\" \/>\n\t<meta property=\"og:image:width\" content=\"641\" \/>\n\t<meta property=\"og:image:height\" content=\"334\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"2 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.reloadly.com\/blog\/#organization\",\"name\":\"Reloadly\",\"url\":\"https:\/\/www.reloadly.com\/blog\/\",\"sameAs\":[],\"logo\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.reloadly.com\/blog\/#logo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/blog.reloadly.com\/blog\/wp-content\/uploads\/2020\/11\/logo-1.svg\",\"width\":100,\"height\":100,\"caption\":\"Reloadly\"},\"image\":{\"@id\":\"https:\/\/www.reloadly.com\/blog\/#logo\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.reloadly.com\/blog\/#website\",\"url\":\"https:\/\/www.reloadly.com\/blog\/\",\"name\":\"Reloadly\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.reloadly.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/www.reloadly.com\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/blog.reloadly.com\/blog\/airtime-top-ups-should-you-go-sync-or-async\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/blog.reloadly.com\/blog\/wp-content\/uploads\/2022\/04\/blog-image50a-01.png\",\"width\":641,\"height\":334,\"caption\":\"fintech services for superapps\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/blog.reloadly.com\/blog\/airtime-top-ups-should-you-go-sync-or-async\/#webpage\",\"url\":\"https:\/\/blog.reloadly.com\/blog\/airtime-top-ups-should-you-go-sync-or-async\/\",\"name\":\"Airtime top-ups: should you go sync or async? - Reloadly\",\"isPartOf\":{\"@id\":\"https:\/\/www.reloadly.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/blog.reloadly.com\/blog\/airtime-top-ups-should-you-go-sync-or-async\/#primaryimage\"},\"datePublished\":\"2022-04-06T07:20:52+00:00\",\"dateModified\":\"2022-04-19T10:39:15+00:00\",\"description\":\"Are you implementing Reloadly's top-up APIs? Are you having trouble deciding whether to go sync or async? Read this to make the right choice.\",\"breadcrumb\":{\"@id\":\"https:\/\/blog.reloadly.com\/blog\/airtime-top-ups-should-you-go-sync-or-async\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/blog.reloadly.com\/blog\/airtime-top-ups-should-you-go-sync-or-async\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/blog.reloadly.com\/blog\/airtime-top-ups-should-you-go-sync-or-async\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.reloadly.com\/blog\/\",\"url\":\"https:\/\/www.reloadly.com\/blog\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/blog.reloadly.com\/blog\/airtime-top-ups-should-you-go-sync-or-async\/\",\"url\":\"https:\/\/blog.reloadly.com\/blog\/airtime-top-ups-should-you-go-sync-or-async\/\",\"name\":\"Airtime top-ups: should you go sync or async?\"}}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/blog.reloadly.com\/blog\/airtime-top-ups-should-you-go-sync-or-async\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/blog.reloadly.com\/blog\/airtime-top-ups-should-you-go-sync-or-async\/#webpage\"},\"author\":{\"@id\":\"https:\/\/www.reloadly.com\/blog\/#\/schema\/person\/b7f57cdec858524713a40069354fc55b\"},\"headline\":\"Airtime top-ups: should you go sync or async?\",\"datePublished\":\"2022-04-06T07:20:52+00:00\",\"dateModified\":\"2022-04-19T10:39:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/blog.reloadly.com\/blog\/airtime-top-ups-should-you-go-sync-or-async\/#webpage\"},\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/www.reloadly.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/blog.reloadly.com\/blog\/airtime-top-ups-should-you-go-sync-or-async\/#primaryimage\"},\"keywords\":\"airtime top-up\",\"articleSection\":\"Developer Blog\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/blog.reloadly.com\/blog\/airtime-top-ups-should-you-go-sync-or-async\/#respond\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.reloadly.com\/blog\/#\/schema\/person\/b7f57cdec858524713a40069354fc55b\",\"name\":\"Mauro Chojrin\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.reloadly.com\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2e0c52b5f88c4911eeb351e93b0dab9a?s=96&d=mm&r=g\",\"caption\":\"Mauro Chojrin\"},\"url\":\"https:\/\/blog.reloadly.com\/blog\/author\/mauro-chojrin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","authors":[{"term_id":361,"user_id":22,"is_guest":0,"slug":"mauro-chojrin","display_name":"Mauro Chojrin"}],"_links":{"self":[{"href":"https:\/\/blog.reloadly.com\/blog\/wp-json\/wp\/v2\/posts\/2615"}],"collection":[{"href":"https:\/\/blog.reloadly.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.reloadly.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.reloadly.com\/blog\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.reloadly.com\/blog\/wp-json\/wp\/v2\/comments?post=2615"}],"version-history":[{"count":4,"href":"https:\/\/blog.reloadly.com\/blog\/wp-json\/wp\/v2\/posts\/2615\/revisions"}],"predecessor-version":[{"id":2648,"href":"https:\/\/blog.reloadly.com\/blog\/wp-json\/wp\/v2\/posts\/2615\/revisions\/2648"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.reloadly.com\/blog\/wp-json\/wp\/v2\/media\/2646"}],"wp:attachment":[{"href":"https:\/\/blog.reloadly.com\/blog\/wp-json\/wp\/v2\/media?parent=2615"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.reloadly.com\/blog\/wp-json\/wp\/v2\/categories?post=2615"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.reloadly.com\/blog\/wp-json\/wp\/v2\/tags?post=2615"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}