DEV Community

Cover image for What is Beckn and How to Install Beckn as a BAP Provider?
Athreya aka Maneshwar
Athreya aka Maneshwar

Posted on

What is Beckn and How to Install Beckn as a BAP Provider?

The Beckn Protocol is like a universal language for digital commerce, helping different platforms communicate with each other.

Whether it’s mobility, retail, or EV charging, Beckn makes sure everything works smoothly together.

In this blog, we’ll see how Beckn can transform the Electric Vehicle (EV) charging world and go step-by-step to set up Beckn as a BAP (Buyer App Protocol) provider.

Image description

Why Beckn is a Game-Changer for EV Charging

Imagine being able to find and use any EV charging station, even if it’s not part of your network. That’s what Beckn does.

It connects different networks so they can share information and services. Here’s why it’s awesome:

  1. Works Everywhere: Find charging stations across multiple networks, not just one.
  2. Better Business: Charging station owners get more visibility and customers.
  3. Convenience: Users can easily locate nearby charging stations, compare prices, and more.

For example, networks like ChargeZone and TruePower has joined Beckn, and their charging stations become available to everyone on the network.

Image description

How to Set Up Beckn as a BAP Provider

Here’s how you can set up a BAP provider step-by-step. Don’t worry, it’s easier than it sounds!

What You Need

  • A Linux-based server (Ubuntu is perfect).
  • Docker and Docker Compose installed.
  • A domain name.
  • SSL certificates for your domain (Let’s Encrypt works great).

1. Download Beckn-Onix

Start by cloning the Beckn-Onix repository:

 git clone https://github.com/beckn/beckn-onix/
 cd beckn-onix/install
Enter fullscreen mode Exit fullscreen mode

2. Run the Installation Script

Next, run the setup script:

 ./beckn-onix.sh
Enter fullscreen mode Exit fullscreen mode

Follow the instructions:

  1. Choose what you want to set up:
   Which platform would you like to set up?
   1. Gateway
   2. BAP
   3. BPP
   Enter your choice: 2
Enter fullscreen mode Exit fullscreen mode

Pick BAP (Buyer App Protocol).

  1. Fill in the details:
   Enter BAP Subscriber ID: bap-network-staging.yourdomain.tech
   Enter BAP Subscriber URL: https://bap-network-staging.yourdomain.tech
   Enter the registry_url (e.g., https://registry.becknprotocol.io/subscribers): https://registry-sandbox.ueialliance.org/subscribers
Enter fullscreen mode Exit fullscreen mode

Use the staging registry URL to test your setup.

The script will:

  • Install the protocol server for BAP.
  • Generate private and public keys.
  • Register your BAP on the staging registry automatically.

3. Set Up NGINX

Now, let’s configure NGINX to direct traffic to your BAP network and client.

Create a file with this configuration:

server {
    listen 80;
    server_name bap-network-staging.yourdomain.tech;

    location / {
        proxy_pass http://localhost:5002/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

server {
    listen 80;
    server_name bap-staging.yourdomain.tech;

    location / {
        proxy_pass http://localhost:5001/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}
Enter fullscreen mode Exit fullscreen mode

Save it, then restart NGINX:

$ sudo systemctl restart nginx
Enter fullscreen mode Exit fullscreen mode

4. Check Everything’s Running

Make sure the containers are running:

$ docker ps
Enter fullscreen mode Exit fullscreen mode

You should see two containers:

  • bap-network (Port 5002)
  • bap-client (Port 5001)

How Beckn Helps with EV Charging Station Discovery

Once your BAP is ready, it works with the Beckn Gateway to find EV charging stations near your users. Here’s an example search request:

Example Search Request

{
    "context": {
        "bap_id": "bap-network-staging.yourdomain.tech",
        "bap_uri": "https://bap-network-staging.yourdomain.tech",
        "domain": "ev-charging:0.1.0",
        "action": "search",
        "location": {
            "country": {
                "code": "IND"
            },
            "city": {
                "code": "std:080"
            }
        },
        "version": "1.1.0",
        "transaction_id": "6743e9e2-4fb5-487c-92b7-13ba8018f176",
        "message_id": "random-uuid",
        "timestamp": "2023-07-16T04:41:16Z"
    },
    "message": {
        "intent": {
            "item": {
                "descriptor": {
                    "code": "energy"
                }
            }
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

This searches for EV charging stations in Bangalore (city code std:080).

Test with Postman

For testing, use Beckn’s official Postman collection: Beckn Sandbox GitHub.

Wrapping Up

Beckn makes it easy to bring different EV charging networks together, giving users access to more stations and helping providers reach more customers.

With this guide, you can set up a BAP provider and be part of the growing Beckn ecosystem. Happy charging!

Top comments (0)