# Working With APIs the Pythonic Way

DevFeed: [Working With APIs the Pythonic Way](<https://devfeed.tech/articles/working-with-apis-the-pythonic-way-33946.md>)

Original publisher: [Read original article](<https://hakibenita.com/working-with-apis-the-pythonic-way>)

Author: Haki Benita

Published: 2017-01-04T22:00:00Z

Content type: tutorial

Language: en

Sources: [Haki Benita](<https://devfeed.tech/sources/haki-benita.md>)

Topics: [API](<https://devfeed.tech/topics/api.md>), [Python](<https://devfeed.tech/topics/python.md>), [Exception](<https://devfeed.tech/topics/exception.md>), [data](<https://devfeed.tech/topics/data.md>)

Tags: [apis](<https://devfeed.tech/tags/apis.md>), [articles](<https://devfeed.tech/tags/articles.md>), [data-structure](<https://devfeed.tech/tags/data-structure.md>), [django](<https://devfeed.tech/tags/django.md>), [exception-handling](<https://devfeed.tech/tags/exception-handling.md>), [http](<https://devfeed.tech/tags/http.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [logging](<https://devfeed.tech/tags/logging.md>), [python](<https://devfeed.tech/tags/python.md>), [testing](<https://devfeed.tech/tags/testing.md>)

## AI overview

A step-by-step tutorial on building a Python module for communicating with an external payment gateway. It covers handling HTTP and remote payment errors, defining custom exceptions, logging, and returning structured charge responses with namedtuple.

## Source excerpt

Communication with external services is an integral part of any modern system. Whether it's a payment service, authentication, analytics or an internal one - systems need to talk to each other. In this short article we are going to implement a module for communicating with a made-up payment gateway, step by step.