 <pre><code>get_currencies() -&gt; URL = "http://openexchangerates.org", Endpoint = "/api/latest.json?app_id=&lt;myprivateid&gt;", X = string:concat(URL, Endpoint), % io:format("~p~n",[X]). inets:start(), {ok, {_,_,R}} = httpc:request(X), E = jsx:decode(lists_to_binary(R)), Base = proplists:get_value(&lt;&lt;"base"&gt;&gt;,E), Sec = proplists:get_value(&lt;&lt;"timestamp"&gt;&gt;,E), {Days,Time} = calendar:seconds_to_daystime(Sec), Date = calendar:gregorian_days_to_date(Days+719528), Currencies = proplists:get_value(&lt;&lt;"rates"&gt;&gt;,E), fun(C) -&gt; V = proplists:get_value(C,Currencies), {change,Date,Time,Base,C,V} end. </code></pre> <p>and somewhere in your code:</p> <pre><code>GC = get_currencies(), %% you can store GC in an ets, a server state... %% but don't forget to refresh it :o) </code></pre> <p>and use it later</p> <pre><code>{change,D,T,B,C,V} = GC(&lt;&lt;"ZWL"&gt;&gt;), %% should return {change,{2014,8,15},{2,0,12},&lt;&lt;"USD"&gt;&gt;,&lt;&lt;"ZWL"&gt;&gt;,322.355006} </code></pre> <p><strong>[edit]</strong></p> <p>When I use an external application such as jsx (using rebar itself), I use also rebar and its dependency mechanism to create my own application, in my opinion it is the most convenient way. (In other cases, I use also rebar :o)</p> <p>Then I build my application using the OTP behaviors (application, supervisor, gen_server...). It is a lot of modules to write, but some of them are very very short (application and supervisors) and they facilitate the application structure (see <a href="http://www.learnyousomeerlang.com/what-is-otp" rel="nofollow">What is OTP</a> if you are not familiar with this).</p> <p>In your case, my first idea is to have a gen server that build and store the GC anonymous function in its state, each time it get a cast message such as <code>update_currencies</code>, and provide the answer each time it get a call message such as <code>{get_change,Cur}</code> (and maybe refresh GC if it is undefined or out dated).</p> <p>You will also have to decide where the errors will be managed - <em>it may be nowhere: if the gen_server does nothing else but answer to this currency query: if something wrong appears it will crash and be restarted by its supervisor</em> - because this code has many interfaces with the out world and so subject to numerous failures (no Internet access, structure of answer change from site, bad currency request from user...)</p>