Inflation API
Overview
Inflation API allows showing inflation data and calculating inflation rates for custom periods from other websites, blogs or applications for all countries we have data for. For example, you can host your own inflation calculator on your website which will be using our always up to date data and logic.
Inflation API is provided using different protocols / standards - json, jsonp, xml(soap)
Terms of Use
Inflation api is provided free of charge and can be used from other websites, blogs and applications if the following conditions are met:
- Non-commercial use
- Link to the original source at statbureau.org is provided. Example: <a href = "https://www.statbureau.org" >www.statbureau.org</a>
Services
The following methods are available:
decimal CalculateInflationRate(string country, DateTime start, DateTime end)
The method allows calculating inflation rate (percentage) between the start of the first month and end of the second for a given country.
- country - the code of the country (belarus, brazil, canada, european-union, eurozone, france, germany, greece, india, japan, kazakhstan, mexico, russia, spain, turkey, ukraine, united-kingdom, united-states)
- start - the first month, inclusive
- end - the last month, inclusive
- returns inflation rate, decimal, percentage
decimal CalculatePriceChange(string country, DateTime start, DateTime end, decimal amount, List<DateTime> denominationsToApply)
The method allows calculating the price change due to inflation between the start of the first month and end of the second for a given country.
- country - the code of the country (belarus, brazil, canada, european-union, eurozone, france, germany, greece, india, japan, kazakhstan, mexico, russia, spain, turkey, ukraine, united-kingdom, united-states)
- start - the first month, inclusive
- end - the last month, inclusive
- amount - the price in the beginning of the first month
- denominationsToApply - a list of denominations that need to be applied, set to null if none are needed
- returns the price in the end of the second period, adjusted to the inflation, decimal
decimal CalculateValueChange(string country, DateTime start, DateTime end, decimal amount, List<DateTime> denominationsToApply)
The method allows to determine the change of the money purchasing power due to inflation between the start of the first month and end of the second for a given country.
- country - the code of the country (belarus, brazil, canada, european-union, eurozone, france, germany, greece, india, japan, kazakhstan, mexico, russia, spain, turkey, ukraine, united-kingdom, united-states)
- start - the first month, inclusive
- end - the last month, inclusive
- amount - amount in the beginning of the first month
- denominationsToApply - a list of denominations that need to be applied, set to null if none are needed
- returns the amount in the end of the second period, adjusted to the inflation, decimal
List<Denomination> GetDenominations(string country)
Returns a list of denominations that happened in the given country.
List<MonthlyInflation> GetData(string country)
Returns the full dataset of monthly inflation rates from the very begining to now, month over month.
Json/Jsonp
The list of json addresses:
- /calculate-inflation-rate-json
- /calculate-inflation-price-json
- /calculate-inflation-value-json
- /get-denominations-json
- /get-data-json
The list of jsonp addresses:
- /calculate-inflation-rate-jsonp
- /calculate-inflation-price-jsonp
- /calculate-inflation-value-jsonp
- /get-denominations-jsonp
- /get-data-jsonp
Json and jsonp methods also support a parameter named 'format' which formats the output to the currency standard.
Xml/SOAP (Deprecated)
The methods are also available with the Xml/SOAP protocol at https://www.statbureau.org/WebServices/InflationService.svc and Wsdl with the definition is located here.
Support for Xml/SOAP is going to be phased out in favor of Json/JsonP
Example
Below goes a naive, but working example that can be reused on any other external website or blog to calculate the price changes. The example uses jquery javascript library to invoke a jsonp service on button click.
The unstyled output of the above code is provided below. You can also use js fiddle to try the code: example.
Feedback
For the feedback, please see the About page