Test Scenarios

Run Local Web Servers

Run a local web server on your local computer to test your API integrations.

Why run a local web server? Permalink Get a link to this section

To test asynchronous requests and code written in a server-side programming language (such as Node.js or PHP), you need access to a developer server or the ability to run a local web server (localhost). Running a local web server lets you render web pages locally in a browser without making them publicly available to other people.

Test Square APIs with a local web server Permalink Get a link to this section

To enable development and testing on local computers, some Square APIs have reduced security requirements when calls are made from localhost. For example, the Square payment form iframe does not load on HTTP websites unless they are served on localhost. To take advantage of these reduced security requirements when testing, you must serve local pages using the "localhost" keyword instead of an explicit IP address (such as

Some programming language interpreters include a built-in web server that you can use for development and testing purposes. To start a built-in web server:

  1. Open the Mac Terminal or Windows Command Prompt.

  2. Navigate to the root folder containing the code you want to test.

  3. Enter the language-specific command from the following table:

Language Local web server command Default URL
PHP $ php -S localhost:8000 http://localhost:8000
Rails $ rails server http://localhost:3000
Python $ python -m SimpleHTTPServer 8000 (Python 2)
$ python -m http.server 8000 (Python 3)
Node.js (Express framework) $ npm start No default. Must be explicitly configured programmatically:


< Test in Unsupported Regions