Run the app
This guide will walk you through the process of trying FlatPeak service for the first time.
1. Get a Dashboard account
Before you begin, make sure to create an account and complete onboarding. Once completed, you’ll be able to access your API keys.
Use test (sandbox) mode keys for your development.
2. Run Connect flow
Clone our repo and install the required dependencies
Set the environment variables
Run locally
A local preview will be available at http://localhost:7070
.
Your browser will redirect to an error page. This is because you have not provided a Connect token. Ignore this error and continue following this guide.
Obtain a bearer token to access FlatPeak API
-
Go to the Dashboard API section to retrieve your Account ID and API Key. Use test (sandbox) mode key.
-
Base64 encode the combination of
account_id:api_key
and make a request to create-a-bearer-token endpoint.
Obtain a token to access Connect
FlatPeak implements a single-use session token to provide access to Connect API endpoints, so you don’t need to expose API keys to your customer-facing app
Make a request to create-connect-token endpoint to obtain a connect token.
callback_uri
), we recommend using https://webhook.site, but you can use any other service.Run the Connect app
On your computer, where you already have FlatPeak connect code running locally, open: http://localhost:7070?fp_cot=cot_***
. Replace **cot_ with the connect_token
. The resulting URI may look similar to this example:
Follow the flow
Connect will present you with a set of pages that will let you share your tariff information. It automatically chooses the best route to discover your tariff based on the availability of provider APIs, data-sharing regulations and frequency of provider use within the FlatPeak base.
Receive and process callback
Once click Save button on Your Tariff screen, Connect will send the following to callback_uri
you specified:
Exchange completed Connect token for Location ID
Once you received a callback and using connect_token
as a reference, call exchange-connect-token endpoint to obtain a location_id
that represents a permanent identifier of a property address in FlatPeak. In the future you will store it in your database in reference to the physical location of your customer’s property.
Get tariff rates
You can now query the tariff-rates API endpoint to obtain tariff data.