Level up your Twilio API skills in TwilioQuest, an educational game for Mac, Windows, and Linux. Download Now
Build the future of communications.
Start building for free

Python posts

  • By Miguel Grinberg
    Send Scheduled Emails from Python and Flask with Twilio SendGrid Send Scheduled Emails from Python and Flask with Twilio SendGrid

    Twilio SendGrid eliminates many of the complexities of sending email. In a previous tutorial, you learned how to use SendGrid’s SMTP server to send emails to your users from a Python and Flask application. But how do you schedule your emails so that they are sent at a specific time?

    In this short tutorial you will learn how to use SendGrid’s email scheduling options, which will save you from having to implement your own background scheduling.


    To work on this tutorial you will need the following items:

    • Python 3.6 or newer. If your operating system does not provide a Python 3.6+ interpreter, you can go to python.org to download an installer.
    • A free Twilio SendGrid account. If you are new to Twilio Sendgrid you can create a trial account. With a trial account you can send 100 emails per day forever.

    Create a Flask project

    Find an …

    Read More
  • By Mark Lewin
    Create a Cold War-Era Numbers Station with Twilio Voice and Python Flask Create a Cold War-Era Numbers Station with Twilio Voice and Python Flask

    Put on your fedora and dark glasses, because you’re about to become a Cold War-era numbers station operator!

    What is a numbers station, I hear you ask? A numbers station is a radio station in the shortwave frequency band that periodically reads out a sequence of numbers, popularly believed to be a secret code for intelligence officers listening for encrypted information. Numbers stations appeared during World War I and are likely to have become much more prevalent during the Cold War.

    In the past, the numbers were often spoken in what sounded like a creepy voice, probably due to the poor radio transmission quality available at the time. You can listen to a few recent examples of numbers station transmissions on the Crypto Museum's website. Some numbers stations survive to this very day.

    Since many people enjoy cracking secret codes, I thought it would be fun to show you …

    Read More
  • By Carlos Mucuho
    Turn Voice Recordings into Shareable Videos with Python and FFmpeg Turn Voice Recordings into Shareable Videos with Python and FFmpeg

    In this tutorial, we are going to learn how to build an application with Python and FFmpeg that will allow us to turn voice recordings into cool videos that can be easily shared on social media.

    At the end of the tutorial we will have turned a voice recording into a video that looks similar to the following:

    Project demo

    Tutorial requirements

    To follow this tutorial you are going to need the following components:

    • One or more voice recordings that you want to convert to videos. Programmable Voice recordings stored in your Twilio account work great for this tutorial.
    • Python 3.6+ installed.
    • FFmpeg version 4.3.1 or newer installed.

    Creating the project structure

    In this section, we will create our project directory, and inside this directory, we will create sub-directories where we will store the recordings, images, fonts, and videos that will be used in this tutorial. Lastly, we will create the Python …

    Read More
  • By Sam Agnew
    17年周期ゼミ「ブルードX」から見たPythonの変遷 Brood X Cicadas JP.png

    この記事はTwilio Developer EvangelistのSam Agnewこちら(英語)で執筆した記事を日本語化したものです。



    これらのセミたちが追い付くには多くのことが変化した17年ですが、Pythonプログラミング言語も非常に多くの更新を経てきました。2004年5月にリリースされたPython 2.3.4を調べて、この周期ゼの視点から、現在のPythonでのコーディングと異なる点を確認しましょう。


    from may_2004 import newest_python_version

    旧バージョンのPythonはpython.orgから引き続き入手可能です。前回周期ゼミが発生した頃のPython 2.3.4も含まれます。


    Python 2.3.4 Windows installer


    python command line shell

    Python 2.3.4の新機能

    Python 2.3.4 shell icon on toolbar

    Python 2.3.4には多くの新機能が搭載されていました。いくつ …

    Read More
  • By August Allard
    5 Ways to Make HTTP Requests Using Python 5 Ways to Make HTTP Requests Using Python

    When it comes to software development, there are almost always several different ways to achieve the same outcome. This is true when evaluating a family of third-party software packages, too. For example, in the Python ecosystem there are thousands of packages related to making HTTP requests. Which one should you use?

    In this experiment-based tutorial, we’ll walk through brief code snippets that show how to make a simple GET request using 5 of Python’s most popular requests-related packages. We’ll use NASA’s Astronomy Photo of the Day API (shortened to APOD throughout the rest of the tutorial) and open today’s photo in our web browser.

    Our goal is to make simple GET requests quickly using a variety of Python packages, rather than to compare and contrast all of the features and subtleties of each package. If asynchronous requests are a better fit for your use case, check out the companion …

    Read More
  • By Sam Agnew
    Asynchrone HTTP-Anfragen in Python mit HTTPX und asyncio Asynchrone HTTP-Anfragen in Python mit HTTPX und asyncio

    Hallo und Danke fürs Lesen! Dieser Blogpost ist eine Übersetzung von Asynchronous HTTP Requests in Python with HTTPX and asyncio. Während wir unsere Übersetzungsprozesse verbessern, würden wir uns über Dein Feedback an help@twilio.com freuen, solltest Du etwas bemerken, was falsch übersetzt wurde. Wir bedanken uns für hilfreiche Beiträge mit Twilio Swag :)

    Asynchroner Code ist zunehmend zu einer tragenden Säule der Python-Entwicklung geworden. Mit asyncio als Teil der Standardbibliothek und vielen Paketen von Drittanbietern, die damit kompatible Funktionen bieten, wird dieses Paradigma nicht so schnell verschwinden.

    Wir wollen uns anschauen, wie man die HTTPX-Bibliothek verwendet, um dies für asynchrone HTTP-Anfragen zu nutzen. Das ist einer der häufigsten Anwendungsfälle für nicht blockierenden Code.

    Was ist nicht blockierender Code?

    Möglicherweise hörst du Begriffe wie „asynchron“, „nicht blockierend“ oder „gleichzeitig“ und bist ein wenig verwirrt darüber, was sie alle bedeuten. Diesem viel detaillierteren Tutorial zufolge gibt es zwei primäre Eigenschaften:

    • Asynchrone …
    Read More
  • By Miguel Grinberg
    How to Verify Phone Numbers in a Django Application with Twilio Verify How to Verify Phone Numbers in a Django Application with Twilio Verify

    When building a user registration and authentication system for your web application, you run the risk of not properly detecting fake or duplicate accounts. A very effective way to reduce this risk is to require users to verify their accounts right after they register.

    In this tutorial I’m going to show you how to extend the Django authentication system to include an SMS verification step in the user registration flow, using the Twilio Verify service. Among other things, you will learn how to:

    • Customize the user database model
    • Ask for additional information in the user registration page
    • Send and check SMS verification codes with the Twilio Verify service
    • Prevent access to parts of the application to users that haven’t verified their accounts

    Project demonstration

    Ready to begin? Let’s go!


    To follow this tutorial you need the following items:

    • Python 3.6 or newer. If your operating system does not provide a Python …
    Read More
  • By Miguel Grinberg
    Pythonで環境変数を活用する environment-variables-python

    この記事はMiguel Grinbergが執筆したこちらの記事(英語)を日本語訳したものです。






    >>> import os
    >>> user = os.environ['USER']
    >>> user


    >>> database_url = os.environ['DATABASE_URL']
    Traceback (most recent call l …
    Read More
  • By Ashutosh Hathidara
    Automatically Send Birthday Wishes with Python Flask and WhatsApp Automatically Send Birthday Wishes with Python Flask and WhatsApp

    Do you forget to send birthday wishes to your friends and loved ones? I do, and it usually results in being scolded by my fiancée! I’ve often wished for a software program that could send birthday wishes on my behalf.

    In this tutorial, we will create this exact end-to-end system. We will use Twilio's What’sApp API for sending the messages, the Flask web framework for the web server, and we will run messaging jobs periodically using APScheduler. We’ll also deploy the Flask application to AWS so it can be deployed resiliently and at scale.

    The complete code for this tutorial is available in this Github repository.


    • A Twilio account. (Sign up with this link and receive an additional $10 credit.)
    • The WhatsApp application installed on your mobile phone
    • An activated WhatsApp Sandbox (be sure to follow the setup instructions).
    • Your Account SID and Auth Token, found …
    Read More
  • By Diane Phan
    Utiliser la reconnaissance d'images avec l'API Twilio WhatsApp Comment utiliser la reconnaissance d'images avec l'API Twilio WhatsApp

    Le concept de reconnaissance des images peut sembler être un défi, mais avec l'aide de API de reconnaissance d'images de Clarifai, le code peut prédire le contenu d'une image donnée et déterminer les concepts pour décrire l'image, ainsi que la valeur de prédiction de la précision de la classification de l'image.

    Dans cet article, nous allons vous expliquer comment développer un programme Python fonctionnel pour identifier le contenu multimédia à l'aide de l'API Twilio WhatsApp API, API Clarifai, et Flask.

    Configuration requise pour le tutoriel

    Pour créer ce projet, vous devez disposer des éléments suivants :

    • Python 3.6 ou version ultérieure. Si votre système d'exploitation ne fournit pas d'interpréteur Python, vous pouvez vous rendre sur python.org pour télécharger un programme d'installation.
    • ngrok est un utilitaire pratique pour connecter la version de développement de notre application Python exécutée sur votre système à une URL publique …
    Read More
  • Newer
    Sign up and start building
    Not ready yet? Talk to an expert.