# Getting Started with Visitor API

## Content



This getting started section guides you through a process of creating a Web API application to get the visitor data using the Vissitor API.

### Add Visitor API to Server API

1.  Create a new Web API Core application.
2.  Add the C1.AspNetCore.Api.Visitor NuGet package to the application.

### Configure the API

You can choose to configure the API either using IP2Location Database or GoogleMap API. To configure the api using the IP2Location Database, see [Configuring IP2Location Database](/componentone/docs/webapi/online-webapicore/Services/visitor-api/configuring-ip2location-database). If you want to configure the API using the GoogleMap API, see [Configuring Google Map API](/componentone/docs/webapi/online-webapicore/Services/visitor-api/configuring-google-map-api).

Note that you can set the following in ConfigureServices method of startup.cs file, if you do not want to use any location provider. This will allow you to use all other visitor information.

```SCRIPT
﻿services.ConfigureVisitor(builder =>
       {
               builder.UseWithoutLocationProvider();
       });
```

### Include JS Client Script to Client Project

### Synchronous loading

For synchronous loading of visitor data, use the following code.

```SCRIPT
<script src="{host}/api/visitor/visitor-client.min.js"></script>
```

### Asynchronous loading

For asynchronous loading of visitor data, use the following code.

```SCRIPT
<script>
   function onVisitorLoaded(visitorData) {
        Console.log visitorData
   }
</script>
<script async defer src="{host}/api/visitor/visitor-client.min.js?callback=onVisitorLoaded"></script>
```

### Access Visitor Information

### Synchronous loading

To get the complete visitor data, use the following code:

```
var visitorData= window.visitor.getData();
```

### Asynchronous loading

To get the country code of the visitor, use the following code:

```
window.visitor.getDataAsync(function (visitorData){
       // visitorData.geo.countryCode
})
```

For detailed list of the visitor data fetched on the client-side, see [Visitor Data Information](/componentone/docs/webapi/online-webapicore/Services/visitor-api/visitor-data-information).