Creating custom connector using Python CDK with API request, report generation, and download


Creating a custom connector in Python CDK to request an API, wait for report generation, and download it while following best practices. Inquiring about inheriting from existing classes like HttpStream in Airbyte Python CDK.


Hello everyone.

I need to create a custom connector using the python CDK, my source requires me to request the api first, wait for a report to be generated and when it’s done download it. How can I implement this code following the best practices? Is it possible to inherit something from existing classes in airbyte python cdk such as HttpStream?

This topic has been created from a Slack thread to give it more visibility.
It will be on Read-Only mode here. Click here if you want to access the original thread.

Join the conversation on Slack

["custom-connector", "python-cdk", "api-request", "report-generation", "download", "best-practices", "inheritance", "httpstream"]


What we did is:
Make a new python file that imports requests.
Write a function to get_request and post_request. With url, params and header as arguments in the functions.

You can import the file into your file to get the data.
response = get_request(url, params, header)
You can get the url from your spec/config.
Make the header with auth where you can get a token from the spec/config.
Then you can fill the token and url in when setting up the connection in the airbyte webUI
or hardcode this.

In your main code you could do your first api request.
do a wait or maybe you can do a request every so often to check if the report is done generating and then download the report.
For downloading the report you could add the function in the new python file with the get_request and post_request functions.
Give arguments like url, download path. and call the function in you

<@U06M8MT4GV7> internally, we call this pattern “report-based stream” or “async report”. I don’t know if there’s a readymade infrastructure for this in Python CDK that would make it super easy to copy over, but there are a few connectors that implement this pattern.

Check out source-amazon-ads ReportStream here|[…]-ads/source_amazon_ads/streams/report_streams/