Skip to content
English
  • There are no suggestions because the search field is empty.

Enterprise API integration guide

Integrate AppSecEngineer’s API to fetch learning data, process it for reporting, automate report generation, and distribute insights via email or cloud storage.

Here’s your article cleaned up, de-duplicated, and formatted with proper code blocks. You can paste this directly into your knowledge base.


We provide most of the reports that are present in our dashboard as APIs, which can be integrated into your own system, Business Intelligence (BI) tools, or other dashboards/systems. This will provide insights and help you track progress directly in your own environment.

Find the API documentation at:
https://apidocs.appsecengineer.com


Steps

1. Generate API Keys

These APIs are authorized using API keys, which can be generated from the AppSecEngineer Admin section.

  1. Log in to the AppSecEngineer Portal.
  2. Go to Admin → Integrations → Enterprise APIs.
  3. You’ll find the API URL and a button to generate an API secret.
  4. Generate the API secret and make sure to store it securely.

2. Review API Docs

We provide different types of reports such as:

  • Reporting categorized by learning paths
  • Per-user reporting
  • Learning journeys reports

Carefully review:

  • The payload (request body)
  • HTTP method
  • API path

The required headers and other attributes are also documented in the API docs.


Example Code in Python

import requests

api_url = "https://api.appsecengineer.app/enterprise/report/proficiency-report"

headers = {
"X-ASE-API-Token": "<secret api key>",
"X-ASE-Customer-ID": "<customer id shown in dashboard>",
"Content-Type": "application/json",
}

body = {}

try:
response = requests.post(api_url, json=body, headers=headers)
if response.status_code == 200:
print("Request successful!")
print("Response:", response.json())
else:
print(f"Request failed with status code: {response.status_code}")
print("Response:", response.text)
except requests.exceptions.RequestException as e:
print("An error occurred:", e)

Note: We only support JSON data as both request and response.

The response can be transformed into CSV/sheet/PDF, etc., using your own system if needed. Or it can be directly represented in BI tools.


Process and Clean the Data

Objective: Prepare the retrieved data for reporting by extracting, cleaning, and organizing it.

  1. Parse the JSON response and extract relevant fields.
  2. Format the data (e.g., clean dates, remove unnecessary fields).
  3. Structure the data into a consistent format for report generation.

Example Python

cleaned_data = []

for item in data["results"]:
cleaned_data.append({
"date": item["date"],
"sales": item["sales"],
"transactions": item["transactions"],
})

Generate the Report

Objective: Create a professional report in the desired format (e.g., CSV, Excel, PDF, or HTML).

Options for Report Generation

CSV Format (using csv library)

import csv

keys = cleaned_data[0].keys()

with open("report.csv", mode="w", newline="") as file:
writer = csv.DictWriter(file, fieldnames=keys)
writer.writeheader()
writer.writerows(cleaned_data)

Excel Format (using pandas)

import pandas as pd

df = pd.DataFrame(cleaned_data)
df.to_excel("report.xlsx", index=False)

HTML Format

Generate web-friendly reports using HTML tables or templates.
(For example, you can use Jinja2 templates or directly construct HTML with tables from cleaned_data.)


Step 6: Automate Report Generation (Optional)

Objective: Schedule automated report generation for regular intervals (e.g., daily, weekly, monthly).

Automation Methods

  • Linux cron jobs: Automate execution of the script at specific intervals.
    Example (run at midnight daily):


    # Edit crontab
    crontab -e
    # Add the following line:
    0 0 * * * python3 /path/to/report_script.py
  • Windows Task Scheduler: Schedule scripts to run on Windows systems.

  • Cloud services: Use tools like AWS Lambda or Google Cloud Functions for serverless automation.


Step 7: Distribute the Report

Objective: Share the generated report with stakeholders or automate the distribution process.

Options for Distribution

Email (Python with smtplib)

import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email import encoders

sender_email = "your_email@example.com"
receiver_email = "receiver@example.com"
password = "your_email_password"

msg = MIMEMultipart()
msg["From"] = sender_email
msg["To"] = receiver_email
msg["Subject"] = "Monthly Sales Report"

attachment = MIMEBase("application", "octet-stream")
with open("report.csv", "rb") as file:
attachment.set_payload(file.read())

encoders.encode_base64(attachment)
attachment.add_header(
"Content-Disposition",
"attachment",
filename="report.csv",
)

msg.attach(attachment)

with smtplib.SMTP("smtp.example.com", 587) as server:
server.starttls()
server.login(sender_email, password)
server.sendmail(sender_email, receiver_email, msg.as_string())

Cloud Storage

Upload the report to platforms like Google Drive or AWS S3 and share access links.


Step 8: Monitor and Improve

Objective: Continuously optimize the report generation process.

  • Feedback collection: Gather input from stakeholders on the report’s accuracy, relevance, and design.
  • Improvements: Refine parameters, enhance formatting, and address any data inconsistencies.
  • Error handling: Implement error logging and handling to ensure reliability.

Track learning journey results through our guide on Reports about Learning Journeys.


Summary of Steps

  1. Select API: Identify the appropriate API for retrieving the required data.
  2. Authenticate: Set up secure access using API keys or OAuth tokens.
  3. Fetch Data: Retrieve data using well-configured API requests.
  4. Process Data: Clean and organize the data for analysis and reporting.
  5. Generate Report: Create reports in desired formats (CSV, Excel, PDF, HTML).
  6. Automate: Schedule recurring report generation using automation tools.
  7. Distribute: Share reports via email or upload them to cloud storage platforms.
  8. Monitor & Improve: Continuously test and enhance the process for reliability and usability.