Skip to content

Third party API settings

  • To save Third party API settings click on the Add Third party API Settings button.

Third party API setting code

import * as T from 'types';

let thirdPartyApiSetting: T.ITPApiSettingsTypes = {
    enableCaching: false,
    acceptOnlyEncryptedData: false,
    apiAccessType: T.EAPIAccessType.TOKEN_ACCESS,
    resetCacheOnModificationOf: [
        'DB:INSTANCE_NAME:DATABASE_NAME:COLLECTION_NAME',
        'CA:CUSTOM_API_NAME',
        'TP:BUNDLE_NAME:API_VERSION'
    ],
    authTokenInfo: <T.IAuthTokenInfo[]>[
        {
            authTokenType: T.EAuthTokenType.AM_DB,
            authTokenAMDB: {
                "instance": "INSTANCE_NAME",
                "database": "DATABASE_NAME",
                "collection": "COLLECTION_NAME",
                "usernameColumn": "USER_NAME_COLUMN",
                "passwordColumn": "USER_PASSWORD_COLUMN"
            }
        }
    ],
};
module.exports = thirdPartyApiSetting;

Enable caching

To enable caching of particular Third party APIs use enableCaching: true

enableCaching: true | false

Accept only encrypted data

  • If you set the acceptOnlyEncryptedData value as true API Maker will accept only the encrypted body, query params, and URL.
  • In header provide x-am-encrypted-payload: true when you set acceptOnlyEncryptedData: true.
acceptOnlyEncryptedData: true | false

API access type

  • There are two possible values of apiAccessType.
  • When you set IS_PUBLIC this Third party APIs should be publicly available.
  • When you set TOKEN_ACCESS this Third party APIs should require a token to access.
  • Provide API User token in the x-am-authorization header.
apiAccessType: IS_PUBLIC | TOKEN_ACCESS

Auth token info

  • If you do not provide authTokenInfo it will take authTokenInfo from the default secret.
// authTokenInfo: <T.IAuthTokenInfo[]>[]
  • If the authTokenInfo value is an empty array then provide only AM's API user's token in the x-am-authorization header because we are overriding the default secret's authTokenInfo. In that, you have to provide API Maker's API user token in the x-am-authorization header.
authTokenInfo: <T.IAuthTokenInfo[]>[]
  • Now, if you set authTokenType: T.EAuthTokenType.AM_DB and given required values in the authTokenAMDB object. The end user(who will use APIs) needs to provide the token in the x-am-user-authorization header.
  • The end user needs to create a token using the given instance, database, collection, usernameColumn, and passwordColumn values. Use the getToken system API to get the token.
authTokenInfo: <T.IAuthTokenInfo[]>[
    {
        authTokenType: T.EAuthTokenType.AM_DB,
        authTokenAMDB: {
            "instance": "INSTANCE_NAME",
            "database": "DATABASE_NAME",
            "collection": "COLLECTION_NAME",
            "usernameColumn": "USER_NAME_COLUMN",
            "passwordColumn": "USER_PASSWORD_COLUMN"
        }
    }
]

Reset cache on modification of

  • We can reset the cache of the Third party API if any modification happens in the given collection/table, custom API, or third party API using resetCacheOnModificationOf.
  • DB: instance_name:database_name:collection|table, if modify/delete data of this collection/table system will automatically reset the cache of this [Hello World] Third party API.
  • TP: api_bundle_name:api_version, if we hit any API of this version having [categoryRedis: EAPICategoryRedis.MODIFY_DATA], it will reset the cache of this [Hello World] Third party API.
  • CA: custom_api_name, if we hit this custom_api, it will reset the cache of this [Hello World] Third party API.