# HTTP API (Osmos Calls Your API)

## Overview

There are two modes of operation for this connector. Either Osmos will call your API, or Osmos can generate an API for you to call. Put another way, either you have an API endpoint created, or you want Osmos to create an API endpoint for you. These two modes will be referred to as *Osmos Calls Your API* and *Call an Osmos API* respectively. This page is for the former. To see documentation on the latter, see [HTTP API (*Call an Osmos API*)](https://docs.osmos.io/source-connectors/http-endpoint-connector).

This Connector sends an HTTP request to a specified HTTP API and treats the returned data from that API as *source data*. This source data is then sent through an Osmos Pipeline to a Destination Connector.

### Types of APIs Supported

This is not a Postman or `curl` replacement -- the scope of HTTP requests that Osmos will create are limited. Generalized authentication handshakes, forwarding data from a previous API request to the next one, and non-HTTP (TCP, FTP, Telnet) are  not supported by this connector.

#### Example Use Cases

For example, let's say there's an API out there, `www.example.com/weather?city=seattle`. Let's say that issuing a `GET` request to this endpoint returns an array of temperature measurements -- one measurement for every hour of the day. Something like this:

```
[75, 75, 75, 74, 72, 72, 
 70, 69, 70, 71, 75, 74,
 72, 72, 70, 69, 68, 67,
 67, 66, 65, 65, 66, 65]
```

Issuing an HTTP `GET` request from an Osmos source would result in 24 records, one for each of the above numbers, being fed into the pipeline. You may also choose to have these 24 numbers treated as *one* record with 24 fields in it.&#x20;

## Prerequisites

Information needed:

* An HTTP API that you would like to retrieve data from and send through an Osmos Pipeline.

## Creating an HTTP Endpoint Source Connector

**Step 1:** After selecting **+ New Connector**, under the **System** prompt, click **HTTP API**

![](https://353417064-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MYrsDW6vGBTygB1qqSE%2Fuploads%2FhvtMtdhz8EMFOUifJObD%2FHTTP%20API.png?alt=media\&token=6b0fa5f9-b3aa-4c18-8af4-aec8e10ebbab)

**Step 2:** Enter a **Connector Name.**

**Step 3:** Select **Source Connector.**

**Step 4:** Select **Osmos Calls Your API**

### **Detecting the Schema**&#x20;

We will automatically detect the schema of the data returned by the specified HTTP API.

## Step 5: API URL

Specify the URL, including the port number if any, of the API that Osmos should be sending the request to. For example, this could be *<http://example.com/api/v2:8824>*

## Step 6: HTTP Method

Select the [HTTP Method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) that Osmos should use when sending the request for data to this API.&#x20;

## Step 7: API Request Type

Select whether the API should return one record at a time, or an array of records. This setting turns on/off unpacking a top level array into a series of records.

## Step 8: HTTP Headers

Specify the headers, if any, that Osmos should be using to request data from this API. Headers are often used for authentication, authorization, or declarations of what type of content you're sending. Headers have both a **Name** and a **Value.** For example, an authorization header might look like:

**Name:** Authorization&#x20;

**Value:** qaX1SrppzSe1Y1qOOc08

## Step 9: Deduplication Mode

Osmos supports record level deduplication when pulling data from an API. In this mode, Osmos will store hashes of each record pulled from the source API, and will only forward new records.

## Advanced Options

**Header Normalization**

The source file may have characters at the start or end that includes spaces, tabs, carriage returns and line endings.  You can choose to keep all characters from the source or remove all whitespace.  **Select one of the options:**

1. **Don't normalize headers. Use headers exactly as they appear in the source:** If this option is selected, we will retain all characters from the source file.
2. **Remove extra whitespace and other common untypable characters from headers:** If this option is selected, we remove all whitespace (spaces, tabs, carriage returns, line endings) at start/end.

## Connector Options

The connector can be deleted, edited and duplicated.

#### Duplication

To save time, the connector can be duplicated.  This new connector needs to be named and can be edited, as needed.

<figure><img src="https://353417064-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MYrsDW6vGBTygB1qqSE%2Fuploads%2F4xmlm9w6NXvPy9hv6joo%2FCleanShot%202024-01-04%20at%2020.53.21%402x.png?alt=media&#x26;token=eeeaacf6-f97f-4b2b-bbac-df07b4ed9c2a" alt="" width="563"><figcaption></figcaption></figure>
