Discover_Image Currency Convertor > Documentation

Overview


The Currency Convertor provides the exchange rates for various currencies.

Authentication-Making the first API request is only few steps away


  1. All projects start in Sandbox mode. Once you’re invited to gain access to this API you can login here to get Client Application ID (API Key) Client Application Secret, Consumer Application Certificate and API Plan name.

  2. All API requests must be authenticated with an OAuth token. To get the OAuth token, follow these simple steps

    1. Make a HTTP POST request to the endpoint /auth/oauth/v2/token with HTTP Authorization Header as Basic base64encoded(client_application_id:client_application_secret), Content-Type as application/x-www-form-urlencoded and Cache-Control as no-cache

    2. The response would contain an OAuth token along with token type and token expiry in seconds

      SAMPLE OAUTH TOKEN REQUEST

      POST /auth/oauth/v2/token?grant_type=xyz&scope=RWDS_xyz HTTP/1.1
      Authorization: sdlfsdf0dskladfk123456
      Content-Type: application/x-www-form-urlencoded
      Cache-Control: no-cache

      SAMPLE RESPONSE

      Response-Status: HTTP/1.1 200 OK
      Cache-Control: no-store
      Content-Type: application/json;charset=UTF-8
      Pragma: no-cache
      {
      "access_token": "sdlfsdf0dskladfk123456"
      "token_type": "xyz"
      "expires_in": 3600
      "scope": "RWDS_xyz"
      }

  3. Once an OAuth token is obtained, you can use the token along with Consumer Application Secret and API Plan name provided during Sandbox access in the HTTP Header of an API to make your first call. The same OAuth can be used for multiple API calls as long as it is not expired.

Access Error


User authentication failed with error code 1001 and HTTP Status Code as 401.

Not authorized to access the resource! With the error code 1003 and HTTP Status Code as 403.

Unsupported Media Type with HTTP status Code 415.

API Structure


A typical API request would contain the sections HTTP Header, Request Header, Request Body as part of the request and HTTP Header, Response Header and Response Body as part of the response with some exception due to the nature of the API. Refer the individual end points to know more.

HTTP Header


We follow a robust standard for HTTP Header which includes the following parameters to be supplied while you are making an API request

Accept
Content-Type
Authorization
X-DFS-API-PLAN
The value for Authorization will be Basic base64encoded(client_application_id:client_application_secret).
The value for X-DFS-API-PLAN will be provided during App registration in the portal.
Our HTTP Header in the response will include Access, Content-Type and Cache-Control.

HTTP Status Codes


User authentication failed with error code 1001 and HTTP Status as 401.
Not authorized to access the resource! With the error code 1003 and HTTP Status as 403.
Unsupported Media Type with HTTP status as 415.
Validation error with the error code 10001 and HTTP Status as 400.
Internal server error with the error code 10002 and HTTP Status as 500.

dci/currencyconversion/exchangerates

/dci/currencyconversion/v1/exchangerates


This API is mainly developed for tip guide returning the entire set of values

REQUEST HTTP HEADERS


X-DFS-API-PLAN:

Name of the API plan assigned to the app during registration approval (e.g. DCI_CURRENCYCONVERSION _SANDBOX, DCI_CURRENCYCONVERSION_PROD)

Authorization:

The value of the header is Bearer access_token

SAMPLE CURL REQUEST

curl -X GET \
dci/currencyconversion/v1/exchangerates \
-H 'authorization: Basic access_token ' \
-H 'cache-control: no-cache' \
-H 'x-dfs-api-plan: API_PLAN_NAME '

RESPONSE VALUES


date: date

API Invoked date

curr_cd: string

Currency code

curr_desc_en: string

Currency description English

curr_desc_es: string

Currency description Spanish

curr_desc_de: string

Currency description German

curr_desc_ja: string

Currency description African

curr_desc_ru: string

Currency description Russian

curr_desc_pt: string

Currency description Portugal

curr_desc_zh: string

Currency description Chinese

exchange_dt: date

Date when the rate is updated

exchange_rate: Float

Exchange rate equivalent to 1$

Sample Response # 1

{
"date": "2018-01-24 11:57:03",
"currencies": [
{
"curr_cd": "AFN",
"curr_desc_en": "Afghan Afghani",
"curr_desc_es": "Afgani afgano",
"curr_desc_de": "Afghanischer Afghani",
"curr_desc_ja": "アフガニ",
"curr_desc_ru": "Афганский афгани",
"curr_desc_pt": "Afegane Afegão",
"curr_desc_zh": "阿富汗阿富汗尼",
"exchange_dt": "2017-04-20",
"exchange_rate": 0.0155521
},
{
"curr_cd": "INR",
"curr_desc_en": "Indian Rupees",
"curr_desc_es": "Afgani afgano",
"curr_desc_de": "Afghanischer Afghani",
"curr_desc_ja": "アフガニ",
"curr_desc_ru": "Афганский афгани",
"curr_desc_pt": "Afegane Afegão",
"curr_desc_zh": "阿富汗阿富汗尼",
"exchange_dt": "2017-04-20",
"exchange_rate": 0.14
}
]
}

dci/currencyconversion/healthcheck

/dci/currencyconversion/v1/healthcheck


This API can be used to check if the service is up and running

REQUEST HTTP HEADERS


Accept:

Only accept application/json type

Authorization:

The value of the header is Bearer access_token

X-DFS-API-PLAN:

Name of the API plan assigned to the app during registration approval

RESPONSE VALUES


message: string

service/API is up and running or Down

status: string

UP or Down

Sample Response # 1

{
"details" : {
"message" : "service/API is up and running"
},
"status": "UP"
}

dci/currencyconversion/exchangerates

/dci/currencyconversion/v1/exchangerate


This API returns the exchange rate for the requested currency equivalent to dollar

REQUEST HTTP HEADERS


Accept:

Only accept application/json type

Authorization:

The value of the header is Bearer access_token

X-DFS-API-PLAN:

Name of the API plan assigned to the app during registration approval

SAMPLE CURL REQUEST

curl -X GET \
/dci/currencyconversion/v1/exchangerate\currencycd=AFN \
-H 'authorization: Basic access_token ' \
-H 'cache-control: no-cache' \
-H 'x-dfs-api-plan: API_PLAN_NAME '

RESPONSE VALUES


date: date

API Invoked date

curr_cd: string

Currency code

curr_desc_en: string

Currency description English

curr_desc_es: string

Currency description Spanish

curr_desc_de: string

Currency description German

curr_desc_ja: string

Currency description African

curr_desc_ru: string

Currency description Russian

curr_desc_pt: string

Currency description Portugal

curr_desc_zh: string

Currency description Chinese

exchange_dt: date

Date when the rate is updated

exchange_rate: Float

Exchange rate equivalent to 1$

Sample Response # 1

{
"curr_cd" : "AFN",
"curr_desc_en" : "Afghan Afghani",
"curr_desc_es" : "Afgani afgano",
"curr_desc_de" : "Afghanischer Afghani",
"curr_desc_ja" : "アフガニ",
"curr_desc_ru" : "Афганский афгани",
"curr_desc_pt" : "Afegane Afegão",
"curr_desc_zh" : "阿富汗阿富汗尼",
"exchange_dt" : "2017-04-20",
"exchange_rate" : "0.0155521"
}

dci/currencyconversion/languages

/dci/currencyconversion/v1/languages


This API returns the exchange rate for the requested currency equivalent to dollar

REQUEST HTTP HEADERS


Accept:

Only accept application/json type

Authorization:

The value of the header is Bearer access_token

X-DFS-API-PLAN:

Name of the API plan assigned to the app during registration approval

RESPONSE VALUES


languageCode: string

Language code

languageDesc: string

Language Description

Sample Response # 1

[
{
"languageCode" : "pt",
"languageDesc" : "PORTUGUESE"
}
{
"languageCode" : "en",
"languageDesc" : "ENGLISH"
}
]

Errors


Header Level Error Codes

Error Code Error Message Error Description HTTP Status Code
90001 Invalid field type - LanguageCode Language Code must only contain letters 400
90002 Invalid field type - CurrencyCode Currency Code must only contain letters 400