URLs of SMARTFENSE APIs
Below, we list all the available APIs in SMARTFENSE:
Interactive Modules: https://instancia.takesecurity.com/api/related-training-campaigns/
Newsletters: https://instancia.takesecurity.com/api/related-newsletter-campaigns/
Phishing: https://instancia.takesecurity.com/api/related-phishing-campaigns/
Ransomware: https://instancia.takesecurity.com/api/related-ransomware-campaigns/
Videos: https://instancia.takesecurity.com/api/related-video-campaigns/
Exams: https://instancia.takesecurity.com/api/related-exam-campaigns/
Surveys: https://instancia.takesecurity.com/api/related-survey-campaigns/
Important: You will need to replace the word "instancia" in each API URL with the subdomain of the specific instance.
To connect our APIs to Microsoft Power BI:
1- Open Power BI. Go to the "Get data from other sources" section.
2- In the "Get Data" window, select "Other" from the left-side menu and then choose "Web." Click on "Connect."
3- Select "Basic" and enter the URL of the API you want to connect in the "URL" field. Then, click "OK."
2- If the information obtained through the API exceeds 100 rows, we need to use a function to display data from all the pages, as the data is paginated in sets of 100 rows.
2.1- In the Queries section, below the already created query, right-click > New Query > Blank Query.
// Function to get a page of data
GetPage = (url as text) =>
let
Source = Json.Document(Web.Contents(url)),
Results = Source[results],
NextPage = if Record.HasFields(Source, "next") then Source[next] else null
in
[Results=Results, NextPage=NextPage]
in
GetPage
// URL inicial de la API
InitialUrl = "https://instancia.takesecurity.com/api/related-training-campaigns/?page=1",
// Función para obtener todas las páginas
GetAllPages = (url as text) =>
let
// Inicializar la primera página
FirstPage = GetPage(url),
FirstResults = FirstPage[Results],
FirstNextPage = FirstPage[NextPage],
// Función para obtener todas las páginas de manera iterativa
GetAllPagesIteratively = (url as text) =>
let
PagesList = List.Generate(
() => [Url = url, Page = GetPage(url)],
each [Url] <> null,
each [Url = [Page][NextPage], Page = if [Url] <> null then GetPage([Url]) else [Results = {}, NextPage = null]],
each [Page][Results]
),
AllResults = List.Combine(PagesList)
in
AllResults
in
GetAllPagesIteratively(url),
// Obtener todos los datos desde la URL inicial
AllData = GetAllPages(InitialUrl),
// Convertir la lista en una tabla
ResultTable = Table.FromList(AllData, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
// Expandir los registros (ajusta los nombres de campo según tu API)
ExpandedData = Table.ExpandRecordColumn(ResultTable, "Column1", {"first_name", "last_name", "email", "groups", "functional_areas", "hierarchical_levels", "related_campaigns"}, {"first_name", "last_name", "email", "groups", "functional_areas", "hierarchical_levels", "related_campaigns"}),
#"Se expandió related_campaigns" = Table.ExpandListColumn(ExpandedData, "related_campaigns"),
#"Se expandió related_campaigns1" = Table.ExpandRecordColumn(#"Se expandió related_campaigns", "related_campaigns", {"campaign_mode","campaign_name","campaign_description","campaign_state","campaign_date","campaign_expiration_date","campaign_is_test","content_name","content_type","activity_sent","activity_sent_date","notify_user_on_creation","user_notification_on_creation","activity_started","activity_started_date","activity_completed","activity_completed_date"}),
#"Se expandió hierarchical_levels" = Table.ExpandListColumn(#"Se expandió related_campaigns1", "hierarchical_levels"),
#"Se expandió functional_areas" = Table.ExpandListColumn(#"Se expandió hierarchical_levels", "functional_areas"),
#"Se expandió groups" = Table.ExpandListColumn(#"Se expandió functional_areas", "groups")
in
#"Se expandió groups"
2.7 - If necessary, expand the required columns, as detailed in the following steps.
3- Using the bottom bar, scroll to the right until you see the "results.related_campaigns" column, and click on the expand button in the column.
Data from the instance is not updated automatically at regular intervals; instead, a manual refresh must be performed to retrieve the data currently in the instance of our platform.