1. Knowledge base
  2. API Query Manager

How can you insert your API Query Manager data in Database

In this article we explain how to import your data in any Database with our API QM product

With Dataslayer you can pull a URL directly from our API QM product in JSON format (learn how here). Each URL corresponds to a data table.

You can insert your data in any Database by following the steps below.

Note that the sample below is made with a PostgreSQL Database, you only need to adapt the script below to a Database of your choice that uses the Standard SQL language.

Inserting my digital marketing data into a PostgreSQL Database


Insert data obtained from the Dataslayer API into a PostgreSQL database. The Dataslayer API allows you to fetch data from various sources and then you can store that data in your PostgreSQL database for further analysis or reporting. Here's a general outline of the steps you would need to follow:

1. Retrieve Data from Dataslayer API:
Use the Dataslayer API to fetch the data you need. This might involve making API requests, authenticating, and specifying the data source and metrics you want to retrieve.

2. Transform Data (Optional):
Depending on your needs, you might need to transform the data you get from the API into a format suitable for insertion into your PostgreSQL database. This could involve cleaning up the data, formatting it correctly, or aggregating it.

3. Connect to PostgreSQL Database:
Use a suitable programming language (such as Python) to establish a connection to your PostgreSQL database. You would need to provide the necessary credentials and connection parameters.

4. Insert Data into PostgreSQL:
Once connected to the database, you can use SQL commands (specifically, the INSERT INTO statement) to insert the data into your PostgreSQL tables. You would need to format the SQL statements with the data you retrieved from the API.

5. Commit Changes and Close Connection:
After inserting the data, make sure to commit the changes to the database. Then, close the connection to release resources.

Here's a simplified example in Python using the psycopg2 library for database interaction (if you use another code language with other libraries you will have to adapt the code):

import psycopg2

# Connect to the PostgreSQL database
conn = psycopg2.connect(

# Create a cursor
cursor = conn.cursor()

# Sample data retrieved from Dataslayer API
urls = [
# Each API Query Manager URL
# ...

# Insert data into PostgreSQL
for entry in api_data:
"INSERT INTO your_table_name (date_column, value_column) VALUES (%s, %s)",
(entry["date"], entry["value"])

# Commit changes and close connection

Remember to replace placeholders like your_host, your_database, your_user, your_password, your_table_name, date_column, and value_column with your actual database and table details.
Also, make sure to adjust the structure of the URL list to match the data you're getting from the Dataslayer API.

As always, please contact us via our live chat on our website or via email if you still have doubts or questions. We are happy to help!