Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Launching a library(API client) in total darkness by Ronald Maravanyika

Pycon ZA
October 10, 2019

Launching a library(API client) in total darkness by Ronald Maravanyika

This talk will detail how one can create a python API client with limited resources.It's based on my personal experience of having to create an API client to be used by over a thousand users. The talk accommodates all levels of developers, final year students may also find this talk interesting.

We will cover the basics from what is an API client, why we need it, then we will look at common methods of using APIs then l will quickly show you how to create the API client and then we will look at challenges that l faced in terms of shortage of resources as well as the solutions. We will lastly look at how to document the library while writing code.

This talk isn't about the specific details of developing a client for a particular API, but a more general talk about the tools and techniques l used in developing an API client with limited resources.

Pycon ZA

October 10, 2019
Tweet

More Decks by Pycon ZA

Other Decks in Programming

Transcript

  1. ABOUT ME • Software Engineer at NTT Limited • Technical

    Director at Zimbopy • Managing member PSF • DSF member • Djangogirls Organiser
  2. WHAT TO LOOK FORWARD TO • Topic break down •

    Definition of terms • Case study explanation • Degreed • How to use API • A look at API client • Cookie cutter • Creating API client • Testing • Documentation • Launching with Twine Beginner Intermediate to senior
  3. LIBRARY • Python library is a collection of functions and

    methods that allows you to perform many actions without writing your code
  4. API • DEF: A set of functions and procedures allowing

    the creation of applications that access the features or data of an operating system, application, or other service.
  5. USING POSTMAN • API authentications(Basic HTTP(base 64 username/password), Oauth, API

    keys) • Our API authentications method uses: OAuth 2.0 protocol’s Client CredentialsFlow for authentication and authorization
  6. REQUESTS • Calling requests.request will create a Session • Session

    is a good idea if you want to make multiple connections to the same endpoint. • WHY? Because it hold open the TCP session connections • Expanding on this: https://medium.com/@anthonypjshaw/python-requests-deep-dive-a0a5c5c1e093
  7. COOKIE CUTTER • A great way to start your library(keep

    in mind the challenges) • I used audreyr/cookiecutter-pypackage project template • ADV: • - You have basic structure in no time • - Push to pypi is made easy • - Documentation is sorted with sphinx
  8. COOKIE CUTTER • A great way to start your library(keep

    in mind the challenges) • I used audreyr/cookiecutter-pypackage project template • ADV: • - You have basic structure in no time • - Push to pypi is made easy • - Documentation is sorted with sphinx
  9. STEPS • Create a pypi account • Upload your package

    to github.com • Create pypi account (setup.py, setup.cfg, LICENSE.txt, README.md) NB: COOKIE CUTTER HAS ALREADY DONE MOST OF THIS STUFF FOR US.
  10. STEP CONT… • python setup.py sdist • CREATES THE DISTRIBUTION

    TO UPLOAD TO PYPI • twine upload dist/* • This will upload it to PYPI