# Introduction Source: https://help.cryptolens.io/api-reference/introduction Our Web API reference is currently available at [https://app.cryptolens.io/docs/api/v3/](https://app.cryptolens.io/docs/api/v3/) For [AI-assisted integrations](/getting-started/build-with-ai) or full API reference search, use [**llms-full.txt**](https://app.cryptolens.io/docs/api/v3/llms-full.txt)**.** It contains the complete Devolens, formerly Cryptolens, API documentation in an LLM-friendly format. # Basics of Cryptolens Source: https://help.cryptolens.io/basics/index Basic concepts of Cryptolens Cryptolens Payments Overview Pn Cryptolens is a software licensing platform that does the following: * **Licensing**: keeping track of all instances of your software. For example, you can restrict which features a customer should have access to, on how many devices they should be able to run the application, keep track usage of individual features as well as ensure that a license stops working after the expiration date. * **Payment processing**: automating selling of your software, either through Cryptolens (supports Stripe & PayPal) or by integrating it with external payment providers (e.g. FastSpring or your own system). * **Analytics of usage data**: Analyse the usage of your software globally or on user level. ## Cryptolens Platform Cryptolens platform is accessed through the [app.cryptolens.io](http://app.cryptolens.io). This is the central place where you can control all your applications. It allows you to: * Implement licensing * Process payments * Analyse usage ## Cryptolens Client API To make sure that your applications can communicate with our server, you can use one of our [client libraries](https://help.cryptolens.io/web-api/skm-client-api). A client library provides an implementation of all the methods of the Web API as well as several other methods that are useful. A client library is not necessary to be able to verify a license, but it makes it easier. By adding a small code snippet (read more [here](/examples/key-verification)), it enables you to translate your licensing model into simple logic, as shown below: ```c# theme={null} if(license.HasFeature(1) .HasNotExpired() .IsValid()) { // do something } else { // invalid license. } ``` ## Next * [Learn about ‘products’ and ‘keys’](/basics/product-and-keys) # Products and Key Source: https://help.cryptolens.io/basics/product-and-keys Products and Keys in Cryptolens Product Key Relation Pn ## Key A (license) key is a 20 letters long string, eg. `MUYVD-LSEBY-CXHRQ-XFAGY`, that has license information associated with it. For example, it can store info such as: * Trial key or subscription (time-limited) * Customer information * Custom variables These are just some of the examples of what a key can do. ## Product A Product is a way to organize your keys. Normally, you will name the product the same as your application. For serial key generation purposes, you will need to specify an algorithm: either [SKGL or SKM15](https://help.cryptolens.io/web-interface/skgl-vs-skm15). We recommend to use the default SKM15. ## Next * [Learn the basics about our Web API](/basics/webapi) # Web API Source: https://help.cryptolens.io/basics/webapi Web Api Illustration Pn ## Talking to Web API Web API can be thought of as a channel that can be used to talk to Cryptolens Platform from your application and third party services. It contains a wide range of methods, which allow you to activate keys, create new ones, analyse usage data, and so much more. ### Cryptolens Client APIs This is a set of client libraries that you can add into your project to faciliate license key verification. You can find out more [here](https://help.cryptolens.io/web-api/skm-client-api). ### Direct Communication If you are targeting a language for which there is no client library, you can still take advantage of the functionality of Cryptolens’s Web API. For example, in order to retrieve key information in JSON, you can call ``` https://app.cryptolens.io/api/key/GetKey?token={accesstoken}&ProductId=1234&Key=MUYVD-LSEBY-CXHRQ-XFAGY&Sign=True ``` You can find more [here](https://app.cryptolens.io/docs/api/v3/). ## Next steps You’ve now learned about the basic concepts of Cryptolens. Here’s what’s next: 1. [Get started with a pratical implementation](https://help.cryptolens.io/getting-started/index) 2. [Learn more about possible licensing models](https://help.cryptolens.io/licensing-models/licensetypes) 3. [Understand GDPR and its implications](https://help.cryptolens.io/legal/GDPR) # Changelog Source: https://help.cryptolens.io/changelog/index Updates are available on the following page: [https://app.cryptolens.io/App/Changes](https://app.cryptolens.io/App/Changes) # Data analysis and reports Source: https://help.cryptolens.io/examples/data-analysis Example of how to analyse various data sources in Cryptolens ## Introduction There are several data sources you can use to analyse the usage of your application and generate audit reports. We will describe them in more detail below and provide several examples of how they can be analysed. ## Data sources * [Web API Log](https://app.cryptolens.io/docs/api/v3/model/WebAPILog) - contains a list events that are created each time a license changes (eg. activation or change of expiration date). Data object changes are also logged in this log. Note, this log contains minimal information about the event. * [Events Log](https://app.cryptolens.io/docs/api/v3/model/EventObject) - contains events that were registered using [Register Event](https://app.cryptolens.io/docs/api/v3/RegisterEvent) as well several other internal events. * [Object Log](https://app.cryptolens.io/docs/api/v3/model/ObjectLog) - contains a list of events that are created when certain object types are added or modified to allow you to track all changes made by you and your team members. ## Analysis We suggest to review the [following repository](https://github.com/Cryptolens/reporting-tools) to check if the report that you need to create is already available. As always, please let us know should you have any questions at [support@cryptolens.io](mailto:support@cryptolens.io). The easiest way to analyse the logs is using our [Python SDK](https://github.com/Cryptolens/cryptolens-python) in combination with [Anaconda](https://www.anaconda.com/) to manage the packages. Let’s look at how we can get some basics stats on the ratio of successful vs. unsuccessful requests. First, we need to load the relevant data: ```python theme={null} from datetime import datetime, timedelta, date from licensing.models import * from licensing.methods import Key, Helpers import pandas as pd import matplotlib.pyplot as plt from tools import * month_back = int(datetime.datetime.timestamp(datetime.datetime.today() - datetime.timedelta(days=30))) logs = [] ending_before=0 """ Loading the data """ while True: res = Key.get_web_api_log(token=get_api_token(), order_by="Id descending", limit = 1000, ending_before=ending_before) if res[0] == None: break logs = logs + res[0] if res[0][-1]["time"] < month_back: break; ending_before = res[0][-1]["id"] logs = pd.DataFrame(logs) logs = logs[logs["time"]>month_back] ``` Once we have the data in a pandas DataFrame, let’s create the plot: ```python theme={null} def success(state): return state % 100 // 10 - 1 logs["Success"] = success(logs["state"]) logs[logs["Success"]== 0] = "Success" logs[logs["Success"]== 1] = "Failure" logs["Success"].value_counts(normalize=True).plot(kind="bar", title='Successful vs. unsuccessful API requests') ``` This will create the following plot: Data Analysis Successfulratio Pn # Data collection Source: https://help.cryptolens.io/examples/data-collection Explains how data is being collected and how additional data can be supplied for better insights ## Idea By default, Cryptolens [logs](https://app.cryptolens.io/docs/api/v2/WebAPILog) many of the requests made to the Web API. This includes all [data object methods](https://app.cryptolens.io/docs/api/v3/Data) and all [key methods](https://app.cryptolens.io/docs/api/v3/Key) except for [Get Key](https://app.cryptolens.io/docs/api/v3/GetKey). However, these logs contain limited information and may not capture all events that could be useful from an analytics standpoint. When you deploy your product, it can for instance be useful to know the OS it’s running on or what features customers use the most, etc. Although these are useful on their own, when you link them together, you can get even better insights that can aid you in business critical decision making. For example, if you link transaction data with the OS data, you can see which OS brings you most of the revenue. If you see that a certain OS version does not bring in significant revenues, you can use this as basis to stop supporting it. In Cryptolens, additional data is referred to as **events** and can be gathered using [analytics methods](https://app.cryptolens.io/docs/api/v3/AI) in the Web API. We will cover these in the implementation section. ## Implementation ### In the app To register an event, you can call the [AI.RegisterEvent](https://help.cryptolens.io/api/dotnet/api/SKM.V3.Methods.AI.html#SKM_V3_Methods_AI_RegisterEvent_System_String_SKM_V3_Models_RegisterEventModel_) method. Most of the parameters are optional, but it’s useful to at least supply a `FeatureName` and either `Key` or `MachineCode`. If you just have one product, `ProductId` is not necessary, but it’s useful if you have multiple products. The code snippet below can be used to register event, in our case that the user started `YearReportGenerator` module. ```c# theme={null} AI.RegisterEvent("access token with RegisterEvent permission", new RegisterEventModel { EventName = "start", FeatureName = "YearReportGenerator", Key= "AAAA-BBBB-CCCC-DDDD", MachineCode = Helpers.GetMachineCode(), ProductId = 3, Metadata = Helpers.GetOSStats() }); ``` If you are on a platform that does not support this method, you can always send in data using by calling the URL below: ``` https://app.cryptolens.io/api/ai/RegisterEvent?token=&EventName=start&FeatureName=YearReportGenerator&Key=AAAA-BBBB-CCCC-DDDD&ProductId=3&MachineCode=& ``` ### Integration with payment providers In order to track transactions, we can use the same [AI.RegisterEvent](https://help.cryptolens.io/api/dotnet/api/SKM.V3.Methods.AI.html#SKM_V3_Methods_AI_RegisterEvent_System_String_SKM_V3_Models_RegisterEventModel_) method, but supply different set of parameters. To record the value, we can use the parameters `Value` and `Currency`. This can either be accomplished by calling the Web API directly or `AI.RegisterEvent` method (in case your backend is in .NET). Let’s assume your customer has have paid 30 usd for the product. In that case, you can call the following url: ``` https://app.cryptolens.io/api/ai/RegisterEvent?token=&Value=30&Currenc ``` # Introduction Source: https://help.cryptolens.io/examples/index In this section, we have listed several examples to help you get started. The focus is on applications targeting .NET, however Cryptolens does work with other languages too. You can find more examples in repositories associated with respective [client API](https://help.cryptolens.io/web-api/skm-client-api). If you want to explore other licensing models, we recommend to review [licensing models](https://help.cryptolens.io/licensing-models/licensetypes) section, where all examples have code suggestions in .NET. Depending on the platform (eg. Unity, Android, etc), we recommend to review [this page](https://help.cryptolens.io/getting-started/index) for platform specific advice. ## Inside your application * [Key verification](/examples/key-verification) - prepared example for key verification (C#, [VB.NET](http://VB.NET), Java, Python, C++). * [Offline key verification](/examples/offline-verification) - prepared example for offline key verification (C#, [VB.NET](http://VB.NET)). * [Creating verified trials](/examples/verified-trials) - prepared example showing how to create verified trials (C#, [VB.NET](http://VB.NET)). ## External services * [Key generation](/examples/key-generation) - key generation (useful when integrating with third party payment services). ## Licensing models * [Perpetual licensing (try & buy)](/licensing-models/perpetual) * [Recurring payments (SaaS)](https://help.cryptolens.io/licensing-models/subscription) # Integration with n8n Source: https://help.cryptolens.io/examples/integration-with-n8n Devolens (formerly Cryptolens) offers a n8n integration (node) that you can use in a similar way as our [Zapier app](/examples/zapier). You can find out more about the methods that are supported on [this page](https://n8n.io/integrations/cryptolens-devolens/). If any method that you need is missing, please let our support team know. ## Use cases Similar to Zapier, the goal of the n8n integration is allow you to integrate Cryptolens with other services. Typically, our customers use it to automate: 1. License key delivery upon a successful payment. 2. Populate a CRM when a new license is created. 3. Create a new license for a lead in a CRM. 4. Sending automatic reminders to customers when their license is about to expire. ### Examples Our n8n node was released recently and we are still working on documenting how it can be used. Please feel free to reach out to us, help (at) [devolens.com](http://devolens.com) or through the chat box. Below, we have listed a few use cases and the general idea of how to implement them. **License key delivery when a payment succeeds** For this example, let's assume you are using [Stripe Checkout](https://stripe.com/en-se/payments/checkout) to process payments. Once a customer has activated a subscription, you can capture this event using [Stripe's n8n node](https://n8n.io/integrations/stripe/) and call Cryptolens to issue a license. Once the license is issued, you can call an email service (e.g. [Send email service](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.sendemail/)) to send the license to a customer. **Populate a CRM once a license is issued** Our n8n integration contains an action called Get Web API Log (in the AI tab) that you can use to capture events. To capture all events related to issuance of a license, you can filter on States 3010 and 3011. Once you have the event, you can call the CRM that you are using. # Key Generation Source: https://help.cryptolens.io/examples/key-generation Example of how to create new keys using our API. Being able to create new license keys through external applications is important if you want to integrate Cryptolens with an external providers (eg. for payments, distribution etc). For example, if you already have a web store in place and want to keep using it, you can still use Cryptolens for eg. software licensing. This article describes the way you can generate keys by a simple web request through another website or an application. The goal is to automate software distribution by allowing your customers to receive valid license keys upon successful payments. ## Generating a Key Once you have enabled key generation, you are able to generate a new key. The simplest way is to assign all parameters (can be found here) to get a link that will return the specific key you want. A quick way to get that link without actually reading the Web API documentation is as following: 1. Select the product: [https://app.cryptolens.io/Product](https://app.cryptolens.io/Product) 2. Press Create New Key 3. Fill in all the parameters (such as set time, features, etc.) 4. Press on the \ button. 5. Copy the link in the textbox. Done! If you try to visit the link, you will notice that a new key will be returned. If you prefer to get a json object instead, please add \&json=true . # Key verification Source: https://help.cryptolens.io/examples/key-verification This guide shows the steps to perform a simple key verification using one of our SDKs/libraries.