Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update python cdk tutorial with updates to exchange rates api #12427

Merged
merged 3 commits into from
Apr 29, 2022

Conversation

brianjlai
Copy link
Contributor

Issue: #12249

What

The Exchange Rates API that we use as part of the "Python CDK: Creating a HTTP API Source" tutorial has changed quite a bit in the past few months. In particular, the introduction of required API access keys and some new limitations on what Free tier users can utilize has made out instructions fall out of sync.

How

Most of the changes to the API can all be reasoned about with some experimentation, but in order to reduce the friction of people going through the tutorial, I've updated the steps and code snippets to incorporate changes to the API. I've also updated some of the connector code to align with the new changes.

@github-actions github-actions bot added area/connectors Connector related issues area/documentation Improvements or additions to documentation CDK Connector Development Kit labels Apr 28, 2022
@@ -14,14 +14,16 @@


class ExchangeRates(HttpStream):
url_base = "https://api.exchangeratesapi.io/"
url_base = "http://api.exchangeratesapi.io/"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exchange Rates only allows free tier to use http not https

# The api requires that we include the base currency as a query param so we do that in this method
return {'base': self.base}
# The api requires that we include access_key as a query param so we do that in this method
return {'access_key': self.access_key}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Free tier users no longer have the ability to specify a base. Leaving it in results in 400 errors. Although its confusing from a tutorial standpoint to allow for base, base is used in earlier sections to demonstrate invalid configs so I think we should not completely remove it from the tutorial since it still serves a purpose, even if not in the outbound req

@@ -38,8 +40,8 @@ def request_params(
stream_slice: Mapping[str, Any] = None,
next_page_token: Mapping[str, Any] = None,
) -> MutableMapping[str, Any]:
# The api requires that we include the base currency as a query param so we do that in this method
return {"base": self.base}
# The api requires that we include access_key as a query param so we do that in this method ADD THIS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ADD THIS. comment is a little confusing. what needs to be added?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch! I forgot to delete that as i was marking what code to add to the tutorial. will delete this

@brianjlai brianjlai merged commit ceec454 into master Apr 29, 2022
@brianjlai brianjlai deleted the brian/update_cdk_tutorial_docs branch April 29, 2022 20:44
suhomud pushed a commit that referenced this pull request May 23, 2022
* update python cdk tutorial with updates to exchange rates api

* remove extra comment in source.py tutorial sample code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/connectors Connector related issues area/documentation Improvements or additions to documentation CDK Connector Development Kit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants