VOOZH about

URL: https://www.digitalocean.com/community/tutorials/how-to-use-web-apis-in-python-3?comment=80311

⇱ How To Use Web APIs in Python 3 | DigitalOcean


How To Use Web APIs in Python 3

Updated on March 20, 2019
👁 How To Use Web APIs in Python 3

Introduction

An API, or Application Program Interface, enables developers to integrate one app with another. They expose some of a program’s inner workings in a limited way.

You can use APIs to get information from other programs or to automate things you normally do in your web browser. Sometimes you can use APIs to do things you just can’t do any other way. A surprising number of web properties offer web-based APIs alongside the more familiar website or mobile app, including Twitter, Facebook, GitHub, and DigitalOcean.

If you’ve worked your way through some tutorials on how to code in Python 3, and you’re comfortable with Python’s syntax, structure, and some built-in functions, you can write Python programs that take advantage of your favorite APIs.

In this guide, you will learn how to use Python with the DigitalOcean API to retrieve information about your DigitalOcean account. Then we’ll look at how you can apply what you’ve learned to GitHub’s API.

When you’re finished, you’ll understand the concepts common across web APIs, and you’ll have a step-by-step process and working code samples that you can use to try out APIs from other services.

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the author(s)

👁 Brian King
Brian King
Author

Managed the Write for DOnations program, wrote and edited community articles, and makes things on the Internet. Expertise in DevOps areas including Linux, Ubuntu, Debian, and more.

Still looking for an answer?

Was this helpful?

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Hello,

I could not get my GIT repositories list until I updated the content of the variable api_url_base in the github_list_repos.py script.

The content of variable api_url_base is incomplete and is causing HTTP 401. The variable must have the /users path component in it as follows:

api_url_base = 'https://api.github.com/users/'
headers = {'Content-Type': 'application/json',
 'User-Agent': 'Python Student',
 'Accept': 'application/vnd.github.v3+json'}

Salute!

Hi… how to get API token for this site

👁 Creative Commons
This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License.
  • Deploy on DigitalOcean

    Click below to sign up for DigitalOcean's virtual machines, Databases, and AIML products.

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and AI-native businesses

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

© 2026 DigitalOcean, LLC.Sitemap.
Dark mode is coming soon.