go back  41 - Daily Python Tip Part 2 - Build an API




This challenge write-up first appeared on PyBites.

It's not that I'm so smart, it's just that I stay with problems longer. - A. Einstein

Hi Pythonistas, you heard of Daily Python Tip? It's a Twitter account that posts one python tip per day, run by @karlafej and @simecek. We partnered up with them and use their awesome collection of tips to build a web app (part 1) and a simple API (part 2).

The Challenge

If you built a web app for part 1 you could use its data / backend. If not just use the Daily Python Tip's backend. We want this challenge to be independent so API lovers are not required to build a web app first.

The goal is to make a simple API using Flask, Django Rest Framework of another (Python) framework. Something the guys at Daily Python Tip could actually use!

HTTP verbs / actions:

  • GET -> here is their google spreadsheet
  • POST -> here is their Google form. "We are consenting adults" so we should prevent duplicates and bad data to be entered so you should add proper validation:

    • no duplicate postings,
    • max length of 140 characters (tips gets posted to Twitter),
    • discard new tips that are too similar to existing (this might be complex but give it some thought ...)

If you took part 1 and are using your own DB / backend you could also implement:

  • PUT (edit) -> for example make the Published boolean editable
  • DELETE -> not sure if applicable but could be used to remove bad data

Bonus

  1. Add Twitter login / authentication to your API so you can implement more actions:
  2. Only allow POST upon login
  3. Add your Twitter handle upon POSTing a new tip
  4. Make a user endpoint with likes, bookmarks, etc
  5. Be creative ...
  6. Host it to the cloud (Heroku, PythonAnywhere, ...)

Slack Channel

For a beginner some of our challenges might be overwhelming. Another observation is that the process of doing these challenges is as interesting as the final result.

We are eager to expand our awesome PyBites community. For this reason we are opening up our private Slack for you to discuss our code challenges and let us know how you're progressing your Python skills. Send us an email if you want to join.

This way you get the unique opportunity to learn from other Pythonistas and share some of your own learning.

Credit

To get credit PR your work to our Community branch of our Challenges repo. See detailed instructions here.

About

Our goal is to learn and teach you Python through practical exercises. Learning a programming language is way more fun as a community!

For any feedback, issues or ideas use GH Issues, tweet us or drop us an email.


Keep Calm and Code in Python!

-- PyBites