AprilDocs
Search…
Weather Datafeed Tech Doc
Introduction:
This technical document will be broken into parts, part 1 provides you access to April weather datafeeds on-chain for thousands of cities around the world. This access allows you to easily and quickly connect up a Dapp front end without the need to build or manage your own blockchain backend. A flat monthly subscription rate of USD 10 is charged for this basic access once the 30 day free trial period is over.
An example of what you can build with part 1 of this doc can be found at our April weather explorer demo linked below.
Subsequent parts of this doc will focus on integrating April weather datafeeds via cross chain protocols.
April Weather Explorer Demo:
Step 1:
Sign up or Sign in to BSN International portal https://bsnbase.io/g/main/index
Step 2:
Please click April invite link below and you will see the Apply to Join page:
Complete the Applying to Join steps:
a. Chose Read role (the application for joining will be rejected if SysAdmin or Write roles are chosen.)
b. Click Add City Nodes
c. Click the City Node or Nodes of your chose (Tokyo & Paris are chosen in below screenshot) and click confirm.
d. Click New Certificate
e. Set your certificate access password (please keep this password in a safe & secure place)
f. Click Confirm
Step 3:
Now please wait for April team to approve your application. Your application will be reviewed within 24 hours.
Your application status will show Pending Review until it is either approved or rejected.
Step 4:
Once approved you will receive a notification e-mail to the email address you used for BSN account signup and your status will change to Confirmed.
Subscription Plan:
April will utilize a paid subscription service model once the 30 days free trial period is over. Payment method accepted include April token, USDT, BUSD or ECNY.
We offer a flat USD 10 per month plan.
This plan not only provides you access to April Weather but all our other datafeeds as well.
Step 5:
Now that you are approved you are able to call April using your off BSN system. Please visit BSN Github: https://github.com/BSNDA
We will use the PCNgateway Java SDK as our off Bsn system example for the rest of this guide. Download the Java SDK https://github.com/BSNDA/PCNGateway-Java-SDK
Step 6:
Before you can obtain weather data from April using the BSN java SDK you will need to get the BSN access information from your applications page.
To obtain the access information please click Permissioned Services tab, then Participated Services.
Then you will see April information, service participation date, application status & Action option button. Please click the Action options button then click Details
You will be taken to the application details page, click the green download icon for your chosen city node to obtain the access certificates. Also click the Configuration parameters for service access button to obtain application details (UserCode, AppCode) which you will need to input into the BSN java SDK.
You will need to unzip the downloaded file using your New Certificate password which you created in Step 2. section d.
Access details:
UserCode: You must obtain your own UserCode by clicking the Configuration Parameters for Service access button.
AppCode: app0003202109071055297039036
ChainCode: cc_app0003202109071055297039036_01
Step 7:
Once you have the access certificate file opened and access details now is the time to input them into the BSN java SDK so you can request April weather data.
You want to open the java SDK Fabric test client and input the details as shown below:
1
public void initConfig() throws IOException {
2
Config config = new Config();
3
config.setAppCode("app0003202109071055297039036");
4
config.setUserCode("USER0003202005291706487822713");
5
config.setApi("https://tokyonode.bsngate.com:17602");
6
Copied!
Next we need to set the contents and path of the private & gateway public keys. Open the downloaded Certificate file from step 6.
You will see several folders, you want the UserAppCert folder, click secp256r1. Extract the private key file then copy and paste the contents to the correct place. You also need to go to the gatewayCert folder and extract the gateway_public_cert_secp256r1 file and copy and paste the contents. Both input paths for the private and public keys are mentioned in below code snippet.
1
config.setPrk(Common.readLocalFile("D:/private_key.pem"));
2
config.setPuk(Common.readLocalFile("D:/public_key.pem"));
3
config.setMspDir("D:/test");
4
config.initConfig(config);
5
String filePath="config/config.json";
6
Config config=Config.buildByConfigJson(filePath);
7
config.initConfig(config);
8
}
Copied!
Step 8:
We must now input the parameter details so that we can call April and get the weather data we need.
a. setFuncName changed to "get"
b. setChainCode changed to "cc_app0003202109071055297039036_01"
c. Input the city or town you wish to obtain weather data for, the city/town must be in lowercase.
String[] args = {"paris"}
d. Comment out //reqkey.setUserName (test28) or you will receive "user is not exist' error.
1
public void reqChainCode() {
2
try {
3
initConfig();
4
ReqKeyEscrow reqkey = new ReqKeyEscrow();
5
String[] args = {"paris"};
6
reqkey.setArgs(args);
7
reqkey.setFuncName("get");
8
reqkey.setChainCode("cc_app0003202109071055297039036_01");
9
//reqkey.setUserName("test28");
10
ResKeyEscrow resKeyEscrow = FabricClient.reqChainCode(reqkey);
11
System.out.println(JSONObject.toJSONString(resKeyEscrow, SerializerFeature.PrettyFormat));
12
} catch (Exception e) {
13
e.printStackTrace();
14
}
15
}
Copied!
Step 9:
Lastly run reqChainCode()
You will get the weather data for the inputed city/town in the response:
PART 2: (to be published)
Last modified 1mo ago
Copy link