Getting Started
This guide will get you all set up and ready to use the BetterCommerce API for Next.js StoreFront. We'll cover how to get started using one of our API clients and how to make your first API request. We'll also look at where to go next to find all the information you need to take full advantage of our powerful REST API.
Get your API keys
- Signup with the platform by getting in touch at signup@bettercommerce.io
- You can login and go to Settings > API Keys and copy API Key & Shared Secret.
- You will also need your OrgId & DomainId – which is provided by the BetterCommerce account manager.
Before you can make requests to the BetterCommerce API, you will need to grab your API key from your dashboard. You find it under Settings » API.
Clone StoreFront Repository
- Clone the git repo from BetterCommerce StoreFront
- Update environment variables in .env file - details below.
- Run the solution locally or publish on vercel or any other static site supported hosting providers
Environment Variables
You shall be needing the following data to setup your Next.js storefront. The variables prefixed with NEXT_ are exposed to the front end. You need to have NEXT_PUBLIC for it to be accessed on the client side, else these variables are accessible only on the server.
Key | Description | Default Value |
---|---|---|
COMMERCE_PROVIDER | Identify commerce provider being used in the storefront | Bettercommerce |
BETTERCOMMERCE_BASE_URL | Base URL for the BC API | https://api20.bettercommerce.io |
BETTERCOMMERCE_AUTH_URL | Auth URL to get API token | https://auth.bettercommerce.io/oAuth/Token |
BETTERCOMMERCE_CLIENT_ID | API Key | Available in the Settings > API Token |
BETTERCOMMERCE_SHARED_SECRET | API Shared Secret | Available in the Settings > API Token |
NEXT_PUBLIC_ORG_ID | Unique OrgId for your organization | Provided by your BC Account Manager |
NEXT_PUBLIC_DOMAIN_ID | Unique Domain Id per domain within the organization | Provided by your BC Account Manager |
NEXT_PUBLIC_API_VERSION | Version of the API being used | v2 |
NEXT_PUBLIC_ENABLE_INFINITE_SCROLL | Should the infinite scroll be enabled on PLPs or standard paging | TRUE |
NEXT_PUBLIC_OMNILYTICS_ID | If Omnilytics is enabled for realtime event capture, then this value to be provided | Your account manager shall provide the link |
NEXT_PUBLIC_GEO_ENDPOINT | If Omnilytics is enabled for realtime event capture, then this value is needed | Your account manager shall provide the link |
OMS_BASE_URL | OMS API Url which is used for fetching basket delivery plan, split shipment, inventory, etc. | https://omsapi20.bettercommerce.io/ |
LOQATE_KEY | Used for post code finder, can be left blank as well if loqate is not used | To be fetched by signup with Loqate |