Fingerprint is a device intelligence platform offering industry-leading accuracy. Fingerprint Server API allows you to search, update, and delete identification events in a server environment. It can be used for data exports, decision-making, and data analysis scenarios. Server API is intended for server-side usage, it's not intended to be used from the client side, whether it's a browser or a mobile device.
This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.
- API version: 4
- Package version: 8.1.0
- Generator version: 7.19.0
- Build package: org.openapitools.codegen.languages.GoClientCodegen
Go 1.21 or higher
We follow the Go support policy and support the last two major versions of Go.
- Get the package from GitHub:
go get "github.com/fingerprintjs/go-sdk/v8"- Import and use the library:
package main
import (
"context"
"fmt"
"github.com/fingerprintjs/go-sdk/v8"
"log"
)
func main() {
client := fingerprint.New(
// Configure authorization, in our case with API Key
fingerprint.WithAPIKey("SECRET_API_KEY"),
// You can also use fingerprint.RegionUS or fingerprint.RegionAsia. Default one is fingerprint.RegionUS
fingerprint.WithRegion(fingerprint.RegionEU),
)
// Usually this data will come from your frontend app
eventID := "<EVENT_ID>"
// Get visits for given visitorId and requestId
event, httpRes, err := client.GetEvent(context.Background(), eventID)
fmt.Printf("%+v\n", httpRes)
if err != nil {
if errResp, ok := fingerprint.AsErrorResponse(err); ok {
switch errResp.Error.Code {
case fingerprint.ErrorCodeEventNotFound:
log.Fatalf("Event not found")
default:
log.Printf("Error %s: %v", errResp.Error.Code, errResp)
log.Fatal(err)
}
}
}
fmt.Printf("Got response with visitorId: %s", event.Identification.VisitorID)
// Access identification details
if event.Identification != nil {
fmt.Printf("Got response with Identification: %v", event.Identification)
}
req := fingerprint.NewSearchEventsRequest().
// Suspect can be set by using `UpdateEvent` method
Suspect(true).
Limit(10)
// Search for 10 events with suspect=true
searchEventsResult, httpRes, err := client.SearchEvents(context.TODO(), req)
if err != nil {
if errResp, ok := fingerprint.AsErrorResponse(err); ok {
log.Printf("Error %s: %v", errResp.Error.Code, errResp)
}
log.Fatal(err)
}
if searchEventsResult.Events != nil {
fmt.Printf("Got response with Events: %v \n", searchEventsResult.Events)
}
}Note You can also check examples located in example directory. To run the examples:
cd example && FINGERPRINT_API_KEY=SECRET_API_KEY EVENT_ID=EVENT_ID_EXAMPLE go run getEvent.goAlternatively, you can define your environment variables inside
example/.envfile and run the examples without passing them as arguments. If your subscription region is not the “Global/US” region, useREGION=euorREGION=apin the line above or in your local.envfile.
If your subscription is in region other than US, you need to change the region in the configuration:
import (
"github.com/fingerprintjs/go-sdk/v8"
)
func main() {
client := fingerprint.New(
fingerprint.WithAPIKey("SECRET_API_KEY"),
fingerprint.WithRegion(fingerprint.RegionEU), // or fingerprint.RegionAsia, defaults to fingerprint.RegionUS
)
}This SDK provides utility methods for decoding sealed results. Use below code to unseal results:
package main
import (
"encoding/base64"
"fmt"
"github.com/fingerprintjs/go-sdk/v8"
"log"
"os"
)
// Utility function to decode base64 string
func base64Decode(input string) []byte {
output, err := base64.StdEncoding.DecodeString(input)
if err != nil {
log.Fatal(err)
}
return output
}
func main() {
// Sealed result from the frontend.
sealedResult := base64Decode(os.Getenv("BASE64_SEALED_RESULT"))
// Base64 encoded key generated in the dashboard.
key := base64Decode(os.Getenv("BASE64_SEALED_RESULT_KEY"))
keys := []fingerprint.DecryptionKey{
// You can provide more than one key to support key rotation. The SDK will try to decrypt the result with each key.
{
Key: key,
Algorithm: fingerprint.AlgorithmAES256GCM,
},
}
unsealedResponse, err := fingerprint.UnsealEventsResponse(sealedResult, keys)
if err != nil {
panic(err)
}
// Do something with unsealed response, e.g: send it back to the frontend.
fmt.Println(unsealedResponse)
}To learn more, refer to example located in example/sealedResults.go.
This SDK provides utility method for verifying the HMAC signature of the incoming webhook request.
Use below code to verify signature:
package main
import (
"github.com/fingerprintjs/go-sdk/v8"
)
func main() {
// Your webhook signing secret.
secret := "secret"
// Request data. In real life scenario this will be the body of incoming request
data := []byte("data")
// Value of the "fpjs-event-signature" header.
header := "v1=1b2c16b75bd2a870c114153ccda5bcfca63314bc722fa160d690de133ccbb9db"
isValid := fingerprint.IsValidWebhookSignature(header, data, secret)
if !isValid {
panic("Invalid signature")
}
}To learn more, refer to example located in example/webhookSignature.go.
All URIs are relative to https://api.fpjs.io/v4
| Class | Method | HTTP request | Description |
|---|---|---|---|
| FingerprintAPI | GetEvent | Get /events/{event_id} | Get an event by event ID |
| FingerprintAPI | SearchEvents | Get /events | Search events |
| FingerprintAPI | UpdateEvent | Patch /events/{event_id} | Update an event |
| FingerprintAPI | DeleteVisitorData | Delete /visitors/{visitor_id} | Delete data by visitor ID |
- BotInfo
- BotResult
- BrowserDetails
- Canvas
- Emoji
- Error
- ErrorCode
- ErrorResponse
- Event
- EventRuleAction
- EventRuleActionAllow
- EventRuleActionBlock
- EventSearch
- EventUpdate
- FontPreferences
- Geolocation
- GeolocationSubdivisionsInner
- IPBlockList
- IPInfo
- IPInfoV4
- IPInfoV6
- Identification
- IdentificationConfidence
- IncrementalIdentificationStatus
- Integration
- IntegrationSubintegration
- PluginsInner
- PluginsInnerMimeTypesInner
- Proximity
- ProxyConfidence
- ProxyDetails
- RawDeviceAttributes
- RequestHeaderModifications
- RuleActionHeaderField
- RuleActionType
- SDK
- SearchEventsBot
- SearchEventsIncrementalIdentificationStatus
- SearchEventsSDKPlatform
- SearchEventsVPNConfidence
- SupplementaryIDHighRecall
- TamperingConfidence
- TamperingDetails
- TouchSupport
- VPNConfidence
- VPNMethods
- Velocity
- VelocityData
- WebGlBasics
- WebGlExtensions
- Type: HTTP Bearer token authentication
- API key parameter name: Authorization
- Location: HTTP header
To report problems, ask questions, or provide feedback, please use Issues. If you need private support, you can email us at oss-support@fingerprint.com.
This project is licensed under the MIT license.