Live Chat

We'll need to share your messages (and your email address if you're logged in) with our live chat provider, Drift. Here's their privacy policy.

If you don't want to do this, you can email us instead at

Quickstart: Creating HTTP endpoints

Put an HTTP API on your app

Anvil lets you set up HTTP endpoints with very little code.

Follow this quickstart to create an HTTP endpoint that extracts two variables from the path and creates a response dynamically based on their values.

Create an app

Log in to Anvil and click ‘New Blank App’. Choose the Material Design theme.

Location of the Create App button

Add a Server Module

In the App Browser, click the + next to Server Code to add a new Server Module.

Adding a Server Module in the App Browser

You will see a code editor with a yellow background.

Python code with a yellow background

Create an HTTP endpoint

Write this function:

def add_numbers(a, b):
  a = int(a)
  b = int(b)
  return {
    'originals': [a, b],
    'sum': a + b,

It takes two numbers and returns a data structure containing their sum.

Above this function, write @anvil.server.http_endpoint('/add/:a/:b'):

def add_numbers(a, b):
  a = int(a)
  b = int(b)
  return {
    'originals': [a, b],
    'sum': a + b,

Access your HTTP endpoint

At the bottom of your Server Module, there is a message like this:

Message at bottom of Server Module explaining URL stem of HTTP API

Copy the URL without the {path} part, and put add/32/10 at the end. For my app that would be:

Open a new browser tab and access that URL. You should see this response:


Pass in different numbers to get a different answer:

This time the response is:


(To set up a nicer URL for your API, see deployment.)

Copy the example app

Click on the button below to clone a finished version of this app into your account.

Next up

Want more depth on this subject?

Read more about HTTP APIs and requests in Anvil.

Want another quickstart?

Every quickstart is on the Quickstarts page.