Skip to content

Commit

Permalink
Merge pull request #17 from fingerprintjs/feature/events_endpoint
Browse files Browse the repository at this point in the history
feat: introduce /event/{request_id} endpoint
  • Loading branch information
TheUnderScorer authored Sep 14, 2022
2 parents 62421d3 + 87b99c3 commit dfa5a14
Show file tree
Hide file tree
Showing 60 changed files with 3,440 additions and 51 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/functional_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches-ignore:
- main
schedule:
- cron: '0 5 * * *'
- cron: "0 5 * * *"

jobs:
functional_tests:
Expand All @@ -19,10 +19,11 @@ jobs:
- name: "Install dependencies"
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements.txt
- name: "Try to get data using SDK"
run: "python ./run_checks.py"
env:
PRIVATE_KEY: '${{ secrets.PRIVATE_KEY }}'
VISITOR_ID: '${{ secrets.VISITOR_ID }}'
PRIVATE_KEY: "${{ secrets.PRIVATE_KEY }}"
VISITOR_ID: "${{ secrets.VISITOR_ID }}"
REQUEST_ID: "${{ secrets.REQUEST_ID }}"
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true,
"env": {
"VISITOR_ID": "uYIm7Ksp5rf00SllPhFp",
"REQUEST_ID": "1662542583652.pLBzed",
"PRIVATE_KEY": "MMFSjCCXN0DeACxOAsA4"
}
}
]
}
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ configuration = fingerprint_pro_server_api_sdk.Configuration(api_key="SECRET_API

# create an instance of the API class
api_instance = fingerprint_pro_server_api_sdk.FingerprintApi(configuration)
```

## Examples

Fetching visits using visitorId:
```python
import fingerprint_pro_server_api_sdk
from fingerprint_pro_server_api_sdk import Response
from fingerprint_pro_server_api_sdk.rest import ApiException

configuration = fingerprint_pro_server_api_sdk.Configuration(api_key="SECRET_API_KEY")
api_instance = fingerprint_pro_server_api_sdk.FingerprintApi(configuration)

visitor_id = 'visitor_id_example' # str |
#request_id = 'request_id_example' # str | Filter events by requestId (optional)
#linked_id = 'linked_id_example' # str | Filter events by custom identifier (optional)
Expand All @@ -103,23 +116,52 @@ except ApiException as e:
print("Exception when calling DefaultApi->visitors_visitor_id_get: %s\n" % e)
```

Fetching events for requestId:
```python
import fingerprint_pro_server_api_sdk
from fingerprint_pro_server_api_sdk import EventResponse
from fingerprint_pro_server_api_sdk.rest import ApiException

configuration = fingerprint_pro_server_api_sdk.Configuration(api_key="SECRET_API_KEY")
api_instance = fingerprint_pro_server_api_sdk.FingerprintApi(configuration)

request_id = 'request_id_example' # str

try:
events_response: EventResponse = api_instance.get_event(request_id)

except ApiException as e:
print("Exception when calling DefaultApi->get_event: %s\n" % e)
```

## Documentation for API Endpoints

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

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*FingerprintApi* | [**get_event**](docs/FingerprintApi.md#get_event) | **GET** /events/{request_id} | Get event by request ID
*FingerprintApi* | [**get_visits**](docs/FingerprintApi.md#get_visits) | **GET** /visitors/{visitor_id} |

## Documentation For Models

- [BotdDetectionResult](docs/BotdDetectionResult.md)
- [BotdResult](docs/BotdResult.md)
- [BrowserDetails](docs/BrowserDetails.md)
- [Confidence](docs/Confidence.md)
- [ErrorResponse](docs/ErrorResponse.md)
- [ErrorResponseError](docs/ErrorResponseError.md)
- [EventResponse](docs/EventResponse.md)
- [IPLocation](docs/IPLocation.md)
- [IPLocationCity](docs/IPLocationCity.md)
- [Location](docs/Location.md)
- [ManyRequestsResponse](docs/ManyRequestsResponse.md)
- [ProductsResponse](docs/ProductsResponse.md)
- [ProductsResponseBotd](docs/ProductsResponseBotd.md)
- [ProductsResponseIdentification](docs/ProductsResponseIdentification.md)
- [ProductsResponseIdentificationData](docs/ProductsResponseIdentificationData.md)
- [Response](docs/Response.md)
- [ResponseVisits](docs/ResponseVisits.md)
- [StSeenAt](docs/StSeenAt.md)
- [Subdivision](docs/Subdivision.md)
- [Visit](docs/Visit.md)
Expand Down
9 changes: 9 additions & 0 deletions docs/BotdDetectionResult.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# BotdDetectionResult

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**result** | **str** | Bot detection result: * `notDetected` - the visitor is not a bot * `good` - good bot detected, such as Google bot, Baidu Spider, AlexaBot and so on * `bad` - bad bot detected, such as Selenium, Puppeteer, Playwright, headless browsers, and so on |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

11 changes: 11 additions & 0 deletions docs/BotdResult.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# BotdResult

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**ip** | **str** | IP address of the requesting browser or bot. |
**time** | **datetime** | Time in UTC when the request from the JS agent was made. We recommend to treat requests that are older than 2 minutes as malicious. Otherwise, request replay attacks are possible |
**bot** | [**BotdDetectionResult**](BotdDetectionResult.md) | |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

9 changes: 9 additions & 0 deletions docs/ErrorResponse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ErrorResponse

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**error** | [**ErrorResponseError**](ErrorResponseError.md) | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

10 changes: 10 additions & 0 deletions docs/ErrorResponseError.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# ErrorResponseError

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**code** | **str** | | [optional]
**message** | **str** | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

9 changes: 9 additions & 0 deletions docs/EventResponse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# EventResponse

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**products** | [**ProductsResponse**](ProductsResponse.md) | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

52 changes: 52 additions & 0 deletions docs/FingerprintApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,60 @@ All URIs are relative to *https://api.fpjs.io*

Method | HTTP request | Description
------------- | ------------- | -------------
[**get_event**](FingerprintApi.md#get_event) | **GET** /events/{request_id} | Get event by request ID
[**get_visits**](FingerprintApi.md#get_visits) | **GET** /visitors/{visitor_id} |

# **get_event**
> EventResponse get_event(request_id)
Get event by request ID

This endpoint allows you to get events with all the information from each activated product - BOTD and Fingerprinting. Use the requestId as a URL path :request_id parameter. This API method is scoped to a request, i.e. all returned information is by requestId.

### Example
```python
import fingerprint_pro_server_api_sdk
from fingerprint_pro_server_api_sdk import Response
from fingerprint_pro_server_api_sdk.rest import ApiException

# Configure API key authorization and region
configuration = fingerprint_pro_server_api_sdk.Configuration(api_key="SECRET_API_KEY")
# configuration = fingerprint_pro_server_api_sdk.Configuration(api_key="SECRET_API_KEY", region="eu")

# create an instance of the API class
api_instance = fingerprint_pro_server_api_sdk.FingerprintApi(configuration)
visitor_id = 'visitor_id_example' # str |
#request_id = 'request_id_example' # str | Filter events by requestId (optional)
#linked_id = 'linked_id_example' # str | Filter events by custom identifier (optional)
limit = 10 # int | Limit scanned results (optional)
#before = 56 # int | Used to paginate results (optional)

try:
api_response: Response = api_instance.get_visits(visitor_id, limit=2)
print(api_response)
except ApiException as e:
print("Exception when calling DefaultApi->visitors_visitor_id_get: %s\n" % e)
```

### Parameters

**request_id** | **str**| Request ID |

### Return type

[**EventResponse**](EventResponse.md)

### Authorization

[ApiKeyHeader](../README.md#ApiKeyHeader), [ApiKeyQuery](../README.md#ApiKeyQuery)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **get_visits**
> Response get_visits(visitor_id, request_id=request_id, linked_id=linked_id, limit=limit, before=before)
Expand Down
10 changes: 10 additions & 0 deletions docs/ProductsResponse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# ProductsResponse

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**identification** | [**ProductsResponseIdentification**](ProductsResponseIdentification.md) | | [optional]
**botd** | [**ProductsResponseBotd**](ProductsResponseBotd.md) | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

9 changes: 9 additions & 0 deletions docs/ProductsResponseBotd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ProductsResponseBotd

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**data** | [**BotdResult**](BotdResult.md) | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

9 changes: 9 additions & 0 deletions docs/ProductsResponseIdentification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ProductsResponseIdentification

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**data** | [**ProductsResponseIdentificationData**](ProductsResponseIdentificationData.md) | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

23 changes: 23 additions & 0 deletions docs/ProductsResponseIdentificationData.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# ProductsResponseIdentificationData

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**request_id** | **str** | Unique identifier of the user's identification request. |
**browser_details** | [**BrowserDetails**](BrowserDetails.md) | |
**incognito** | **bool** | Flag if user used incognito session. |
**ip** | **str** | |
**ip_location** | [**IPLocation**](IPLocation.md) | |
**timestamp** | **int** | Timestamp of the event with millisecond precision in Unix time. |
**time** | **datetime** | Time expressed according to ISO 8601 in UTC format. |
**url** | **str** | Page URL from which identification request was sent. |
**tag** | **dict(str, object)** | A customer-provided value or an object that was sent with identification request. | [optional]
**linked_id** | **str** | A customer-provided id that was sent with identification request. | [optional]
**confidence** | [**Confidence**](Confidence.md) | |
**visitor_found** | **bool** | Attribute represents if a visitor had been identified before. |
**first_seen_at** | [**StSeenAt**](StSeenAt.md) | |
**last_seen_at** | [**StSeenAt**](StSeenAt.md) | |
**visitor_id** | **str** | |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

2 changes: 1 addition & 1 deletion docs/Response.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**visitor_id** | **str** | |
**visits** | [**list[Visit]**](Visit.md) | |
**visits** | [**list[ResponseVisits]**](ResponseVisits.md) | |
**last_timestamp** | **int** | When more results are available (e.g., you scanned 200 results using `limit` parameter, but a total of 600 results are available), a special `lastTimestamp` top-level attribute is added to the response. If you want to paginate the results further in the past, you should use the value of this attribute. | [optional]
**pagination_key** | **str** | Visit's `requestId` of the last visit in the current page. | [optional]

Expand Down
22 changes: 22 additions & 0 deletions docs/ResponseVisits.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# ResponseVisits

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**request_id** | **str** | Unique identifier of the user's identification request. |
**browser_details** | [**BrowserDetails**](BrowserDetails.md) | |
**incognito** | **bool** | Flag if user used incognito session. |
**ip** | **str** | |
**ip_location** | [**IPLocation**](IPLocation.md) | |
**timestamp** | **int** | Timestamp of the event with millisecond precision in Unix time. |
**time** | **datetime** | Time expressed according to ISO 8601 in UTC format. |
**url** | **str** | Page URL from which identification request was sent. |
**tag** | **dict(str, object)** | A customer-provided value or an object that was sent with identification request. |
**linked_id** | **str** | A customer-provided id that was sent with identification request. | [optional]
**confidence** | [**Confidence**](Confidence.md) | |
**visitor_found** | **bool** | Attribute represents if a visitor had been identified before. |
**first_seen_at** | [**StSeenAt**](StSeenAt.md) | |
**last_seen_at** | [**StSeenAt**](StSeenAt.md) | |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

2 changes: 1 addition & 1 deletion docs/Visit.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Name | Type | Description | Notes
**timestamp** | **int** | Timestamp of the event with millisecond precision in Unix time. |
**time** | **datetime** | Time expressed according to ISO 8601 in UTC format. |
**url** | **str** | Page URL from which identification request was sent. |
**tag** | **dict(str, object)** | A customer-provided value or an object that was sent with identification request. |
**tag** | **dict(str, object)** | A customer-provided value or an object that was sent with identification request. | [optional]
**linked_id** | **str** | A customer-provided id that was sent with identification request. | [optional]
**confidence** | [**Confidence**](Confidence.md) | |
**visitor_found** | **bool** | Attribute represents if a visitor had been identified before. |
Expand Down
4 changes: 3 additions & 1 deletion docs/WebhookVisit.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**visitor_id** | **str** | |
**client_referrer** | **str** | | [optional]
**request_id** | **str** | Unique identifier of the user's identification request. |
**browser_details** | [**BrowserDetails**](BrowserDetails.md) | |
**incognito** | **bool** | Flag if user used incognito session. |
Expand All @@ -11,7 +13,7 @@ Name | Type | Description | Notes
**timestamp** | **int** | Timestamp of the event with millisecond precision in Unix time. |
**time** | **datetime** | Time expressed according to ISO 8601 in UTC format. |
**url** | **str** | Page URL from which identification request was sent. |
**tag** | **dict(str, object)** | A customer-provided value or an object that was sent with identification request. |
**tag** | **dict(str, object)** | A customer-provided value or an object that was sent with identification request. | [optional]
**linked_id** | **str** | A customer-provided id that was sent with identification request. | [optional]
**confidence** | [**Confidence**](Confidence.md) | |
**visitor_found** | **bool** | Attribute represents if a visitor had been identified before. |
Expand Down
10 changes: 10 additions & 0 deletions fingerprint_pro_server_api_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,23 @@
from fingerprint_pro_server_api_sdk.api_client import ApiClient
from fingerprint_pro_server_api_sdk.configuration import Configuration
# import models into sdk package
from fingerprint_pro_server_api_sdk.models.botd_detection_result import BotdDetectionResult
from fingerprint_pro_server_api_sdk.models.botd_result import BotdResult
from fingerprint_pro_server_api_sdk.models.browser_details import BrowserDetails
from fingerprint_pro_server_api_sdk.models.confidence import Confidence
from fingerprint_pro_server_api_sdk.models.error_response import ErrorResponse
from fingerprint_pro_server_api_sdk.models.error_response_error import ErrorResponseError
from fingerprint_pro_server_api_sdk.models.event_response import EventResponse
from fingerprint_pro_server_api_sdk.models.ip_location import IPLocation
from fingerprint_pro_server_api_sdk.models.ip_location_city import IPLocationCity
from fingerprint_pro_server_api_sdk.models.location import Location
from fingerprint_pro_server_api_sdk.models.many_requests_response import ManyRequestsResponse
from fingerprint_pro_server_api_sdk.models.products_response import ProductsResponse
from fingerprint_pro_server_api_sdk.models.products_response_botd import ProductsResponseBotd
from fingerprint_pro_server_api_sdk.models.products_response_identification import ProductsResponseIdentification
from fingerprint_pro_server_api_sdk.models.products_response_identification_data import ProductsResponseIdentificationData
from fingerprint_pro_server_api_sdk.models.response import Response
from fingerprint_pro_server_api_sdk.models.response_visits import ResponseVisits
from fingerprint_pro_server_api_sdk.models.st_seen_at import StSeenAt
from fingerprint_pro_server_api_sdk.models.subdivision import Subdivision
from fingerprint_pro_server_api_sdk.models.visit import Visit
Expand Down
Loading

0 comments on commit dfa5a14

Please sign in to comment.