SILVERLINE (347 x 95 px) (1)
  • Features
  • Documentation
  • Pricing
  • Blog
  • Contact Us
  • Login
Start for Free
✕
  • Features
  • Documentation
  • Pricing
  • Blog
  • Contact Us
  • Login

Introduction

1
  • Introduction

Quick Start Guide

4
  • Step 1 – Setup Data Source
  • Step 2 – Automatic Endpoints
  • Step 3 – Build a new API
  • Querying and Scripting

Using Parameters

1
  • Using Parameters

Authentication

2
  • API Access Control
  • Users and Groups

Multi-Source Aggregation

1
  • Multiple Data Sources – One API

Data Sources

1
  • Data Sources

Examples

2
  • Attendance Tracking with JWT & API Keys
  • Combining Multiple Data Sources

Troubleshooting

1
  • Troubleshooting Tips
View Categories
  • Home
  • Docs
  • Quick Start Guide
  • Querying and Scripting

Querying and Scripting

The core vision of Silverline API is to empower developers with a seamless way to build APIs on their data, apply business logic, and modify it within minutes as requirements evolve. With this in mind, we will explore two key aspects of the platform: querying data and using Python scripts to extend business logic.

To get started, navigate to the APIs tab and click on the New API button. 

Select your data source (Silverline API has a powerful Multi-Data Source feature that allows you to connect multiple data sources into a single API, more information available in Multi-Data Source documentation).

Alternatively, you can choose Script Only mode, which enables you to write a Python script without querying a data source.

For this example, let’s select Car Dealership as the data source which is a Postgres DB. Suppose we want to build an API that retrieves all available cars by year. Implementing this is simple. You can either manually write the query or use the AI Chat Box to generate it. Simply type:
“Give me all the cars for a given year as {{year}}.”

Press Enter

Here, {{year}} is a parameter, following the format {{parameter_name}}. When this format is used in the query, a parameter box automatically appears to the right of the query, as shown in the screenshot above.
This parameter will be included in the API request. You can add validation by clicking the three dots next to the parameter box, where you can define rules, set custom error responses if the input doesn’t meet the criteria, and configure a custom response code.

Once the query is set up, test it by providing a sample value for the parameter and running the query. 

[Tip: If the query generated through natural language fails, copying and pasting the error message back into the AI chat box often regenerates a corrected version that works.]

Once you’re satisfied with the results, enter a name for the API and save it. 

[Bonus:  You can also view the query results in Charts, where data can be visualized in different formats.]

Finally, publish the API to make it available for consumption. You can then navigate to the Optional Settings page to assign a friendly name to the API route. Next, go to the API Endpoint tab to verify the endpoint and its results. From this tab, you can also copy the endpoint for use.



Extending Business Logic Using Scripting

To further enhance business logic, navigate to the Script Setup tab. Suppose we want to add two additional attributes to our API response: “Discount” and “Final Price”. The discount logic is — if a car’s standard price is above $60,000, the discount is 10%, and if the price is below $60,000, the discount is 5%. The Final Price is then calculated as Price – Discount.

This logic can be implemented manually using Python or by leveraging Silverline API’s AI functionality. Simply enter the following in the chat box:
“Add new attributes ‘Discount’ and ‘Final Price’ where if a car’s standard price is above $60,000, the discount is 10%. If the price is below $60,000, the discount is 5%. The Final Price attribute will be calculated as Price – Discount.”

Press Enter




To ensure that data from queries is correctly referenced in the script, use the {{queryResultset}} parameter, as shown in the example above. This parameter holds the response from the query, allowing the script to process and manipulate the retrieved data effectively.

Next, Just click on Run Script to see the result. Verify it and Click Save and Publish it to go live.
(Since the API endpoint is already set with a friendly name from before, no changes are needed. The same endpoint call will now automatically reflect the two additional attributes.)

[Tip: If the script generated through natural language fails, copying and pasting the error message back into the AI chat box often helps regenerate a corrected version that works.]

[Important: By default, the generated script uses a sample value to build the script. Be sure to replace the example value with the {{queryResultset}} parameter before running it. This parameter holds the response from the previous query in the Data Analysis and Query Setup tab.]

[Note: Parameters can also be used in scripts, just as they are in queries as mentioned above. They follow the same  format {{parameter_name}} and must be supplied as part of the API request.]

Share This Article :
  • Facebook
  • X
  • LinkedIn
  • Pinterest
Step 3 – Build a new API
SILVERLINE (347 x 95 px) (1)
  • Privacy Policy
  • Terms of Service
  • Trust & Compliance

    © 2025 Silverline API All Rights Reserved | Powered Silverline API

    Get In Touch

    Enter your email below, and our team will reach out to ensure a smooth, personalized onboarding experience.

    Subscription Form