# Communicating with an External API

You can send GET, POST, etc. requests with arguments to an external API.

### httpGet

Changes the nicknames of the users who have just entered with the [<mark style="color:purple;">Korean Nickname Generator</mark>](https://nickname.hwanmoo.kr/) API.

<div align="center"><figure><img src="/files/V94qyeJZkFw39OGYgHeE" alt=""><figcaption></figcaption></figure></div>

{% code overflow="wrap" %}

```jsx
// Executes when a player enters
App.onJoinPlayer.Add(function (player) {
	App.httpGet(
		"https://nickname.hwanmoo.kr/?format=json&count=1&max_length=6&whitespace=_",
		null,
		function (res) {
			// Change the response to a JSON object
			let response = JSON.parse(res);
			player.name = response.words[0];
			player.sendUpdated();
		}
	);
});
```

{% endcode %}

### httpPost

Receives the header and data sent from the app in response and displays it in the chat window.

{% code overflow="wrap" %}

```jsx
// Activates function when q is pressed
App.addOnKeyDown(81, function (player) {
	App.httpPost(
		"https://postman-echo.com/post",
		{
			"test-header": "zep",
		},
		{
			name: "zepscript",
		},
		(res) => {
			let response = JSON.parse(res);
			App.sayToAll(`header sent: ${response.headers["test-header"]}`, 0xffffff);
			App.sayToAll(`data sent: ${response.form.name}`, 0xffffff);
		}
	);
});
```

{% endcode %}

{% hint style="warning" %}
Please Note&#x20;

\- For the tutorial, we recommend setting the app type to Mini-Game.&#x20;

\- The JSON file name must be “main.” Please create a new text file and name it “main.js.”&#x20;

\- If you do not know how to deploy an app, please refer to the [<mark style="color:purple;">**ZEP Script Deployment Guide**</mark>](/zep-script/zep-script-guide/zep-script-development-guide/zep-script-deployment-guide.md)<mark style="color:purple;">.</mark>
{% endhint %}

***


---

# 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://docs.zep.us/zep-script/zep-script-guide/explore-zep-script/tutorials/communicating-with-an-external-api.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.
