# Communicating with an External API

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

### httpGet

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

![](https://3059601135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkvEvcz_LX5eDyvl13E%2Fuploads%2FUaBYNpoDET0ZBv0sGril%2Fimage.png?alt=media\&token=a3be097b-ac9b-41c8-81bb-49fe1318f3ab)

```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();
		}
	);
});
```

### httpPost

Receive the header and data sent from the app in response and display in the chat window.

```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);
		}
	);
});
```

{% hint style="warning" %}
Please Note

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