> For the complete documentation index, see [llms.txt](https://docs.xlconnect.net/xlconnect-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xlconnect.net/xlconnect-documentation/developing-with-xlconnect/javascript/calling-apis-with-http-requests.md).

# Calling API's with HTTP Requests

How to talk to web API's using HTTP requests

The Language of the Web

You are probably already familiar with the Hyper Text Transfer Protocol (HTTP) as that is how your web browser talks to web servers over the internet to show you web pages. Your browser sends an http request to a web server, that responds with a http response with html data that will be rendered in your browser for you to read.

This same technology can also be used to request and serve data, that better suited for programs to read. Instead of serving html they respond with data, typically json or xml. These are call Application Programming Interfaces or API's.

XLConnect has a built in HTTP client that allows Excel to call these API's with minimal technical friction.

## A sample Web request using XLConnect

In the [Javascript Studio](/xlconnect-documentation/developing-with-xlconnect/javascript/javascript-studio.md), this code will execute an HTTP request and display the data.

Copy and paste it into a new Javascript Studio window and hit F5 to execute it.

```
http = require('http.js')                // use the http module with wrapper methods 
uri = 'https://swapi.dev/api/people/'    // uri with details about starwars characters
sw = http.get(uri)                       // get the data and assign to sw variable 
```

This code grabs data (click [here ](https://swapi.dev/api/people/)to see the raw data) about Star Wars characters. Double click the `results` element to drill down to the actual characters.

Please note this uses the [HTTP module GET](/xlconnect-documentation/reference/modules/http-module.md) method that handles

<figure><img src="https://2187688023-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMwwg2EqgR32FSkJdVLhw%2Fuploads%2FNOlgxfbrRCBWYl2ydg0S%2Fimage.png?alt=media&amp;token=655865b1-e2f9-47da-993c-2f8d4c6fd42e" alt=""><figcaption><p>GETting a uri and displaying the results.</p></figcaption></figure>

## Anatomy of an HTTP request

An HTTP request has three major parts:

1. The Unique Resource Identifier URI (sometimes also called URL for Locator)
2. The Headers
3. The Content

API's have not really converged to a uniform way of using these elements to make it work, so be prepared to use all of them.

### URI

You will have seen many uri's in your life, to make sure you understand exactly what each part means, below is a short summary.

<figure><img src="https://2187688023-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMwwg2EqgR32FSkJdVLhw%2Fuploads%2FvE0TRGfwe6ZVIBp29t0k%2Fimage.png?alt=media&amp;token=2fe06897-cc0a-425a-9255-65d3f38f2101" alt=""><figcaption><p>Anatomy or a URI</p></figcaption></figure>

### Headers

Headers are key-value properties that be sent and received, this allows both client and server to add properties to a request. Xero for instance requires that every request has a property `xero-tenant-id` to indicate for which tenant the request is meant for. Another often used property is

### Content

The Content of a web request is the actua thing you wat to send and/ or recieve, in today's
