Bc Api Query Generator logo

Bc Api Query Generator

Community
fernandoartalf
bc-api-query-generator

Generates API query objects for Business Central that expose data via OData/REST endpoints using the QueryType = API pattern. Creates queries with single or multiple dataitems (table joins), proper API properties, column mappings, aggregation methods (Sum, Count, Average, Min, Max), filters, DataItemLink joins (InnerJoin, LeftOuterJoin, CrossJoin), and DataItemTableFilter. Supports multi-version APIs, date filters, and dimension columns. Use when asked to create an API query, generate a query endpoint, build a read-only API from joined tables, expose aggregated data via API, create reporting queries, or implement OData query endpoints.

Overview

Publisherfernandoartalf
RepositoryAL-Copilot-Skills-Collection
Skill namebc-api-query-generator
Stars
28
Forks
8
Bundled files
3
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 3 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by fernandoartalf on GitHub. Read the source before you install it.

Installation

Install the Bc Api Query Generator AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/fernandoartalf/AL-Copilot-Skills-Collection/tree/main/skills/bc-api-query-generator
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/fernandoartalf/AL-Copilot-Skills-Collection.git /tmp/AL-Copilot-Skills-Collection
mkdir -p .claude/skills
cp -r /tmp/AL-Copilot-Skills-Collection/skills/bc-api-query-generator .claude/skills/bc-api-query-generator
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Bc Api Query Generator in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Bc Api Query Generator on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Bc Api Query Generator is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Business Central API Query Generator

Generates production-ready AL API query objects following Microsoft's API standards. Handles single-table and multi-table join patterns, aggregation, filtering, and proper OData endpoint configuration.

Overview

API queries (QueryType = API) expose read-only data via OData endpoints. Unlike API pages, queries:

  • Support joining multiple tables via nested dataitems
  • Support aggregation methods (Sum, Count, Average, Min, Max)
  • Support filters exposed as OData query parameters
  • Are read-only — no INSERT, UPDATE, DELETE
  • Cannot be extended

This skill generates:

  • API query with proper metadata properties
  • Single or multi-dataitem layouts with join configuration
  • Column mappings with camelCase naming
  • Aggregation and filter elements
  • File placed following feature-based folder convention

Advanced patterns and join examples: references/query-examples.md

Prerequisites

  • AL workspace with established object ID range
  • Source table(s) identified with join relationships
  • Clear list of columns to expose
  • API publisher, group, and version defined

Quick Start

al
query [ID] "[Prefix] [Entity] API"
{
    QueryType = API;
    APIPublisher = '[publisher]';
    APIGroup = '[group]';
    APIVersion = 'v2.0';
    Caption = '[entityCaption]', Locked = true;
    EntityName = '[entityName]';         // camelCase, singular
    EntitySetName = '[entityNames]';     // camelCase, plural

    elements
    {
        dataitem([dataItemName]; "[Source Table]")
        {
            column([fieldAlias]; "[Field Name]")
            {
                Caption = '[Caption]', Locked = true;
            }
        }
    }
}

Endpoint URL: ../[publisher]/[group]/[version]/companies({id})/[entitySetName]

API Query Properties

PropertyGuideline
QueryTypeAlways API for web service queries
APIPublisherCompany/publisher identifier, lowercase, no spaces
APIGroupLogical group: sales, purchasing, inventory, finance, reporting
APIVersionUse 'v2.0' or list 'v1.0', 'v2.0' for multi-version support
CaptionUse camelCase entity name, always Locked = true
EntityNamecamelCase, singular (e.g., customerSale, itemLedgerEntry)
EntitySetNamecamelCase, plural (e.g., customerSales, itemLedgerEntries)

DataItem Pattern — Single Table

Use for simple read-only exposure of a single table:

al
query [ID] "[Prefix] [Entity] API"
{
    QueryType = API;
    APIPublisher = '[publisher]';
    APIGroup = '[group]';
    APIVersion = 'v2.0';
    Caption = '[entityCaption]', Locked = true;
    EntityName = '[entityName]';
    EntitySetName = '[entityNames]';

    elements
    {
        dataitem([dataItemName]; "[Source Table]")
        {
            // Primary key / identifier columns
            column([alias]; "[Key Field]")
            {
                Caption = '[Caption]', Locked = true;
            }

            // Business data columns
            column([alias]; "[Business Field]")
            {
                Caption = '[Caption]', Locked = true;
            }

            // Date columns
            column([alias]; "[Date Field]")
            {
                Caption = '[Caption]', Locked = true;
            }

            // Amount / numeric columns
            column([alias]; "[Amount Field]")
            {
                Caption = '[Caption]', Locked = true;
            }

            // Dimension columns (if applicable)
            column([alias]; "[Dimension Field]")
            {
                Caption = '[Caption]', Locked = true;
            }
        }
    }
}

DataItem Pattern — Multi-Table Join

Use for joining related tables. Nest dataitems to create SQL JOINs:

al
query [ID] "[Prefix] [Entity] API"
{
    QueryType = API;
    APIPublisher = '[publisher]';
    APIGroup = '[group]';
    APIVersion = 'v2.0';
    Caption = '[entityCaption]', Locked = true;
    EntityName = '[entityName]';
    EntitySetName = '[entityNames]';

    elements
    {
        dataitem([parentDataItem]; "[Parent Table]")
        {
            // Parent table columns
            column([alias]; "[Parent Field]")
            {
                Caption = '[Caption]', Locked = true;
            }

            dataitem([childDataItem]; "[Child Table]")
            {
                DataItemLink = "[Child FK Field]" = [parentDataItem]."[Parent PK Field]";
                SqlJoinType = InnerJoin;

                // Child table columns
                column([alias]; "[Child Field]")
                {
                    Caption = '[Caption]', Locked = true;
                }

                // Aggregation column example
                column([alias]; "[Amount Field]")
                {
                    Caption = '[Caption]', Locked = true;
                    Method = Sum;
                }

                // Filter element example
                filter([filterAlias]; "[Filter Field]")
                {
                    Caption = '[Caption]', Locked = true;
                }
            }
        }
    }
}

SqlJoinType Property

Sets the data item link type between data items to determine the records included in the resulting dataset. Always set on the lower (nested) data item. Works together with DataItemLink to combine records — except for CrossJoin, which requires DataItemLink to be blank.

al
SqlJoinType = InnerJoin;
Join TypeDescriptionWhen to Use
LeftOuterJoinReturns every record from the upper (parent) data item, even if no matching record exists in the lower data item. Non-matching lower fields return null/default values.Most common for API queries. Use when you need all parent records regardless of child matches (e.g., all customers even those with no ledger entries).
InnerJoinReturns only records where a match is found between linked fields in both data items. Records without matches in either table are excluded.Use when you only want records that exist in both tables (e.g., only items that have been sold).
RightOuterJoinReturns every record from the lower (child) data item, even if no matching record exists in the upper data item. Non-matching upper fields return null/default values.Use when the child table is the primary dataset and you want all child records even without parent matches. Less common in API queries.
FullOuterJoinReturns all records from both data items, including records that have no matching value in either table. Non-matching fields return null/default values on both sides.Use for complete datasets where no records should be excluded (e.g., reconciliation queries).
CrossJoinProduces a Cartesian product — every row from the upper data item combined with every row from the lower data item. DataItemLink must be blank.Rarely needed. Use for generating all possible combinations (e.g., item × location matrix). Can produce very large datasets — use with caution.

Remarks:

  • The SqlJoinType property is always set on the lower (nested) data item, never on the root data item.
  • For LeftOuterJoin, InnerJoin, RightOuterJoin, and FullOuterJoin, the DataItemLink property establishes an "equal to" (=) comparison between fields.
  • For CrossJoin, the DataItemLink property must be left blank — no field comparisons are made.
  • When no SqlJoinType is specified, the default is LeftOuterJoin.

Choosing the right join type:

LeftOuterJoin (most common for APIs):
  Parent: [A, B, C]    Child: [A, B]
  Result: [A+A, B+B, C+null]  ← All parents included

InnerJoin:
  Parent: [A, B, C]    Child: [A, B]
  Result: [A+A, B+B]          ← Only matches

RightOuterJoin:
  Parent: [A, B]       Child: [A, B, D]
  Result: [A+A, B+B, null+D]  ← All children included

FullOuterJoin:
  Parent: [A, B, C]    Child: [A, B, D]
  Result: [A+A, B+B, C+null, null+D]  ← All records from both

CrossJoin (no DataItemLink):
  Parent: [A, B]       Child: [X, Y]
  Result: [A+X, A+Y, B+X, B+Y]  ← Every combination

DataItemLink Syntax

al
DataItemLink = "[ChildField]" = [ParentDataItemName]."[ParentField]";
  • Links child dataitem to parent using foreign key relationship
  • Multiple links separated by commas:
    al
    DataItemLink = "Document Type" = [parentItem]."Document Type",
                   "Document No." = [parentItem]."No.";

DataItemTableFilter

Apply fixed filters to restrict data at the dataitem level:

al
dataitem([name]; "[Table]")
{
    DataItemTableFilter = "Document Type" = FILTER(Invoice | "Credit Memo");
    DataItemTableFilter = "Posting Date" = FILTER(<> 0D);
}

Aggregation Methods

Use the Method property on columns for aggregation:

MethodDescription
SumTotal of numeric values
CountNumber of records
AverageAverage of numeric values
MinMinimum value
MaxMaximum value
al
column(totalAmount; "Amount (LCY)")
{
    Caption = 'TotalAmount', Locked = true;
    Method = Sum;
}

Rule: When using aggregation methods, non-aggregated columns become implicit GROUP BY fields.

Filter Elements

Expose filters as OData query parameters:

al
filter(dateFilter; "Posting Date")
{
    Caption = 'DateFilter', Locked = true;
}
  • Filters appear as query parameters in the OData URL
  • Use for date ranges, document type filtering, and status filtering
  • Filter elements do not produce output columns

Column Naming Conventions

AL FieldColumn AliasCaptionPattern
"Entry No."entryNo'Entry No.' or Locked = truecamelCase alias
"Customer No."customerNumber'CustomerNumber', LockedDescriptive names
"Posting Date"postingDate'PostingDate', LockedRemove spaces
"Amount (LCY)"amountLCY'AmountLCY', LockedInclude qualifier
"Sales (LCY)"totalSalesAmount'TotalSalesAmount', LockedDescriptive for aggregation
"Global Dimension 1 Code"globalDimension1CodeStandard dimension naming

Rules:

  • Use camelCase for all column aliases
  • Set Caption with Locked = true for API queries to prevent translation issues
  • Use descriptive aliases for aggregated columns (e.g., totalSalesAmount instead of salesLCY)

API Query Design Workflow

  1. Define purpose — What data needs exposure? Who consumes it? What aggregations?
  2. Identify tables — Primary table and related tables for joins
  3. Plan joins — Define DataItemLink relationships and SqlJoinType
  4. Select columns — Pick fields to expose, decide on aggregations
  5. Add filters — Expose date ranges and key filtering parameters
  6. Allocate object ID — Query objects typically in dedicated range
  7. Implement query — Create .Query.al file following naming convention
  8. Test endpoint — Verify OData response structure and data

File Naming Convention

Follow the pattern: [Prefix][EntityName]API.Query.al

Examples:

  • BCSStatLedgerEntryAPI.Query.al
  • BCSCustomerSalesAPI.Query.al
  • BCSItemInventoryAPI.Query.al

Place in feature folder: src/[Feature]/Query/ or alongside related feature files.

Checklist

Before completing API query generation:

  • QueryType = API set
  • API properties defined (publisher, group, version, entity names)
  • Caption set with Locked = true
  • All dataitems have meaningful names
  • DataItemLink defined for multi-table joins
  • SqlJoinType specified for each nested dataitem
  • DataItemTableFilter applied where needed
  • Column aliases use camelCase
  • Column Captions with Locked = true
  • Aggregation Methods applied where needed
  • Filter elements added for date ranges and key parameters
  • File follows naming convention: [Prefix][Entity]API.Query.al

References

For complete examples:

External Resources

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Bc Api Query Generator AI skill do?

Generates API query objects for Business Central that expose data via OData/REST endpoints using the QueryType = API pattern. Creates queries with single or multiple dataitems (table joins), proper API properties, column mappings, aggregation methods (Sum, Count, Average, Min, Max), filters, DataItemLink joins (InnerJoin, LeftOuterJoin, CrossJoin), and DataItemTableFilter. Supports multi-version APIs, date filters, and dimension columns. Use when asked to create an API query, generate a query endpoint, build a read-only API from joined tables, expose aggregated data via API, create reportin...

Why use Bc Api Query Generator on TypingMind?

Because you install it once and use it with any model. Bc Api Query Generator is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Bc Api Query Generator in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/fernandoartalf/AL-Copilot-Skills-Collection/tree/main/skills/bc-api-query-generator. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Bc Api Query Generator?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Bc Api Query Generator?

As many as you like. As long as a model supports skills, you can use Bc Api Query Generator with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Bc Api Query Generator AI skill free?

Yes. It is published on GitHub by fernandoartalf under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇