Table of Contents

BioStar 2 API Quick Start Guide


Introduction

There are two ways to utilize BioStar API. One is called Web API(via BioStar Cloud Server) and Another one is called Local API. We recommend that you should use Local API. After you install BioStar 2 API Server, you can see the documentation of BioStar API which provides more detailed information on how to use BioStar API.

In this article, I’m going to take a closer look at a sample application that I made for those who are familiar with C# or standalone Windows application. Since BioStar API is RESTful API, those who are not familiar with RESTful API might have difficulties implementing their own applications with BioStar API. Therefore, I’d like to guide them to kick-start their development with the sample application in this article.

Features

This sample application is a Visual C# console application and includes four basic functions: login, user creation, access group retrieval and log retrieval.


[Figure 1. When you’ve launched the sample application]

First, you have to log in before using any other functions. If you type ‘1’ and press Enter, the sample application logs into your local BioStar server through BioStar API server.


[Figure 2. After logging in]

When successfully logged in, you get the information of the user that you used for logging in. The user data is in the JSON format and includes very detailed data including fingerprint templates as you can see from Figure 2. Now that we’ve logged in, we can use other functions. In order to retrieve access groups, type “2” and press Enter.


[Figure 3. Retrieving access groups]

As you can see from the screenshot, there is only one access group in BioStar 2 Server and the name of the access group is “First Access Group” and if you look at the “user_summary” property, you can notice that it has two users. Now type “3” and press Enter to create a new user. You will be asked to enter the user ID. I entered “98” as user ID and got the success message from the server.


[Figure 4. Creating a new user]

Lastly, let’s retrieve log events from the server. Type “4” and press Enter and you will get log data from the server as shown in the screenshot below:


[Figure 5. Getting log list]


Analysis of the source code

1. Log in

The most important part in this sample application is log-in. Let’s take a look at the function below:


2. Retrieving access groups


3. Retrieving events



4. Creating a user


Conclusion

So far, we have taken a brief look at how we can utilize BioStar API. Much of this article is not BioStar API specific. Rather, it’s about basic usage of class HttpClient and what to do to use Local API. Therefore, even if you’re not familiar with using BioStar API, I believe you can kick start on how to use BioStar API with this article. For more detailed information on BioStar API, See the documentation about Local API after installing BioStar 2 API Server: http://127.0.0.1:8795/v2/docs/