# HTTP

## Generate Badge From HTTP Response

Generates the badge in SVG format from response of the given HTTP URL by processing the response with the given expression to resolve badge message. In the Globadge side, the execution steps are;

* Takes HTTP URL and expression as input
* Calls the given HTTP URL and gets the response
* Processes the returned result with the given expression to resolve the badge message
* Builds the badge from given label and resolve message to return to the client in SVG format

### URL&#x20;

`https://api.globadge.com/v1/badgen/http/{expressionType}?httpURL=<httpURL>&label=<label>&labelColor=<labelColor>&messageExpression=<messageExpression>&messageColor=<messageColor>`

* **`expressionType (*)`:** The type of the expression to be used while resolving badge message from HTTP URL response by message expression. Currently, only `jq` expressions are supported. This parameter is passed as **path** **parameter** and it is **mandatory.**
* **`httpURL (*)`:** The HTTP URL to be called with GET method for getting the response which will be used to resolve badge message by message expression. This parameter is passed as **query parameter** and it is **mandatory**.
* **`label (*)`**: The text of the badge label. This parameter is passed as **query parameter** and it is **mandatory**.
* **`messageExpression (*)`**: The expression to be used for resolving badge message from the response of the HTTP URL. The expression must be valid in the context of the expression type passed as path parameter as mentioned above. Currently, only `jq` expressions are supported. This parameter is passed as **query parameter** and it is **mandatory**.
* **`labelColor`**: The color of the badge label. The supported colors are listed [here](https://github.com/badges/shields/tree/master/badge-maker#colors). This parameter is passed as **query parameter** and it is **optional**.
* **`messageColor`**: The color of the badge message. The supported colors are listed [here](https://github.com/badges/shields/tree/master/badge-maker#colors).  This parameter is passed as **query parameter** and it is **optional**.

### Method

`GET`

### Notes

* Given HTTP URL is called only by `GET` method and it is not configurable by parameters.
* Badge responses are cached during **5 minutes**. So, even if the given HTTP URL returns different result, you will get the same badge response during 5 minutes (if the link has the same message expression and label parameters)&#x20;

### Example

The following example gets the latest version of the OpenTelemetry AWS Lambda Collector layer from Github releases:&#x20;

* **`expressionType`:** `jq`&#x20;
* **`httpURL`:** `https://api.github.com/repos/open-telemetry/opentelemetry-lambda/releases`
* **`label`:** `Collector` &#x20;
* **`messageExpression`:**&#x20;

  ```jq
  first(.[].tag_name | select(. | startswith(\"layer-collector\"))) | split(\"/\") | .[1] | sub(\"\\\\.\"; \"_\"; \"g\")
  ```

**Note:** Given parameters as part of the whole URL needs to be encoded as shown below.

{% embed url="<https://api.globadge.com/v1/badgen/http/jq?httpURL=https%3A%2F%2Fapi.github.com%2Frepos%2Fopen-telemetry%2Fopentelemetry-lambda%2Freleases&messageExpression=first%28.%5B%5D.tag_name%20%7C%20select%28.%20%7C%20startswith%28%22layer-collector%22%29%29%29%20%7C%20split%28%22%2F%22%29%20%7C%20.%5B1%5D%20%7C%20sub%28%22%5C%5C%5C%5C.%22%3B%20%22_%22%3B%20%22g%22%29&label=Collector>" %}

## Create Badge HTTP Config

Creates badge HTTP config from given options in the path parameter and request body. Then returns created config id and Globadge API URL to be invoked with GET request to generate the badge from saved config.

### URL&#x20;

`https://api.globadge.com/v1/badgen/http/{expressionType}`

### Method

`PUT`&#x20;

### Request

```json
{
    // [Mandatory] HTTP URL to be invoked with GET request to get response 
    "httpURL": "<HTTP-URL>",
    // [Optional] HTTP headers in string typed key/value format 
    "httpHeaders": {
        "<HEADER-1>": "<HEADER-1-VALUE>",
        ...
        "<HEADER-N>": "<HEADER-N-VALUE>",
    },
    // [Mandatory] Label of the badge
    "label": "<LABEL>",
    // [Mandatory] The expression to be used for resolving badge message from the response of the HTTP URL
    "messageExpression": "<MESSAGE-EXPRESSION>"
}
```

#### Example Request

```json
{
    "httpURL": "https://api.github.com/repos/open-telemetry/opentelemetry-lambda/releases",
    "httpHeaders": {
        "Authorization": "Bearer ...",
        ...
    },
    "label": "Collector",
    "messageExpression": "first(.[].tag_name | select(. | startswith(\"layer-collector\"))) | split(\"/\") | .[1] | sub(\"\\\\.\"; \"_\"; \"g\")"
}
```

### Response

Returns created config id and Globadge API URL to generate badge from saved configs:

```json
{
    // Id (in UUID v4 format) of the created badge HTTP config
    "id": "<HTTP-CONFIG-ID>",
    // Globadge API URL to be invoked with GET request to generate badge from saved config
    // "<EXPRESSION-TYPE>" represent the value passed in the request path parameters for the expression type
    // "<HTTP-CONFIG-ID>" represents the created config id which is returned in the "id" field in this response (above). 
    "url": "https://api.globadge.com/v1/badge/http/<EXPRESSION-TYPE>/<HTTP-CONFIG-ID>"
}
```

## Generate Badge From HTTP Response (By Created Config)

Generates the badge in SVG format from the given created badge HTTP config [here](#create-badge-http-config).&#x20;

In the Globadge side, the execution steps are;

* Gets the badge config (HTTP URL, HTTP headers, expression, label, etc ...) from the given config id
* Takes HTTP URL and expression as input
* Calls the given HTTP URL with the configured HTTP headers (if there is) and gets the response
* Processes the returned result with the given expression to resolve the badge message
* Builds the badge from given label and resolve message to return to the client in SVG format

### URL&#x20;

`https://api.globadge.com/v1/badgen/http/{expressionType}/{httpConfigId}`&#x20;

**`expressionType (*)`:** The type of the expression to be used while resolving badge message from HTTP URL response by message expression. Currently, only `jq` expressions are supported. This parameter is passed as **path** **parameter** and it is **mandatory.**

**`httpConfigId (*)`:** Id (in UUID v4 format) of the created badge HTTP config [here](#create-badge-http-config). This parameter is passed as **path** **parameter** and it is **mandatory.**

### Method

`GET`

### Notes

* Given HTTP URL is called only by `GET` method and it is not configurable by parameters.
* Badge responses are cached during **5 minutes**. So, even if the given HTTP URL returns different result, you will get the same badge response during 5 minutes.

### Example

The following example shows the latest version of the OpenTelemetry AWS Lambda Collector layer from Github releases:&#x20;

* **`expressionType`:** `jq`&#x20;
* **`httpConfigId`:** `e3309d56-dfd6-4dae-ac00-4498070d84f0`&#x20;

{% embed url="<https://api.globadge.com/v1/badgen/http/jq/e3309d56-dfd6-4dae-ac00-4498070d84f0>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.globadge.com/badges/http.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
