Protocol Server requires the following services to be installed:
Protocol Server uses the configuration file to configure the server.
- default.yaml needs to be present inside the config folder.
In order to create the configuration file you can refer to config-sample.yml.
Protocol Server requires port number and db url to be configured.
port: 3000
db:
url: mongodb://localhost:27017/protocol
- The port requires to be a valid integer number.The default port number is 3000.
- The db url requires to be a valid mongodb url.
Protocol Server can be configured to run as a BAP(Beckn Application Platform) or as a BPP(Beckn Provider Platform).
All app configuration required to be inside the app object only.
In order to configure the protocol server as BAP, you need to provide the following configuration:
-
Specify the app mode to be
bap
.app: mode: bap
-
Specify the actions that this app will server.
actions: - search - init
-
Provide the sigin public key and private key
privateKey: "your private key" publicKey: "your public key"
-
Specify the
subscriberId
andsubscriberUri
as per the registry which is also known asbap_id
andbap_uri
.subscriberId: "dev.bap.protocol-server.com" subscriberUri: "https://dev.bap.protocol-server.com/"
-
Specify the registry url.
registryUrl: https://registry.becknprotocol.io/subscribers
-
Specify whether to authenticate the requests or not. This can be done by providing the
auth
property.auth: true
-
The unique key id is also required to in order to create authorization.
uniqueKey: "dev.bap.protocol-server.key"
-
Provide the Operation Region Information.
city: "std:080" country: "IND"
-
Provide the ttl for the requests and ttl for lookupCache.
ttl: "PT1M" lookupCacheTTL: "PT10S"
-
Provide the HTTP Configuration. The
httpTimeout
specify the timeout for the http requests in milliseconds. ThehttpRetryCount
will specify the number of retries for the http requests.httpTimeout: 5000 httpRetryCount: 2
-
Provide the
clientUrl
in order to the communicate the responses to client.clientUrl: "https://beckn.free.beeceptor.com/clientURL"
In order to configure the protocol server as BPP, you need to provide the following configuration:
-
Specify the app mode to be
bpp
.app: mode: bpp
-
Specify the actions that this app will server.
actions: - search - init
-
Provide the sigin public key and private key
privateKey: "your private key" publicKey: "your public key"
-
Specify the
subscriberId
andsubscriberUri
as per the registry which is also known asbpp_id
andbpp_uri
.subscriberId: "dev.bpp.protocol-server.com" subscriberUri: "https://dev.bpp.protocol-server.com/"
-
Specify the registry url.
registryUrl: https://registry.becknprotocol.io/subscribers
-
Specify whether to authenticate the requests or not. This can be done by providing the
auth
property.auth: true
-
The unique key id is also required to in order to create authorization.
uniqueKey: "dev.bpp.protocol-server.key"
-
Provide the Operation Region Information.
city: "std:080" country: "IND"
-
Provide the ttl for the requests and ttl for lookupCache.
ttl: "PT1M" lookupCacheTTL: "PT10S"
-
Provide the HTTP Configuration. The
httpTimeout
specify the timeout for the http requests in milliseconds. ThehttpRetryCount
will specify the number of retries for the http requests.httpTimeout: 5000 httpRetryCount: 2
-
Provide the
clientUrl
in order to the communicate the responses to client which is a provider application in case of BPP.clientUrl: "https://beckn.free.beeceptor.com/clientURL"
In order to validate the API endpoint requests, responses and headers against the same endpoint spec in beckn protocols' specifications, you need to provide the required open api schema file core.yaml.
core.yaml should be consisting of specification of each API as per the beckn protocol specifications.
Once the whole protocol server is either configured to BAP
or BPP
, all npm packages needs to be installed.
npm install
Once all the packages are installed we can run the protocol server in development mode by using the following command.
npm run dev
The whole server built on typescript so in order to run the server in production mode, we need to build the server in JS source code.
npm run build
All the JS source code will be located in the dist
folder.
Once the server is built, we can run the server in production mode by using the following command.
npm run start
To configure this protocol server, a pair of public and private keys is required. The private key is used to sign the requests and the public key is used to verify the requests. This public needs to be registered with the registry and the provided uniqueKey
needs to be configured with the protocol server.
In order to generate the public and private keys, you need to run the following command.
npm run generate-keys
This command will generate a pair of private and public and will be visible on the console.
Generating Key Pairs...
Key Pairs Generated
Your Public Key :
taRF+XAJ3o2E3NDWPj5fPGq5HTVNqa/DKPx8VTpMvlg=
Your Private Key :
Uh/qEeDz5LrZapUKal2vY4fxffIONciN1JWMMSVvcwu1pEX5cAnejYTc0NY+Pl88arkdNU2pr8Mo/HxVOky+WA==
Please save your keys in a secure location.
To subscribe to Beckn network you can follow the network subscription docs here.
Knowledge of the Beckn network and Beckn Protocol Specifications.
Protocol server helps you connect with Beckn network and communicate with the Beckn network. So in order to communicate over the Beckn network each request needs to valid as per the Beckn Protocol Specifications.
The protocol server will perform a series of validations on the request and will return the response as per the Beckn Protocol Specifications.
Only the valid requests will be sent to the network. The invalid requests will be rejected.
It's necessary for all requests from the Client Layer to be valid as per the Beckn Protocol Specifications.
Each request body is divided into three parts:
-
context
: It consists of all the necessary information to validate and perform the request. Each request from the client layer needs to have acontext
as part of the request with the following information:-
domain
: The domain of the request. -
core_version
: The version of the Beckn protocol. -
bpp_id
: This field is mandatory in the case of non-search calls. -
bpp_uri
: This field is mandatory in the case of non-search calls.
The optional fields which will be provided configured value in case not provided.
-
country
: This is an optional field and is used to specify the country of the request. -
city
: This is an optional field and is used to specify the city of the request. -
transaction_id
: This is an optional field and is used to specify the transaction id of the request.
The other fields which will be configured by the Protocol Server are:
-
message_id
: This id will be generated by protocol server on request and is used to specify the message id of the request. -
ttl
: This will be configured by the protocol server as per the provided value in configuration file. -
timestamp
: This will be autogenerated at the time of request. -
bap_id
: This will be configured by the protocol server as per the provided value in configuration file. -
bap_uri
: This will be configured by the protocol server as per the provided value in configuration file. -
action
: This will be configured by the protocol depending on the request.
-
-
message
: The message is the actual request body. It is the payload of the request. It needs to strictly follow the Beckn Protocol Specifications. Any violation will lead to the request being rejected. -
error
: It is the error response in case of any error. It's an optional field. Refer to Beckn Protocol Specifications.
-
The client needs to implement a webhook in order to recieve the requests and responses from the protocol server.
-
The webhook needs to be configured with the
clientUrl
provided in the configuration file. -
All the requests and responses recieved from the network will be sent to the webhook.
-
This API needs to be a
POST
api.
-
-
The communication from client layer to protocol server (BAP Mode) is through the HTTP webhooks. Each request will be sent as a
POST
request. Here the api path will be in the format.<protocol-server-host>/<action>
Here the action can be one of the following:
search
init
select
update
confirm
cancel
status
track
-
In case when the protocol server is configured in BPP mode, each request from the network will be sent to the client layer as a
POST
request to theclientUrl
provided in the configuration file. Once the request is processed the responses needs to be sent back to the protocol server.Here the api path will be in the format.
<protocol-server-host>/<action>
Here the action can be one of the following:
on_search
on_init
on_select
on_update
on_confirm
on_cancel
on_status
on_track
-
BAP Mode
: Each request from the client layer will be sent to the protocol server as aPOST
request. All the responses from the network will be sent to the client layer as aPOST
request to theclientUrl
provided in the configuration file. -
BPP Mode
: Each request from the network will be sent to the client layer as aPOST
request to theclientUrl
provided in the configuration file. Once the request is processed the responses needs to be sent back to the protocol server as aPOST
request.