Getting started overview
Integrating with License-API allows developers to manage software licenses, generate subscription keys, and implement secure product activation processes. This guide outlines the steps for new users to get started, from account creation to making a successful API call. The core process involves signing up for a License-API account, generating API credentials, and then using these credentials to authenticate requests to the License-API endpoints.
Before proceeding, ensure you have a basic understanding of RESTful API principles and how to make HTTP requests from your chosen programming environment. License-API supports various SDKs, including Python and Node.js, to streamline integration. Familiarity with HTTP authentication methods, particularly API key-based authentication, will be beneficial.
Here's a quick reference for the getting started process:
| Step | What to do | Where |
|---|---|---|
| 1. Sign Up | Register for a free Developer Plan account. | License-API Sign Up Page |
| 2. Obtain API Key | Generate your unique API Key from the dashboard. | License-API Dashboard > Settings > API Keys |
| 3. Install SDK (Optional) | Install the appropriate SDK for your programming language. | License-API SDK Documentation |
| 4. Make First Request | Construct and send an API request to create a license. | Your development environment, using the API Key and SDK/HTTP client. |
| 5. Verify Response | Check the API response for success and the new license details. | Your development environment. |
Create an account and get keys
To begin using License-API, you need to create an account. The platform offers a free Developer Plan, which is suitable for initial testing and integration. This plan includes support for up to 100 licenses and 1000 requests per month, allowing developers to explore the API's functionality without immediate cost.
- Navigate to the Sign Up Page: Go to the official License-API sign-up page.
- Complete Registration: Fill in the required details, such as your email address and a secure password.
- Verify Email: Check your inbox for a verification email and follow the instructions to activate your account.
- Access Dashboard: Once verified, log in to your License-API dashboard.
After successfully logging in, the next crucial step is to obtain your API credentials. License-API uses API keys for authentication, providing a secure method to identify your application when making requests. These keys should be treated as sensitive information and kept confidential.
- Go to API Keys Section: From your dashboard, navigate to the "Settings" or "API Keys" section. The exact path may vary slightly but is typically found under your profile or account management settings.
- Generate New Key: Look for an option to "Generate New API Key" or "Create Key." You might be prompted to give your key a descriptive name (e.g., "Development Key," "Production Key").
- Copy Your API Key: Once generated, your API key will be displayed. It's important to copy this key immediately, as it may only be shown once for security reasons. Store it in a secure location, such as an environment variable or a secrets management system, rather than hardcoding it directly into your application code.
Your API key will be used in the Authorization header of your HTTP requests, typically as a Bearer token. For example: Authorization: Bearer YOUR_API_KEY. This standard OAuth 2.0 Bearer Token usage ensures secure communication with the API endpoints.
Your first request
With your API key in hand, you are ready to make your first request to the License-API. This example demonstrates creating a new software license using the /licenses endpoint. We'll show examples in Python and Node.js, which are among the primary language examples provided by License-API.
Using Python
First, install the License-API Python SDK:
pip install license-api-python
Then, use the following Python code to create a license:
import os
from license_api import LicenseAPI
# Replace with your actual API key, ideally from environment variables
api_key = os.environ.get("LICENSE_API_KEY")
if not api_key:
print("Error: LICENSE_API_KEY environment variable not set.")
exit(1)
client = LicenseAPI(api_key)
try:
# Define the license data
license_data = {
"product_id": "prod_123", # Replace with an actual product ID from your dashboard
"user_id": "user_abc", # Replace with an actual user ID
"expires_at": "2027-12-31T23:59:59Z", # ISO 8601 format
"max_activations": 5,
"metadata": {
"customer_name": "Acme Corp",
"plan": "premium"
}
}
# Create the license
new_license = client.licenses.create(license_data)
print("License created successfully:")
print(f" Key: {new_license['key']}")
print(f" Status: {new_license['status']}")
print(f" Expires At: {new_license['expires_at']}")
print(f" Activations Left: {new_license['activations_left']}")
print(f" Full Response: {new_license}")
except Exception as e:
print(f"Error creating license: {e}")
Using Node.js
First, install the License-API Node.js SDK:
npm install license-api-nodejs
Then, use the following Node.js code to create a license:
require('dotenv').config(); // For loading environment variables from .env file
const { LicenseAPI } = require('license-api-nodejs');
// Replace with your actual API key, ideally from environment variables
const apiKey = process.env.LICENSE_API_KEY;
if (!apiKey) {
console.error('Error: LICENSE_API_KEY environment variable not set.');
process.exit(1);
}
const client = new LicenseAPI(apiKey);
async function createLicense() {
try {
// Define the license data
const licenseData = {
product_id: 'prod_123', // Replace with an actual product ID from your dashboard
user_id: 'user_abc', // Replace with an actual user ID
expires_at: '2027-12-31T23:59:59Z', // ISO 8601 format
max_activations: 5,
metadata: {
customer_name: 'Acme Corp',
plan: 'premium',
},
};
// Create the license
const newLicense = await client.licenses.create(licenseData);
console.log('License created successfully:');
console.log(` Key: ${newLicense.key}`);
console.log(` Status: ${newLicense.status}`);
console.log(` Expires At: ${newLicense.expires_at}`);
console.log(` Activations Left: ${newLicense.activations_left}`);
console.log(' Full Response:', newLicense);
} catch (error) {
console.error('Error creating license:', error.message);
}
}
createLicense();
Remember to replace 'prod_123' and 'user_abc' with actual IDs relevant to your License-API account setup. You can find or create these product and user entities within your License-API dashboard.
Common next steps
After successfully making your first API call, consider these common next steps to further integrate License-API into your application:
- Explore Other Endpoints: Review the License-API reference documentation to understand available endpoints for activating, deactivating, validating, and managing licenses. Key endpoints include
/licenses/{key}/activate,/licenses/{key}/deactivate, and/licenses/{key}/validate. - Implement Webhooks: Set up webhooks to receive real-time notifications about license events, such as activation, deactivation, or expiration. This can help keep your application's state synchronized with License-API. Refer to the License-API Webhooks documentation for setup details.
- Integrate with Your Product: Incorporate the license validation logic directly into your software or service. This typically involves calling the License-API to check a user's license status during product startup or feature access.
- Error Handling: Implement robust error handling in your code to gracefully manage API errors, network issues, and invalid license states. The API typically returns standard HTTP status codes and JSON error bodies.
- Security Best Practices: Ensure your API key is securely stored and transmitted. Avoid hardcoding keys directly in your source code. Use environment variables, a secrets manager, or a secure configuration system.
- Monitor Usage: Utilize the License-API dashboard to monitor your API usage, license counts, and track key metrics. This helps in understanding consumption and planning for scaling.
- Upgrade Plan: If your needs exceed the Developer Plan limits, review the License-API pricing page and consider upgrading to a paid plan.
Troubleshooting the first call
Encountering issues during your first API call is common. Here are some troubleshooting tips for License-API:
- Check API Key:
- Is it correct? Double-check that the API key you are using matches the one generated in your License-API dashboard.
- Is it expired or revoked? Ensure the key is still active. You might need to generate a new one if it was inadvertently deleted or expired.
- Is it correctly formatted? For most requests, the API key should be in the
Authorization: Bearer YOUR_API_KEYheader. Ensure there are no typos or extra spaces.
- Verify Endpoint URL: Confirm that the base URL and specific endpoint path (e.g.,
https://api.license-api.com/v1/licenses) are correct as specified in the API reference. - Review Request Body:
- JSON Format: Ensure your request body is valid JSON. Use an online JSON validator if unsure.
- Required Fields: Check that all mandatory fields (e.g.,
product_id,user_idfor license creation) are included and correctly formatted according to the License-API documentation for creating a license. - Data Types: Verify that data types (e.g., string for IDs, ISO 8601 for dates) match the API's expectations.
- HTTP Status Codes:
- 401 Unauthorized: Often indicates an incorrect or missing API key.
- 400 Bad Request: Suggests an issue with your request body or parameters (e.g., missing required fields, invalid data format).
- 403 Forbidden: Your API key might not have the necessary permissions for the requested action, or you've hit a rate limit.
- 404 Not Found: The endpoint URL is incorrect, or the resource you're trying to access (e.g., a specific license by key) does not exist.
- 5xx Server Error: Less common, but indicates an issue on the License-API's side. If this persists, check the License-API status page or contact support.
- Check SDK Version: If you're using an SDK, ensure it's up-to-date. Outdated SDKs might not support the latest API features or could contain bugs.
- Consult Documentation and Support: The License-API documentation is the primary resource. If you're still stuck, check their FAQ or contact their support team.