{"_id":"566b5afcec4a320d00a8ca76","editedParams":true,"version":{"_id":"55312174c68f493900aebb42","project":"55312174c68f493900aebb3f","__v":10,"createdAt":"2015-04-17T15:06:28.598Z","releaseDate":"2015-04-17T15:06:28.598Z","categories":["55312175c68f493900aebb43","566b431d03b4b20d00d02c3a","566b58f212bc0517005d3068","566b59110506f40d0034f148","566b7cc94d1a4d0d00801c00","566b82d130cdb417008d217d","566b855b4d1a4d0d00801c04","566b856f03870a0d008ee7a7","566c42d2f0a5dc0d009acbab","566c443d85dc790d0062c134"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"0.7.0","version":"0.7"},"category":{"_id":"566b59110506f40d0034f148","__v":5,"pages":["566b5afcec4a320d00a8ca76","566b63213d25d00d0066b00a","56a47942e5e9190d00ad6200","56a480315fb2530d00421b75","56a489ae9093960d00f9ab31"],"project":"55312174c68f493900aebb3f","version":"55312174c68f493900aebb42","sync":{"url":"","isSync":false},"reference":true,"createdAt":"2015-12-11T23:15:29.864Z","from_sync":false,"order":2,"slug":"extra-parameters","title":"Extra Parameters"},"editedParams2":true,"user":"5531215e29603d2300011341","__v":3,"project":"55312174c68f493900aebb3f","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-12-11T23:23:40.339Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","examples":{"codes":[]},"auth":"required","params":[{"_id":"566b5afcec4a320d00a8ca77","ref":"","in":"body","required":false,"desc":"","default":"USD","type":"string","name":"base"},{"_id":"566cabbef0a5dc0d009acbc6","ref":"","in":"body","required":false,"desc":"","default":"","type":"string","name":"app_id"}],"url":"/latest.json"},"isReference":true,"order":0,"body":"[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Pro Feature\",\n  \"body\": \"Changing Base Currency is currently available for clients on the Developer, Enterprise and Unlimited plans.\"\n}\n[/block]\nAny currency can be chosen as a base currency when requesting the latest rates, as well as historical rates and time-series (where available).\n\nThe base currency should be requested with its 3-digit ISO code (see our list of available API currencies if in doubt).\n\nResults will be delivered relative to 1 unit of the currency you have requested.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Basic Request & Response*\"\n}\n[/block]\nAppend the `base` query parameter to your API request, along with the required 3-digit ISO currency code or symbol, like so (for Euros):\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"https://openexchangerates.org/api/latest.json\\n    ?app_id=[[app:app_id]]\\n    &base=EUR\",\n      \"language\": \"http\",\n      \"name\": \"HTTP\"\n    },\n    {\n      \"code\": \"$.get('https://openexchangerates.org/api/latest.json', {app_id: '[[app:app_id]]', base: 'GBP'}, function(data) {\\n    console.log(data);\\n});\",\n      \"language\": \"javascript\",\n      \"name\": \"jQuery\"\n    }\n  ]\n}\n[/block]\nThe response format is exactly the same as the standard API response, with all rates in the `rates` object given relative to 1 standard unit of your requested `base` currency:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n    disclaimer: \\\"https://openexchangerates.org/terms/\\\",\\n    license: \\\"https://openexchangerates.org/license/\\\",\\n    \\\"timestamp\\\": 1424127600,\\n    \\\"base\\\": \\\"EUR\\\",\\n    \\\"rates\\\": {\\n        \\\"AED\\\": 4.626447,\\n        \\\"AFN\\\": 61.002415,\\n        \\\"ALL\\\": 137.92617,\\n        /* ... */\\n    }\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Basic Code Samples\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.get('https://openexchangerates.org/api/latest.json', {app_id: '[[app:app_id]]', base: 'UGX'}, function(data) {\\n    console.log(\\\"1 Ugandan Shilling equals \\\" + data.rates.JPY + \\\" Japanese Yen\\\");\\n});\",\n      \"language\": \"javascript\",\n      \"name\": \"jQuery\"\n    },\n    {\n      \"code\": \"More code samples are on their way! Please get in touch if you'd like to submit a new/improved code sample in your languague or framework.\",\n      \"language\": \"text\",\n      \"name\": \"Others...\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Combining Parameters\"\n}\n[/block]\nRequesting symbols for a specific `base` currency can be combined with other API parameters, such as requesting specific rates/currencies (`symbols`) and JSONP callbacks (`callback`), for example:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"https://openexchangerates.org/api/historical/2015-02-16.json\\n    ?app_id=[[app:app_id]]\\n    &base=CAD\\n    &symbols=AUD,GBP,EUR\\n    &callback=someFunctionName\",\n      \"language\": \"http\"\n    }\n  ]\n}\n[/block]\nThe response will combine your parameters:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"someFunctionName(\\n{\\n    disclaimer: \\\"https://openexchangerates.org/terms/\\\",\\n    license: \\\"https://openexchangerates.org/license/\\\",\\n    timestamp: 1424127600,\\n    base: \\\"CAD\\\",\\n    rates: {\\n            AUD: 1.032828,\\n            EUR: 0.706867,\\n            GBP: 0.522328,\\n        }\\n    }\\n)\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Default Base Currency\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"\",\n  \"body\": \"The default API base currency is always United States Dollars (USD). It's not currently possible to set another default base for your entire account, so if (for example) you always need rates in GBP, you’ll need to always add `&base=GBP` to your API requests.\"\n}\n[/block]","excerpt":"The default base currency of the API is US Dollars (USD), but you can request exchange rates relative to a different base currency, where available, by setting the `base` parameter in your request.","slug":"changing-base-currency","type":"basic","title":"Changing Base Currency"}

Changing Base Currency

The default base currency of the API is US Dollars (USD), but you can request exchange rates relative to a different base currency, where available, by setting the `base` parameter in your request.

[block:callout] { "type": "info", "title": "Pro Feature", "body": "Changing Base Currency is currently available for clients on the Developer, Enterprise and Unlimited plans." } [/block] Any currency can be chosen as a base currency when requesting the latest rates, as well as historical rates and time-series (where available). The base currency should be requested with its 3-digit ISO code (see our list of available API currencies if in doubt). Results will be delivered relative to 1 unit of the currency you have requested. [block:api-header] { "type": "basic", "title": "Basic Request & Response*" } [/block] Append the `base` query parameter to your API request, along with the required 3-digit ISO currency code or symbol, like so (for Euros): [block:code] { "codes": [ { "code": "https://openexchangerates.org/api/latest.json\n ?app_id=[[app:app_id]]\n &base=EUR", "language": "http", "name": "HTTP" }, { "code": "$.get('https://openexchangerates.org/api/latest.json', {app_id: '[[app:app_id]]', base: 'GBP'}, function(data) {\n console.log(data);\n});", "language": "javascript", "name": "jQuery" } ] } [/block] The response format is exactly the same as the standard API response, with all rates in the `rates` object given relative to 1 standard unit of your requested `base` currency: [block:code] { "codes": [ { "code": "{\n disclaimer: \"https://openexchangerates.org/terms/\",\n license: \"https://openexchangerates.org/license/\",\n \"timestamp\": 1424127600,\n \"base\": \"EUR\",\n \"rates\": {\n \"AED\": 4.626447,\n \"AFN\": 61.002415,\n \"ALL\": 137.92617,\n /* ... */\n }\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "Basic Code Samples" } [/block] [block:code] { "codes": [ { "code": "$.get('https://openexchangerates.org/api/latest.json', {app_id: '[[app:app_id]]', base: 'UGX'}, function(data) {\n console.log(\"1 Ugandan Shilling equals \" + data.rates.JPY + \" Japanese Yen\");\n});", "language": "javascript", "name": "jQuery" }, { "code": "More code samples are on their way! Please get in touch if you'd like to submit a new/improved code sample in your languague or framework.", "language": "text", "name": "Others..." } ] } [/block] [block:api-header] { "type": "basic", "title": "Combining Parameters" } [/block] Requesting symbols for a specific `base` currency can be combined with other API parameters, such as requesting specific rates/currencies (`symbols`) and JSONP callbacks (`callback`), for example: [block:code] { "codes": [ { "code": "https://openexchangerates.org/api/historical/2015-02-16.json\n ?app_id=[[app:app_id]]\n &base=CAD\n &symbols=AUD,GBP,EUR\n &callback=someFunctionName", "language": "http" } ] } [/block] The response will combine your parameters: [block:code] { "codes": [ { "code": "someFunctionName(\n{\n disclaimer: \"https://openexchangerates.org/terms/\",\n license: \"https://openexchangerates.org/license/\",\n timestamp: 1424127600,\n base: \"CAD\",\n rates: {\n AUD: 1.032828,\n EUR: 0.706867,\n GBP: 0.522328,\n }\n }\n)", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "Default Base Currency" } [/block] [block:callout] { "type": "warning", "title": "", "body": "The default API base currency is always United States Dollars (USD). It's not currently possible to set another default base for your entire account, so if (for example) you always need rates in GBP, you’ll need to always add `&base=GBP` to your API requests." } [/block]