fingerprintjs/fingerprint-pro-server-api-go-sdk

GitHub: fingerprintjs/fingerprint-pro-server-api-go-sdk

Fingerprint Pro Server API 的 Go SDK,用于在服务端查询设备智能数据并验证密封结果与 Webhook 签名。

Stars: 20 | Forks: 4

Fingerprint logo

CI badge CI badge CI badge Discord server

# Fingerprint Server Go SDK [Fingerprint](https://fingerprint.com/) 是一个提供业界领先准确性的设备智能平台。 此 Go 包由 [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) 项目自动生成: - API 版本: 3 - 包版本: 7.10.0 - 构建包: io.swagger.codegen.v3.generators.go.GoClientCodegen ## 环境要求 Go Lang 1.21 或更高版本 我们遵守 [Go 支持策略](https://go.dev/doc/devel/release) 并支持 Go 的最近两个主要版本。 ## 安装与使用 1. 从 GitHub 获取包: ``` go get github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v7/sdk ``` 2. 导入并使用该库: ``` package main import ( "context" "fmt" "github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v7/sdk" "log" ) func main() { cfg := sdk.NewConfiguration() client := sdk.NewAPIClient(cfg) // You can also use sdk.RegionUS or sdk.RegionAsia. Default one is sdk.RegionUS //cfg.ChangeRegion(sdk.RegionEU) // Configure authorization, in our case with API Key auth := context.WithValue(context.Background(), sdk.ContextAPIKey, sdk.APIKey{ Key: "SECRET_API_KEY", }) // Usually this data will come from your frontend app visitorId := "" requestId := "" opts := sdk.FingerprintApiGetVisitsOpts{ // Get visits for this requestId RequestId: requestId, } // Get visits for given visitorId and requestId visits, httpRes, err := client.FingerprintApi.GetVisits(auth, visitorId, &opts) fmt.Printf("%+v\n", httpRes) if err != nil { var tooManyRequestsError *sdk.TooManyRequestsError // Handle potential TooManyRequestsError if errors.As(err, &tooManyRequestsError) { log.Fatalf("Too many requests, retry after %d seconds", tooManyRequestsError.RetryAfter()) } else { // You can also use err.Model() and err.Body() to get more details about the error log.Printf("Error %s: %v", err.Code(), err) log.Fatal(err) } } fmt.Printf("Got response with visitorId: %s", visits.VisitorId) // Get event by given requestId event, httpRes, err := client.FingerprintApi.GetEvent(auth, requestId) if err != nil { // You can also use err.Model() and err.Body() to get more details about the error log.Printf("Error %s: %v", err.Code(), err) log.Fatal(err) } // Access identification details if event.Products.Identification != nil { fmt.Printf("Got response with Identification: %v", event.Products.Identification) } suspect := true opts := sdk.FingerprintApiSearchEventsOpts{ // Suspect can be set by using `UpdateEvent` method Suspect: &suspect, PaginationKey: "1740815825085" } // Search for 10 events with suspect=true searchEventsResult, httpRes, err := client.FingerprintApi.SearchEvents(auth, 10, &opts) if searchEventsResult.Events != nil { fmt.Printf("Got response with Events: %v \n", searchEventsResult.Events) } } ``` ### 区域 如果您的订阅位于美国以外的区域,您需要在配置中更改区域: ``` import ( "github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v7/sdk" ) func main() { cfg := sdk.NewConfiguration() cfg.ChangeRegion(sdk.RegionEU) // or sdk.RegionAsia } ``` ## 密封结果 此 SDK 提供用于解码[密封结果](https://dev.fingerprint.com/docs/sealed-client-results)的实用方法。 请按以下步骤安装密封结果依赖: ``` go get github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v7/sdk/sealed ``` 然后您可以使用以下代码解封结果: ``` package main import ( "encoding/base64" "fmt" "github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v7/sdk/sealed" "os" ) // Utility function to decode base64 string func base64Decode(input string) []byte { output, err := base64.StdEncoding.DecodeString(input) if err != nil { panic(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 := []sealed.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: sealed.AlgorithmAES256GCM, }, } unsealedResponse, err := sealed.UnsealEventsResponse(sealedResult, keys) if err != nil { panic(err) } // Do something with unsealed response, e.g: send it back to the frontend. fmt.Println(unsealedResponse) } ``` ## Webhook 签名 此 SDK 提供用于验证传入 [webhook](https://dev.fingerprint.com/docs/webhooks) 请求 HMAC 签名的实用方法。 请按以下步骤安装 webhook 依赖: ``` go get github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v7/sdk/webhook ``` 然后您可以使用以下代码验证签名: ``` package main import ( "github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v7/sdk/webhook" ) 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 := webhook.IsValidWebhookSignature(header, data, secret) if !isValid { panic("Invalid signature") } } ``` 要了解更多信息,请参考位于 [example/sealedResults.go](./example/sealedResults.go) 的示例。 ## API 端点文档 所有 URI 相对于 *https://api.fpjs.io* 类 | 方法 | HTTP 请求 | 描述 ------------ | ------------- | ------------- | ------------- *FingerprintApi* | [**DeleteVisitorData**](docs/FingerprintApi.md#deletevisitordata) | **Delete** /visitors/{visitor_id} | 根据 visitor ID 删除数据 *FingerprintApi* | [**GetEvent**](docs/FingerprintApi.md#getevent) | **Get** /events/{request_id} | 根据 request ID 获取事件 *FingerprintApi* | [**GetRelatedVisitors**](docs/FingerprintApi.md#getrelatedvisitors) | **Get** /related-visitors | 获取相关访客 *FingerprintApi* | [**GetVisits**](docs/FingerprintApi.md#getvisits) | **Get** /visitors/{visitor_id} | 根据 visitor ID 获取访问记录 *FingerprintApi* | [**SearchEvents**](docs/FingerprintApi.md#searchevents) | **Get** /events/search | 通过搜索获取事件 *FingerprintApi* | [**UpdateEvent**](docs/FingerprintApi.md#updateevent) | **Put** /events/{request_id} | 更新给定 request ID 的事件 ## 模型文档 - [Botd](docs/Botd.md) - [BotdBot](docs/BotdBot.md) - [BotdBotResult](docs/BotdBotResult.md) - [BrowserDetails](docs/BrowserDetails.md) - [ClonedApp](docs/ClonedApp.md) - [DeprecatedGeolocation](docs/DeprecatedGeolocation.md) - [DeveloperTools](docs/DeveloperTools.md) - [Emulator](docs/Emulator.md) - [ErrorCode](docs/ErrorCode.md) - [ErrorPlainResponse](docs/ErrorPlainResponse.md) - [ErrorResponse](docs/ErrorResponse.md) - [EventsGetResponse](docs/EventsGetResponse.md) - [EventsUpdateRequest](docs/EventsUpdateRequest.md) - [FactoryReset](docs/FactoryReset.md) - [Frida](docs/Frida.md) - [Geolocation](docs/Geolocation.md) - [GeolocationCity](docs/GeolocationCity.md) - [GeolocationContinent](docs/GeolocationContinent.md) - [GeolocationCountry](docs/GeolocationCountry.md) - [GeolocationSubdivision](docs/GeolocationSubdivision.md) - [HighActivity](docs/HighActivity.md) - [Identification](docs/Identification.md) - [IdentificationConfidence](docs/IdentificationConfidence.md) - [IdentificationSeenAt](docs/IdentificationSeenAt.md) - [Incognito](docs/Incognito.md) - [Integration](docs/Integration.md) - [IntegrationSubintegration](docs/IntegrationSubintegration.md) - [IpBlocklist](docs/IpBlocklist.md) - [IpBlocklistDetails](docs/IpBlocklistDetails.md) - [IpInfo](docs/IpInfo.md) - [IpInfoAsn](docs/IpInfoAsn.md) - [IpInfoDataCenter](docs/IpInfoDataCenter.md) - [IpInfoV4](docs/IpInfoV4.md) - [IpInfoV6](docs/IpInfoV6.md) - [Jailbroken](docs/Jailbroken.md) - [LocationSpoofing](docs/LocationSpoofing.md) - [MitMAttack](docs/MitMAttack.md) - [ModelError](docs/ModelError.md) - [PrivacySettings](docs/PrivacySettings.md) - [ProductBotd](docs/ProductBotd.md) - [ProductClonedApp](docs/ProductClonedApp.md) - [ProductDeveloperTools](docs/ProductDeveloperTools.md) - [ProductEmulator](docs/ProductEmulator.md) - [ProductFactoryReset](docs/ProductFactoryReset.md) - [ProductFrida](docs/ProductFrida.md) - [ProductHighActivity](docs/ProductHighActivity.md) - [ProductIdentification](docs/ProductIdentification.md) - [ProductIncognito](docs/ProductIncognito.md) - [ProductIpBlocklist](docs/ProductIpBlocklist.md) - [ProductIpInfo](docs/ProductIpInfo.md) - [ProductJailbroken](docs/ProductJailbroken.md) - [ProductLocationSpoofing](docs/ProductLocationSpoofing.md) - [ProductMitMAttack](docs/ProductMitMAttack.md) - [ProductPrivacySettings](docs/ProductPrivacySettings.md) - [ProductProximity](docs/ProductProximity.md) - [ProductProxy](docs/ProductProxy.md) - [ProductRawDeviceAttributes](docs/ProductRawDeviceAttributes.md) - [ProductRemoteControl](docs/ProductRemoteControl.md) - [ProductRootApps](docs/ProductRootApps.md) - [ProductSuspectScore](docs/ProductSuspectScore.md) - [ProductTampering](docs/ProductTampering.md) - [ProductTor](docs/ProductTor.md) - [ProductVelocity](docs/ProductVelocity.md) - [ProductVirtualMachine](docs/ProductVirtualMachine.md) - [ProductVpn](docs/ProductVpn.md) - [Products](docs/Products.md) - [Proximity](docs/Proximity.md) - [Proxy](docs/Proxy.md) - [ProxyConfidence](docs/ProxyConfidence.md) - [ProxyDetails](docs/ProxyDetails.md) - [RawDeviceAttribute](docs/RawDeviceAttribute.md) - [RawDeviceAttributeError](docs/RawDeviceAttributeError.md) - [RelatedVisitor](docs/RelatedVisitor.md) - [RelatedVisitorsResponse](docs/RelatedVisitorsResponse.md) - [RemoteControl](docs/RemoteControl.md) - [RootApps](docs/RootApps.md) - [Sdk](docs/Sdk.md) - [SearchEventsResponse](docs/SearchEventsResponse.md) - [SearchEventsResponseEvents](docs/SearchEventsResponseEvents.md) - [SupplementaryId](docs/SupplementaryId.md) - [SuspectScore](docs/SuspectScore.md) - [Tampering](docs/Tampering.md) - [Tor](docs/Tor.md) - [Velocity](docs/Velocity.md) - [VelocityData](docs/VelocityData.md) - [VelocityIntervals](docs/VelocityIntervals.md) - [VirtualMachine](docs/VirtualMachine.md) - [Visit](docs/Visit.md) - [VisitorsGetResponse](docs/VisitorsGetResponse.md) - [Vpn](docs/Vpn.md) - [VpnConfidence](docs/VpnConfidence.md) - [VpnMethods](docs/VpnMethods.md) - [Webhook](docs/Webhook.md) - [WebhookClonedApp](docs/WebhookClonedApp.md) - [WebhookDeveloperTools](docs/WebhookDeveloperTools.md) - [WebhookEmulator](docs/WebhookEmulator.md) - [WebhookFactoryReset](docs/WebhookFactoryReset.md) - [WebhookFrida](docs/WebhookFrida.md) - [WebhookHighActivity](docs/WebhookHighActivity.md) - [WebhookIpBlocklist](docs/WebhookIpBlocklist.md) - [WebhookIpInfo](docs/WebhookIpInfo.md) - [WebhookJailbroken](docs/WebhookJailbroken.md) - [WebhookLocationSpoofing](docs/WebhookLocationSpoofing.md) - [WebhookMitMAttack](docs/WebhookMitMAttack.md) - [WebhookPrivacySettings](docs/WebhookPrivacySettings.md) - [WebhookProximity](docs/WebhookProximity.md) - [WebhookProxy](docs/WebhookProxy.md) - [WebhookRemoteControl](docs/WebhookRemoteControl.md) - [WebhookRootApps](docs/WebhookRootApps.md) - [WebhookSupplementaryIDs](docs/WebhookSupplementaryIDs.md) - [WebhookSuspectScore](docs/WebhookSuspectScore.md) - [WebhookTampering](docs/WebhookTampering.md) - [WebhookTor](docs/WebhookTor.md) - [WebhookVelocity](docs/WebhookVelocity.md) - [WebhookVirtualMachine](docs/WebhookVirtualMachine.md) - [WebhookVpn](docs/WebhookVpn.md) ## 授权文档 ## ApiKeyHeader - **类型**: API key - **API key 参数名**: Auth-API-Key - **位置**: HTTP header ## ApiKeyQuery - **类型**: API key - **API key 参数名**: api_key - **位置**: URL query string ## 密封结果文档 - [SealedResults](docs/SealedResults.md) - [DecryptionKey](docs/DecryptionKey.md) ## Webhook 文档 - [DecryptionKey](docs/Webhook.md) ## 作者 support@fingerprint.com ## 支持与反馈 要报告问题、提问或提供反馈,请使用 [Issues](https://github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/issues)。如果您需要私人支持,可以发送电子邮件至 [oss-support@fingerprint.com](mailto:oss-support@fingerprint.com)。 ## 许可证 本项目基于 [MIT 许可证](https://github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/blob/main/LICENSE) 授权。
标签:API客户端, DNS解析, EVTX分析, Fingerprint Pro, Go SDK, Go语言, MIT许可, Swagger, 反欺诈, 开源项目, 日志审计, 服务端API, 机器人检测, 用户追踪, 程序破解, 网络信息安全, 设备指纹, 设备智能, 访问者识别, 账号安全, 风险控制