Git Product home page Git Product logo

fingerprintjs / fingerprint-pro-server-api-java-sdk Goto Github PK

View Code? Open in Web Editor NEW
9.0 7.0 4.0 42.16 MB

Java SDK for Fingerprint Pro Server API

License: MIT License

Shell 0.45% Java 90.41% Mustache 8.89% JavaScript 0.25%
audio-fingerprinting browser browser-fingerprint browser-fingerprinting detection fingerprint fingerprinting fingerprintjs fingerprintjs-pro fraud fraud-detection identification java visitor-identification

fingerprint-pro-server-api-java-sdk's Introduction

Fingerprint logo

Jitpack Release CI badge CI badge CI badge Discord server

Fingerprint Pro Server API Java SDK

Fingerprint is a device intelligence platform offering 99.5% accurate visitor identification. The Fingerprint Server Java SDK is an easy way to interact with the Fingerprint Server API from your Java application. You can retrieve visitor history or individual identification events.

Automatically generated by the OpenAPI Generator

Requirements

The following versions of Gradle/Maven are supported

  • Maven (3.8.3+)
  • Gradle (7.2+)

The following versions of Java are supported

  • Java 1.8
  • Java 11
  • Java 17
  • Java 21

Installation

Maven users

Add this dependency to your project's POM:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
<dependency>
  <groupId>com.github.fingerprintjs</groupId>
  <artifactId>fingerprint-pro-server-api-java-sdk</artifactId>
  <version>v5.1.0</version>
</dependency>

Gradle users

Add this dependency to your project's build file:

  repositories {
     maven { url 'https://jitpack.io' }
  }

  dependencies {
     implementation "com.github.fingerprintjs:fingerprint-pro-server-api-java-sdk:v5.1.0"
  }

Others

At first generate the JAR by executing:

./gradlew jar

Then manually install the following JARs:

  • target/fingerprint-pro-server-api-sdk-5.1.0.jar

Usage

To add a HTTP proxy for the API client, use ClientConfig:

import org.glassfish.jersey.apache.connector.ApacheConnectorProvider;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import com.fingerprint.sdk.*;
import com.fingerprint.api.FingerprintApi;

...

ApiClient defaultClient = Configuration.getDefaultApiClient();
ClientConfig clientConfig = defaultClient.getClientConfig();
clientConfig.connectorProvider(new ApacheConnectorProvider());
clientConfig.property(ClientProperties.PROXY_URI, "http://proxy_url_here");
clientConfig.property(ClientProperties.PROXY_USERNAME, "proxy_username");
clientConfig.property(ClientProperties.PROXY_PASSWORD, "proxy_password");
defaultClient.setClientConfig(clientConfig);

FingerprintApi apiInstance = new FingerprintApi(defaultClient);

Getting Started

Please follow the installation instruction and execute the following Java code:

package main;

import com.fingerprint.api.FingerprintApi;
import com.fingerprint.models.EventResponse;
import com.fingerprint.models.Response;
import com.fingerprint.sdk.ApiClient;
import com.fingerprint.sdk.ApiException;
import com.fingerprint.sdk.Configuration;
import com.fingerprint.sdk.Region;

public class FingerprintApiExample {
    // Fingerprint Pro Secret API Key
    private static final String FPJS_API_SECRET = "Fingerprint Pro Secret API Key";
    // A mandatory visitorId of a specific visitor
    private static final String FPJS_VISITOR_ID = "visitorId";
    // An optional requestId made by a specific visitor
    private static final String FPJS_REQUEST_ID = "requestId";
    // An optional linkedId of the visit
    private static final String FPJS_LINKED_ID = "linkedId";
    // An optional parameter limiting scanned results
    private static final Integer LIMIT = 10;
    // An optional parameter used to paginate results, see lastTimestamp
    private static final String PAGINATION_KEY = "1683900801733.Ogvu1j";

    public static void main(String... args) {
        // Create a new api client instance from Configuration with your Fingerprint Pro Server API Key and your Fingerprint Pro Server API Region.
        /*
        You can specify a region on getDefaultApiClient function's second parameter
        If you leave the second parameter empty, then Region.GLOBAL will be used as a default region
        Options for regions are:
        Region.GLOBAL
        Region.EUROPE
        Region.ASIA
        */
        ApiClient client = Configuration.getDefaultApiClient(FPJS_API_SECRET, Region.EUROPE);
        FingerprintApi api = new FingerprintApi(client);
        // Get an event with a given requestId
        try {
            // Fetch the event with a given requestId
            EventResponse response = api.getEvent(FPJS_REQUEST_ID);
            System.out.println(response.getProducts().toString());
        } catch (ApiException e) {
            System.err.println("Exception when calling FingerprintApi.getEvent:" + e.getMessage());
        }
        // Get a specific visitor's all visits
        try {
            // Fetch all visits with a given visitorId, with a page limit
            Response response = api.getVisits(FPJS_VISITOR_ID, null, null, LIMIT, null, null);
            System.out.println(response.getVisits().toString());
        } catch (ApiException e) {
            System.err.println("Exception when calling FingerprintApi.getVisits:" + e.getMessage());
        }

        // Get a specific visitor's all visits with a linkedId
        try {
            // Fetch all visits with a given visitorId, with a page limit, skipping the first visit
            Response response = api.getVisits(FPJS_VISITOR_ID, null, FPJS_LINKED_ID, LIMIT, PAGINATION_KEY, null);
            System.out.println(response.getVisits().toString());
        } catch (ApiException e) {
            System.err.println("Exception when calling FingerprintApi.getVisits:" + e.getMessage());
        }

        // Use all the parameters on getVisits
        try {
            // Fetch the visitor's all visits with a given requestId and linkedId with a page limit while skipping the first visit
            Response response = api.getVisits(FPJS_VISITOR_ID, FPJS_REQUEST_ID, FPJS_LINKED_ID, LIMIT, PAGINATION_KEY, null);
            System.out.println(response.getVisits().toString());
        } catch (ApiException e) {
            System.err.println("Exception when calling FingerprintApi.getVisits:" + e.getMessage());
        }
    }
}

Sealed results

This SDK provides utility methods for decoding sealed results.

package com.fingerprint.example;

import com.fingerprint.Sealed;
import com.fingerprint.model.EventResponse;

import java.util.Base64;

public class SealedResults {
    public static void main(String... args) throws Exception {
        // Sealed result from the frontend.
        String SEALED_RESULT = System.getenv("BASE64_SEALED_RESULT");

        // Base64 encoded key generated in the dashboard.
        String SEALED_KEY = System.getenv("BASE64_KEY");

        final EventResponse event = Sealed.unsealEventResponse(
                Base64.getDecoder().decode(SEALED_RESULT),
                // You can provide more than one key to support key rotation. The SDK will try to decrypt the result with each key.
                new Sealed.DecryptionKey[]{
                        new Sealed.DecryptionKey(
                                Base64.getDecoder().decode(SEALED_KEY),
                                Sealed.DecryptionAlgorithm.AES_256_GCM
                        )
                }
        );

        // Do something with unsealed response, e.g: send it back to the frontend.
    }
}

To learn more, refer to example located in src/examples/java/com/fingerprint/example/SealedResults.java.

Documentation for API Endpoints

All URIs are relative to https://api.fpjs.io

Class Method HTTP request Description
FingerprintApi getEvent GET /events/{request_id} Get event by requestId
FingerprintApi getVisits GET /visitors/{visitor_id} Get visits by visitorId
FingerprintApi webhookTrace TRACE /webhook

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

ApiKeyHeader

  • Type: API key
  • API key parameter name: Auth-API-Key
  • Location: HTTP header

ApiKeyQuery

  • Type: API key
  • API key parameter name: api_key
  • Location: URL query string

Documentation for sealed results

Recommendation

It's recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issues.

Support

To report problems, ask questions or provide feedback, please use Issues. If you need private support, you can email us at [email protected].

License

This project is licensed under the MIT License.

fingerprint-pro-server-api-java-sdk's People

Contributors

dependabot[bot] avatar ilfa avatar jurouhlar avatar orkuncakilkaya avatar semantic-release-bot avatar sshelomentsev avatar theunderscorer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

fingerprint-pro-server-api-java-sdk's Issues

Exception when invoking FingerprintAPI getEvent() method

Hi, I'm trying to test the SDK and I get the following exception when invoking the getEvent() method on the FingerprintApi class.

java.lang.AbstractMethodError: Receiver class com.sun.jersey.api.uri.UriBuilderImpl does not define or inherit an implementation of the resolved method 'abstract javax.ws.rs.core.UriBuilder uri(java.lang.String)' of abstract class javax.ws.rs.core.UriBuilder.
        at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:96)
        at org.glassfish.jersey.client.JerseyWebTarget.<init>(JerseyWebTarget.java:50)
        at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:274)
        at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:56)
        at com.fingerprint.sdk.ApiClient.invokeAPI(ApiClient.java:1000)
        at com.fingerprint.api.FingerprintApi.getEventWithHttpInfo(FingerprintApi.java:133)
        at com.fingerprint.api.FingerprintApi.getEvent(FingerprintApi.java:78)

I'm using Gradle and added the dependency as per your documentation. Is there anything that I'm missing?

Any help would be greatly appreciated.

Java classes shadowing

Hi,

It seems this SDK is shadowing Jackson classes interfering with its usability in a project using Jackson.

The jar should not be containing these classes. Instead, it should declare Jackson and other libraries as a transitive dependency. If it's absolutely needed that this library cannot have dependencies they should be at the very least be shaded. I am attaching a screenshot of what your SDK currently contains and we can clearly see that a lot of Jackson related classes are added (while ./gradlew dependencies in a project using this SDK shows it has no transitive dependencies)

This issue comes from this line in the build.gradle file
from configurations.runtimeClasspath.findAll { it.name.endsWith('jar') }.collect { zipTree(it) }

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.