In scenarios where retrieving data from a single source is insufficient, Silverline API’s multi-data-source feature, powered by AI, enables seamless querying and integration of data from multiple sources—such as databases, flat files and APIs—into a single, unified API response. This streamlined approach enhances data accessibility, transformation, and integration, resulting in a more efficient and scalable API development process.
The following is the process to build a unified API with Silverline API –
Ensure Required Data Sources Are Added
Before proceeding, make sure all necessary data sources are added in the Data Sources tab. This ensures that all relevant data sources, such as databases, flat files, and APIs, are available for querying and integration.
Navigate to APIs tab and click on New API button and choose “Multi DataSource”:
In the API Datasource, select Multi DataSource as your data source type.
Adding Queries or Using Natural Language
At this step, you can either add independent queries (by clicking the ‘Add Query’ button) or simply type your request in natural language, allowing Silverline API to interpret and process it.
Add Query Button :
Natural Language (AI) Process :
For example, suppose we have two data sources:
- PostgreSQL, which contains details of a car dealership, including car make, model, price, and other relevant information.
- CSV File, which includes weekly discounts for specific makes and models.
Our goal is to build a unified API that integrates these two sources and returns the final price of each car after applying the discount.
Using natural language, we can simply input:
“Give me details of the cars such as make, model, price, etc., along with their discounts.”
Silverline API’s Processing
Once the request is entered, Silverline API automatically analyzes the data sources to determine the best tables and columns for retrieving the required information. It then presents this analysis to the user for review. At this stage, the user has the opportunity to confirm or adjust the suggested data mappings. Once the user confirms the analysis, the system proceeds to generate the necessary queries automatically, ensuring efficient and accurate data retrieval.
If the data comes from multiple sources, Silverline API automatically generates multiple queries and intelligently joins them. To facilitate this, it uses a unique query linking format:
{{QueryID:<ID>:<colname>}}
This format ensures that key columns (such as IDs) from one query are passed into another, enabling seamless data integration across sources.
Note: If queries are being added using the “Add Query” button, ensure that the {{QueryID:<ID>:<colname>}} format is used to properly link and connect them.
This query linking format is essential for joining queries from different data sources. It works by embedding key columns from one query into another, ensuring that the QueryID represents the unique identifier of a query, while colname specifies the column whose values will be used. This allows Silverline API to include the key column from one data source in the IN clause of another query, enabling efficient cross-source data retrieval and integration.
Running and Modifying Queries
After the queries are generated, run each query independently to verify the results. If needed, individual queries can also be modified to refine the data retrieval process. Ensuring that the queries return the expected results before proceeding helps avoid errors in the final API output. A green check mark will indicate that the independent query has been successfully executed.
You can access and modify independent queries by clicking the edit icon (pen icon) next to the query.
[Tip: If your query returns an error, simply copying the error message into the question box and running it through AI will often resolve the issue automatically.]
For queries containing the {{QueryID:<ID>:<colname>}} parameter, enter a sample value in the parameter box before executing the query. This ensures the query runs successfully and retrieves the expected results.
Combining Queries into a Script
Once satisfied with the query results, navigate to the Script tab. At this point, the system automatically merges the queries into a single script.
Silverline API stores the query results in an object called:
{{queryResultset}}
This allows the combined response from multiple queries to be structured and processed efficiently.
Note: Below is a screenshot of a sample script that was generated. In the highlighted section, replace the sample data with: queryResultset = ‘{{queryResultset}}’
This ensures that the script uses the actual combined response from the queries for further processing.
After replacement :
Running and Modifying the Script
Now, you can run the script and verify the results.
If modifications are needed, you can simply use natural language (or manually update the Python script). For instance, to add a final price field that calculates the price after applying the discount, you can type:
“Add another attribute called finalPrice = price – discount.”
Silverline API will automatically update the script with this new attribute, allowing for easy adjustments without manually altering the code.
Note: The results displayed on this screen are based on a sample dataset used in the queries. The full results can be viewed in the API Endpoint tab, but keep in mind that API responses are subject to 1500-row limit restrictions.
Saving and Publishing the API
Once the script produces the expected results, you can name the API, save it, and publish it. Additionally, you can configure authentication settings in the API Access Control tab to manage user permissions and access levels.
Finally, assign a friendly name to the endpoint by configuring it in the Optional Settings section.
The updated endpoint can be copied from API Endpoint Tab.