Amazon SQS Python API Docs | dltHub

Build a Amazon SQS-to-database pipeline in Python using dlt with AI Workbench support for Claude Code, Cursor, and Codex.

Last updated:

Amazon SQS is a fully managed, highly‑scalable message queuing service that lets applications decouple and reliably communicate by storing messages in queues. The REST API base URL is https://sqs.{region}.amazonaws.com and all requests require AWS Signature Version 4 (access key + secret) signing.

dlt is an open-source Python library that handles authentication, pagination, and schema evolution automatically. dlthub provides AI context files that enable code assistants to generate production-ready pipelines. Install with uv pip install "dlt[workspace]" and start loading Amazon SQS data in under 10 minutes.


What data can I load from Amazon SQS?

Here are some of the endpoints you can load from Amazon SQS:

ResourceEndpointMethodData selectorDescription
list_queueshttps://sqs.{region}.amazonaws.com/ (Action=ListQueues)GET/POSTListQueuesResult.QueueUrlList.memberReturns list of queue URLs (supports optional QueueNamePrefix and pagination via NextToken on some API versions)
get_queue_attributeshttps://sqs.{region}.amazonaws.com/ (Action=GetQueueAttributes)GET/POSTGetQueueAttributesResult.Attributes.entryReturns attribute name/value pairs for the specified queue
get_queue_urlhttps://sqs.{region}.amazonaws.com/ (Action=GetQueueUrl)GET/POSTGetQueueUrlResult.QueueUrlReturns the URL of the queue matching the name and account/region
receive_messagehttps://sqs.{region}.amazonaws.com/ (Action=ReceiveMessage)GET/POSTReceiveMessageResult.Messages.memberRetrieves one or more messages from the specified queue (up to MaxNumberOfMessages)
list_dead_letter_source_queueshttps://sqs.{region}.amazonaws.com/ (Action=ListDeadLetterSourceQueues)GET/POSTListDeadLetterSourceQueuesResult.QueueUrlList.memberLists source queues that have the specified dead‑letter queue configured
change_message_visibilityhttps://sqs.{region}.amazonaws.com/ (Action=ChangeMessageVisibility)GET/POST(no record list)Changes the visibility timeout of a specified message (response contains ChangeMessageVisibilityResult)
delete_messagehttps://sqs.{region}.amazonaws.com/ (Action=DeleteMessage)GET/POST(no record list)Deletes the specified message from the queue
send_messagehttps://sqs.{region}.amazonaws.com/ (Action=SendMessage)GET/POSTSendMessageResult.MessageIdSends a message to the queue (response includes MessageId)

How do I authenticate with the Amazon SQS API?

Amazon SQS uses AWS Signature Version 4 (SigV4) authenticated requests. You must sign every request with your AWS access key ID and secret access key (and session token for temporary credentials); signing is handled automatically by AWS SDKs, or you must construct the SigV4 Authorization header when calling the REST API directly.

1. Get your credentials

  1. Sign in to AWS Management Console. 2) Open IAM (Identity and Access Management). 3) Create or select an IAM user or role with permissions for SQS (e.g., AmazonSQSFullAccess or fine‑grained policies). 4) For a user, under Security credentials create an access key to obtain Access key ID and Secret access key. 5) (Optional) For temporary credentials, use STS to assume a role to obtain AccessKeyId, SecretAccessKey, and SessionToken.

2. Add them to .dlt/secrets.toml

[sources.amazon_sqs_source] aws_access_key_id = "YOUR_AWS_ACCESS_KEY_ID" aws_secret_access_key = "YOUR_AWS_SECRET_ACCESS_KEY" aws_session_token = "YOUR_AWS_SESSION_TOKEN" # optional for temporary credentials

dlt reads this automatically at runtime — never hardcode tokens in your pipeline script. For production environments, see setting up credentials with dlt for environment variable and vault-based options.


How do I set up and run the pipeline?

Set up a virtual environment and install dlt:

uv venv && source .venv/bin/activate uv pip install "dlt[workspace]"

1. Install the dlt AI Workbench:

dlt ai init --agent <your-agent> # <agent>: claude | cursor | codex

This installs project rules, a secrets management skill, appropriate ignore files, and configures the dlt MCP server for your agent. Learn more →

2. Install the rest-api-pipeline toolkit:

dlt ai toolkit rest-api-pipeline install

This loads the skills and context about dlt the agent uses to build the pipeline iteratively, efficiently, and safely. The agent uses MCP tools to inspect credentials — it never needs to read your secrets.toml directly. Learn more →

3. Start LLM-assisted coding:

Use /find-source to load data from the Amazon SQS API into DuckDB.

The rest-api-pipeline toolkit takes over from here — it reads relevant API documentation, presents you with options for which endpoints to load, and follows a structured workflow to scaffold, debug, and validate the pipeline step by step.

4. Run the pipeline:

python amazon_sqs_pipeline.py

If everything is configured correctly, you'll see output like this:

Pipeline amazon_sqs_pipeline load step completed in 0.26 seconds 1 load package(s) were loaded to destination duckdb and into dataset amazon_sqs_data The duckdb destination used duckdb:/amazon_sqs.duckdb location to store data Load package 1749667187.541553 is LOADED and contains no failed jobs

Inspect your pipeline and data:

dlt pipeline amazon_sqs_pipeline show

This opens the Pipeline Dashboard where you can verify pipeline state, load metrics, schema (tables, columns, types), and query the loaded data directly.


Python pipeline example

This example loads list_queues and receive_message from the Amazon SQS API into DuckDB. It mirrors the endpoint and data selector configuration from the table above:

import dlt from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources @dlt.source def amazon_sqs_source(aws_credentials=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "https://sqs.{region}.amazonaws.com", "auth": { "type": "aws_sigv4", "aws_access_key_id": aws_credentials, }, }, "resources": [ {"name": "list_queues", "endpoint": {"path": "?Action=ListQueues", "data_selector": "ListQueuesResult.QueueUrlList.member"}}, {"name": "receive_message", "endpoint": {"path": "?Action=ReceiveMessage", "data_selector": "ReceiveMessageResult.Messages.member"}} ], } yield from rest_api_resources(config) def get_data() -> None: pipeline = dlt.pipeline( pipeline_name="amazon_sqs_pipeline", destination="duckdb", dataset_name="amazon_sqs_data", ) load_info = pipeline.run(amazon_sqs_source()) print(load_info)

To add more endpoints, append entries from the resource table to the "resources" list using the same name, path, and data_selector pattern.


How do I query the loaded data?

Once the pipeline runs, dlt creates one table per resource. You can query with Python or SQL.

Python (pandas DataFrame):

import dlt data = dlt.pipeline("amazon_sqs_pipeline").dataset() sessions_df = data.list_queues.df() print(sessions_df.head())

SQL (DuckDB example):

SELECT * FROM amazon_sqs_data.list_queues LIMIT 10;

In a marimo or Jupyter notebook:

import dlt data = dlt.pipeline("amazon_sqs_pipeline").dataset() data.list_queues.df().head()

See how to explore your data in marimo Notebooks and how to query your data in Python with dataset.


What destinations can I load Amazon SQS data to?

dlt supports loading into any of these destinations — only the destination parameter changes:

DestinationExample value
DuckDB (local, default)"duckdb"
PostgreSQL"postgres"
BigQuery"bigquery"
Snowflake"snowflake"
Redshift"redshift"
Databricks"databricks"
Filesystem (S3, GCS, Azure)"filesystem"

Change the destination in dlt.pipeline(destination="snowflake") and add credentials in .dlt/secrets.toml. See the full destinations list.


Troubleshooting

Authentication failures

If you get SignatureDoesNotMatch or InvalidSignatureException, verify your SigV4 signing: ensure the request host (region and service = sqs), date (x-amz-date), and credential scope use the same region and service. Check that the system clock is correct and that you are using the correct Access Key ID and Secret. Using AWS SDKs removes manual signing errors.

Access denied / permissions

Errors such as AccessDenied or AWS.SimpleQueueService.NonExistentQueue indicate missing IAM permissions or a wrong queue URL/ARN. Confirm the IAM policy grants sqs:ReceiveMessage, sqs:SendMessage, sqs:GetQueueAttributes, etc., for the target queue resource.

Throttling and limits

If you receive Throttling or RequestThrottled or RequestLimitExceeded, back off and retry with exponential backoff. SQS has API request rate limits and per‑queue throughput constraints; consider batching where supported and using long polling to reduce request rates.

Pagination and message visibility quirks

ListQueues may return truncated results; use NextToken (if present) to fetch subsequent pages. ReceiveMessage returns up to MaxNumberOfMessages per call (1‑10) and doesn't use NextToken — poll repeatedly or use long polling (WaitTimeSeconds) to reduce empty responses. Messages must be deleted explicitly after processing.

Common API errors (examples):

  • AWS.SimpleQueueService.NonExistentQueue
  • AccessDenied
  • SignatureDoesNotMatch / InvalidSignatureException
  • RequestThrottled / Throttling
  • InvalidMessageContents

Ensure that the API key is valid to avoid 401 Unauthorized errors. Also, verify endpoint paths and parameters to avoid 404 Not Found errors.


Next steps

Continue your data engineering journey with the other toolkits of the dltHub AI Workbench:

  • data-exploration — Build custom notebooks, charts, and dashboards for deeper analysis with marimo notebooks.
  • dlthub-runtime — Deploy, schedule, and monitor your pipeline in production.
dlt ai toolkit data-exploration install dlt ai toolkit dlthub-runtime install

Was this page helpful?

Community Hub

Need more dlt context for Amazon SQS?

Request dlt skills, commands, AGENT.md files, and AI-native context.