# Building dependencies and API # The DeviceAtlas Go API provides a way to detect devices based on the data found in HTTP headers. Using these headers, the API returns device information such as screen width, screen height, is mobile, vendor, model etc. To see a full list of properties in DeviceAtlas please visit: https://deviceatlas.com/resources/available-properties . ### Data File ### The DeviceAtlas API relies on a device data file to function. DeviceAtlas provides daily data file updates so it is recommended to download the data file on a regular basis. This can be done manually from your account page or automated via the https://deviceatlas.com/getJSON page. For more information please see: https://deviceatlas.com/resources/getting-the-data ## Requirements ## The DeviceAtlas Go API is a wrapper around the DeviceAtlas C API and requires the following: - DeviceAtlas C API - Go (v1.3.1 or later) Go is often available for install via the system package manager. If this is not the case it can be downloaded from the [Go website](https://golang.org/) or [installed from source](https://golang.org/doc/install/source). ## Building the Go API ## There are two steps to build the Go API: 1. Build and install the DeviceAtlas C API library. 2. Build the Go API wrapper itself. ### Step 1: Building the C API library ### The C API library is provided under the `Dependencies` folder with the compilation instructions enclosed in the package or [available online](https://docs.deviceatlas.com/apis/enterprise/c/2.3.0/README.DeviceApi.html). A summary of instructions to build and install the C API library `libda.so` and `libci.so` are below: ```sh tar xf deviceatlas-enterprise-c-{version}.tgz cd deviceatlas-enterprise-c-{version}/Src cmake . make sudo make install sudo ldconfig /usr/local/lib ``` Note: On Solaris and Illumos, Go only supports 64 bits architectures. For these the C API must be explicitly compiled in 64 bits. ```sh cd deviceatlas-enterprise-c-{version}/Src cmake -DCMAKE_C_FLAGS="-m64" make sudo make install sudo ldconfig /usr/local/lib ``` Note: For Windows based operating systems, please refer to the [README.Windows](https://docs.deviceatlas.com/apis/enterprise/c/2.3.0/README.Windows.html) documentation. ### Step 2: Building the Go API wrapper ### The following commands build the Go API as a static compiled binary file called `deviceatlas.a`. ** Unix operating systems ** ```sh cp -r deviceatlas-enterprise-go-wrapper-{version}/Api/src/deviceatlas $(go env GOPATH)/src/ ``` ** Windows / Powershell ** ```sh copy-item -recurse "deviceatlas-enterprise-go-wrapper-{version}\Api\src\deviceatlas" -destination "$(go env GOPATH)\src\" ``` ** Windows / cmd ** ```sh Xcopy /E /I deviceatlas-enterprise-go-wrapper-{version}\Api\src\deviceatlas %GOPATH%\src\deviceatlas\ ``` ### Additional options ### #### Custom C API Library path #### If the Enterprise C API library (libda.so) is not installed in a system path location, additional environment variables are necessary. 1. CGO_CFLAGS - the path to the C API header files. 2. CGO_LDFLAGS - the path to the C API library ** C API installed in a custom location ** ```sh export CGO_CFLAGS="$CGO_CFLAGS -I/custom/path/header/files" export CGO_LDFLAGS="$CGO_LDFLAGS -L/custom/path/library/files" go install deviceatlas/... ``` ** C API not installed in the system ** ```sh export CGO_CFLAGS="$CGO_CFLAGS -I<path to the C API>/Src" export CGO_LDFLAGS="$CGO_LDFLAGS -L<path to the C API>/Src -Wl,-rpath,<path to the C API>/Src" go install deviceatlas/... ``` Note: On Windows, the PCRE and C API DLLs locations must be present in the PATH environment variable. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - _ Copyright (c) DeviceAtlas Limited 2021. All Rights Reserved. _ https://deviceatlas.com <!-- HTML+JS for document formatting when opened in browser --> <div class="btn-group" id="main-menu" style="float:right"><a class="btn dropdown-toggle" data-toggle="dropdown" href="#">Menu<span class="caret"></span></a><ul class="dropdown-menu"><li><a href="README.html">Main</a></li><li class="disabled"><a href="README.DeviceApi.html">Building dependencies and API</a></li><li><a href="README.DeviceApi-Web.html">Device Detection for Web</a></li><li><a href="README.DeviceApi-Apps.html">Device Detection for Apps</a></li><li><a href="./ApiDocs/device.html">Device API Docs</a></li><li class="divider"></li><li><a href="README.DeviceApi-Config.html">Device Detection API Config</a></li><li><a href="README.Upgrade.html">Device Detection API Upgrade</a></li><li class="divider"></li><li><a href="README.CarrierApi.html">Carrier Identification API</a></li><li><a href="./ApiDocs/carrier.html">Carrier API Docs</a></li><li class="divider"></li><li><a href="README.ClientSide.html">Client-side Component</a></li></ul></div>