Using the API
Once you have been issued with an API key after registering an application, review the document. (API keys can be found by going to My Applications > Application Details.) Sending an API request is simple, but there are a few details you need to be aware of when making a request.
API search
You can view the list of APIs for each game provided through NEXON Open API by navigating to the top Games menu. Each API provides the following information.
API information
It provides a description of the API and the request URL that will actually be used. Parameters that need to be sent along with the API call are listed under "Parameters," and descriptions of these parameters can be found under "Description."
Request parameters (Parameters)
This section indicates parameter information that must be transmitted to the server when sending a request to the open API. Take care not to omit parameters marked as *required when calling the API.
Responses
This section provides response information received after sending a request to the open API. “Response Description” provides a description or structure of the data received when sending a request to the API normally. “Response Headers” and “Response Body” are used when testing the API. For a more detailed explanation, refer to the “API Testing” section below.
API usage
When you call the request URL found under the Games menu, you can use the Open API. However, you must also send the required request parameters specific to each API. When calling an open API provided by NEXON Open API, you need to include your API Key value in the Header to use it properly.
Type | Key name | Content type |
---|---|---|
Header | x-nxopen-api-key | String |
If an error occurs while using the API, the reason for the error can be determined by looking at the response code. Please refer to the response code table below.
Error code | Response code | Response name | Description |
---|---|---|---|
OPENAPI00001 | 500 | Internal Server Error | Internal server error |
OPENAPI00002 | 403 | Forbidden | Unauthorized access |
OPENAPI00003 | 400 | Bad Request | Invalid identifier |
OPENAPI00004 | 400 | Bad Request | Missing or invalid parameter |
OPENAPI00005 | 400 | Bad Request | Invalid API key |
OPENAPI00006 | 400 | Bad Request | Invalid game or API path |
OPENAPI00007 | 429 | Too Many Requests | API call limit exceeded |
OPENAPI00009 | 400 | Bad Request | Data being prepared |
OPENAPI00010 | 400 | Bad Request | Service under maintenance |
OPENAPI00011 | 503 | Service Unavailable | API under maintenance |
API testing
All open APIs provided by NEXON Open API can be tested directly within the Games menu, where you can also view the response values for each test. (The test feature can be used only after logging in with a NEXON ID and obtaining the API key for the API you wish to test.)
- Go to Game > Select a game, and select the API you want to test from the API list.
- Click the “Try it out” button.
- Enter the request parameters in the “Parameters” field.
- Click the “Execute” button to send the request.
- Confirm the following information:
- Curl/Request URL: The URL that the request was actually sent to by including the input parameter values.
- Server response
- Code: HTTP status code indicating the status of the request result
- Response Headers: Response header value
- Response Body: Response data
API sample code
Java sample code
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
public class ApiExample {
public static void main(String[] args) {
try {
String API_KEY = "YOUR API KEY HERE";
String characterName = URLEncoder.encode("CHARACTER NAME", StandardCharsets.UTF_8);
String urlString = "https://open.api.nexon.com/heroes/v1/id?character_name=" + characterName;
URL url = new URL(urlString);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("x-nxopen-api-key", API_KEY);
int responseCode = connection.getResponseCode();
BufferedReader in;
if(responseCode == 200) {
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
} else {
in = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
}
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
} catch (Exception exception) {
System.out.println(exception);
}
}
}
JavaScript sample code
const API_KEY = "YOUR API KEY HERE";
const characterName = "CHARACTER NAME";
const urlString = "https://open.api.nexon.com/heroes/v1/id?character_name=" + characterName;
const answer = fetch(urlString, {
headers:{
"x-nxopen-api-key": API_KEY
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error))
console.log(answer)
Python sample code
headers = {
"x-nxopen-api-key": "YOUR API KEY HERE"
}
characterName = "CHARACTER NAME"
urlString = "https://open.api.nexon.com/heroes/v1/id?character_name=" + characterName
response = requests.get(urlString, headers = headers)
print(response.json())
Creating applications
Although you may freely create applications using Open API within the Terms and Conditions specified, when creating an application, you must specify within the application that the data was provided by NEXON Open API.
Crediting NEXON Open API
Please place the phrase “Data based on NEXON Open API” within services and applications.