Introduction
Welcome to the Nethernite API! You can use our API to access Nethernite API endpoints, which can get information on various monsters, trades, and control account in Nethernite World.
We have language bindings in some languages! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.
This API documentation page under development. Feel free to contact us to explain actions or add new endpoints.
Terms of Service
NEVER SHARE YOUR API KEY WITH ANYONE. YOUR API KEY GRANTS FULL, UNRESTRICTED ACCESS TO YOUR NETHERNITE ACCOUNT.
OpenID Authentication API
NOTE: Either API endpoint requires an API key specified as a request parameter. Consider API key as a personal, unique code assigned to your Nethernite account with a purpose of giving you access to API functionality
Nethernite can be used as an OpenID Provider. That means you can authenticate users on your website through Nethernite (of course, user needs to be registered and have an account in Nethernite). OpenID approach allows to store private credentials (i.e. username, password) in one centralized place, called OpenID Provider. So you, as a developer, don't have to worry about storing user passwords inside your system (Rellying Party).
We suggest to use LightOpenID (https://github.com/iignatov/LightOpenID) for PHP. It provides handy methods to implement OpenID authentication on client side. In case when you don't want to use LightOpenID library we suggest to look at OpenID specification (https://openid.net/specs/openid-authentication-2_0.html). This will help you to understand how to supply correct requests to OpenID provider by yourself.
OpenID authentication implies a few steps:
- Sending authentication request to provider (Nethernite server).
- Confirmation of authentication attempt on Nethernite website. OpenID authentication implies exposing of some private user data to Rellying Party (in our case - it is user ID), so user has to be informed about that and asked for approval.
- In positive case, sending request back to Rellying Party.
- Validating Provider's request on Rellying Party side (by checking request signature), obtaining user identity from the request and using it as intended.
Initialize
<?php
require 'LightOpenID.php';
// Create OpenID client and specify trust hostname which will be used in the request to OpenID provider
$client = new LightOpenID('example.com');
// Specify identity property. Use exactly this value.
$client->identity = 'https://nethernite.com/openid/openid';
// Specify callback url to handle response from Provider
// This endpoint is responsible to accept response from Provider, validate it and move on to your own logic
$client->returnUrl = 'https://example.com/openid/callback';
// Redirect user-agent to the authentication endpoint on Nethernite side
header('Location: ' . $openid->authUrl());
// If everything above was specified correctly user will be redirected to Nethernite website.
// On the Nethernite user has to approve that he is going to authenticate and expose some data to www.example.com.
// If user is not authenticated on Nethernite, he has to provide username and password and be authenticated to proceed
?>
Suppose you are implementing OpenID authentication on your website www.example.com. We will use LightOpenID library
Fully working example you find on GitHub: Nethernite Auth
Simple code to send authentication request to Provider
Response
<?php
// Callback handler https://example.com/openid/callback
// Create OpenID client instance
$client = new LightOpenID('example.com');
if ($client->mode) {
$is_valid = FALSE;
// There is a direct request to Provider under the hood.
// Checks request signature to be sure that data you are going to handle comes from trusted Provider
try {
$is_valid = $client->validate();
} catch (Exception $e){
echo 'Error auth validation '.$e->getMessage();
}
if ($is_valid) {
// Obtain user ID
if (!preg_match('#id=(.*)$#', $client->identity, $match)) {
echo "Something is wrong. Impossible to extract user id";
}
$user_id = $match[1];
// Now you've got Nethernite user ID
// Save it in session to log user in OR send it to our API to grab some user profile details (assuming that you already have a key to use API)
$url = 'https://nethernite.com/user_api/get_any_user_data?key=XXXXXXXXXXXX&user_id=' . $user_id;
$json = file_get_contents($url);
$user_data = json_decode($json);
$profile_image = $user_data['avatar'];
$profile_name = $user_data['name'];
} else {
echo 'Fail! Request is not valid';
}
}
Accept response from OpenID provider, validate it and proceed with your own workflow
API Endpoints
NOTE: Either API endpoint requires an API key specified as a request parameter. Consider API key as a personal, unique code assigned to your Nethernite account with a purpose of giving you access to API functionality
Get user profile data
The above command returns JSON structured like this:
{
"status":"success",
"error_message":"",
"data":{
"id":63,
"name":"haremabaju",
"avatar":"https:\/\/cdn.nethernite.com\/users\/default_assets\/avatar_default_1.png",
"level":1,
"balance":864,
"is_login":false,
"is_ban":null,
"front_session":"acc7cb31737ac9cac46e14585069fedc",
"sold_pets":0,
"bought_pets":0,
"volume_music":0,
"volume_all_sound":0,
"time_last_action":"2018-10-02 01:41:48"
}
}
Returns specific user profile information
HTTP Request
GET https://nethernite.com/user_api/get_any_user_data
Query Parameters
Parameter | Type | Required | Description |
---|---|---|---|
key | string | yes | Your API key. |
id | integer | yes | User ID |
Get user inventory
The above command returns JSON structured like this:
{
"status": "success",
"error_message": "",
"data": [
{
"item_id": 6996,
"item_type": "monster",
"inventory_id": 9330,
"booster_pack_id": 2683,
"level": 1,
"monster_base_id": 61703,
"quality": "2",
"breed": "P_B",
"breed_stats": [
0.4,
0.9,
0.4
],
"img": "https://cdn.nethernite.com/pets/c4df1a3c85b120c1da05a455f9d37f8a/char_300x300_min.png",
"img_small": "https://cdn.nethernite.com/pets/c4df1a3c85b120c1da05a455f9d37f8a/char_100x100_min.png",
"name": "Rocky",
"type": 7,
"experience": 0,
"experience_to_next": 50,
"health": 150,
"power": 11,
"speed": 10,
"breeds": "216",
"quality_name": "uncommon",
"type_name": "elemental",
"available_breeds": [
"H_H",
"H_P",
"H_S",
"P_B"
],
"is_sellable": 1,
"is_tradable": 1,
"sold_count": 10,
"min_price": 1,
"max_price": 123
},
{
"item_id": 9328,
"item_type": "monster",
"inventory_id": 12241,
"booster_pack_id": 2883,
"level": 1,
"monster_base_id": 61703,
"quality": "1",
"breed": "H_S",
"breed_stats": [
0.9,
0,
0.9
],
"img": "https://cdn.nethernite.com/pets/aabda8c9ed69cb2b83c509a2e20df4f8/char_300x300_min.png",
"img_small": "https://cdn.nethernite.com/pets/aabda8c9ed69cb2b83c509a2e20df4f8/char_100x100_min.png",
"name": "Rocky",
"type": 7,
"experience": 0,
"experience_to_next": 50,
"health": 149,
"power": 9,
"speed": 10,
"breeds": "216",
"quality_name": "common",
"type_name": "elemental",
"available_breeds": [
"H_H",
"H_P",
"H_S",
"P_B"
],
"is_sellable": 1,
"is_tradable": 1,
"sold_count": 24,
"min_price": 1,
"max_price": 222
}
]
}
Returns a list of inventory items for current user
HTTP Request
GET https://nethernite.com/user_api/get_user_inventory
URL Parameters
Parameter | Type | Required | Description |
---|---|---|---|
key | string | yes | Your API key. |
Send offer
The above command returns JSON structured like this:
{
"status": "success",
"error_message": "",
"data": {}
}
Sends trade offer to another user, specifying inventory items you submit for exchange
HTTP Request
POST https://nethernite.com/user_api/send_offer
Query Parameters
Parameter | Type | Required | Description |
---|---|---|---|
key | string | yes | Your API key. |
items | array | yes | Array of item IDs from your inventory you offer to exchange. |
receiver_user_id | integer | yes | The user's ID you send a trade offer to. |
Get trade history
The above command returns JSON structured like this:
{
"status": "success",
"error_message": "",
"data": {
"offers": {
"data": [
{
"id": 541,
"offer_id": 209,
"action_type": "SENT",
"status": "CANCEL",
"history_status": "DONE_CANCEL",
"user_sender_status": "CANCEL",
"user_receiver_status": "NEW",
"time_updated": "2018-12-24 11:00:05",
"sender_name": "John Doe",
"receiver_name": "Bob Jonson"
},
{
"id": 539,
"offer_id": 209,
"action_type": "SENT",
"status": "CANCEL",
"history_status": "CREATE",
"user_sender_status": "CANCEL",
"user_receiver_status": "NEW",
"time_updated": "2018-12-24 11:00:05",
"sender_name": "John Doe",
"receiver_name": "Bob Jonson"
}
],
"total_count": 2,
"success_count": 0,
"failed_count": 2
}
}
}
Returns representation of user's trade history
HTTP Request
GET https://nethernite.com/user_api/get_trade_history
URL Parameters
Parameter | Type | Required | Description |
---|---|---|---|
key | string | yes | Your API key. |
max_trades | integer | no | Limits the number of trade offers to be returned |
start_after_time | integer | no | Unix timestamp. To return trade offers, any action was taken to them (updated / confirmed / applied etc.) after the specified timestamp. In other words, this value corresponds to 'time_updated' field in response data set. Example: start_after_time=1545714000 , matches to trade offers which were created, or cancelled, or approved after December 23, 2018. |
start_after_tradeid | integer | no | To filter trade offers list and return offers with ID greater than specified value |
Get trade offers
The above command returns JSON structured like this
{
"status": "success",
"error_message": "",
"data": {
"sended": [
{
"id": "208",
"sender_user_id": "75",
"receiver_user_id": "82",
"user_sender_status": "CONFIRM",
"user_receiver_status": "NEW",
"status": "NEW",
"time_created": "2018-12-24 10:11:22",
"time_updated": "2018-12-24 10:11:22"
}
],
"taken": [
{
"id": "208",
"sender_user_id": "82",
"receiver_user_id": "75",
"user_sender_stat us": "CONFIRM",
"user_receiver_status": "NEW",
"status": "NEW",
"time_created": "2018-12-24 12:10:22",
"time_updated": "2018-12-24 12:30:22"
}
]
}
}
Returns trade offers related to current user and filtered by status specified as a parameter
HTTP Request
GET https://nethernite.com/user_api/get_trade_offers
URL Parameters
Parameter | Type | Required | Description |
---|---|---|---|
key | string | yes | Your API key. |
status | enum | yes | Offer status to filter by ('NEW', 'CONFIRM', 'CANCEL', 'DONE'). |
Get trade offer
The above command returns JSON structured like this:
{
"status": "success",
"error_message": "",
"data": [
{
"item_id": 15885,
"item_type": "monster",
"inventory_id": 33303,
"booster_pack_id": 4086,
"level": 1,
"monster_base_id": 62669,
"quality": "3",
"breed": "H_P",
"breed_stats": [
0.9,
0.9,
0
],
"img": "https://cdn.nethernite.com/pets/1db28778e121c936ede0791c75907d99/char_300x300_min.png",
"img_small": "https://cdn.nethernite.com/pets/1db28778e121c936ede0791c75907d99/char_100x100_min.png",
"name": "Sliver Warg Cub",
"type": 8,
"experience": 0,
"experience_to_next": 50,
"health": 158,
"power": 12,
"speed": 10,
"breeds": "18",
"quality_name": "rare",
"type_name": "beast",
"available_breeds": [
"P_P",
"H_P"
],
"is_sellable": 1,
"is_tradable": 1,
"sold_count": 0,
"min_price": 0,
"max_price": 0
},
{
"item_id": 15887,
"item_type": "monster",
"inventory_id": 33305,
"booster_pack_id": 4086,
"level": 1,
"monster_base_id": 32592,
"quality": "1",
"breed": "H_P",
"breed_stats": [
0.9,
0.9,
0
],
"img": "https://cdn.nethernite.com/pets/59927ae9c811110d5d9cbed2d576dec4/char_300x300_min.png",
"img_small": "https://cdn.nethernite.com/pets/59927ae9c811110d5d9cbed2d576dec4/char_100x100_min.png",
"name": "The Firewing",
"type": 2,
"experience": 0,
"experience_to_next": 50,
"health": 152,
"power": 10,
"speed": 8,
"breeds": "16",
"quality_name": "common",
"type_name": "dragonkin",
"available_breeds": [
"H_P"
],
"is_sellable": 1,
"is_tradable": 1,
"sold_count": 0,
"min_price": 0,
"max_price": 0
}
]
}
Get list of inventory items for specified offer
HTTP Request
GET https://nethernite.com/user_api/get_trade_offer
URL Parameters
Parameter | Type | Required | Description |
---|---|---|---|
key | string | yes | Your API key. |
offer_id | integer | yes | Trade offer ID. |
Get trade offers summary
The above command returns JSON structured like this:
{
"status": "success",
"error_message": "",
"data": {
"in_progress": "2",
"new": "0"
}
}
Returns short summarized information about trade offers related to current user
HTTP Request
GET https://nethernite.com/user_api/get_trade_offers_summary
URL Parameters
Parameter | Type | Required | Description |
---|---|---|---|
key | string | yes | Your API key. |
time_last_visit | integer | no | Pass Unix timestamp to specify a limit of trade offers involved to calculate a summary. If not specified, this method will be use a time of last user's action in the system as a default value. |
Confirm trade offer
The above command returns JSON structured like this:
{
"status": "success",
"error_message": "",
"data": {}
}
Confirm trade offer received from another user
HTTP Request
GET https://nethernite.com/user_api/confirm_trade_offer
URL Parameters
Parameter | Type | Required | Description |
---|---|---|---|
key | string | yes | Your API key. |
offer_id | integer | yes | Offer ID. |
Decline trade offer
The above command returns JSON structured like this:
{
"status": "success",
"error_message": "",
"data": {}
}
Decline trade offer received from another user
HTTP Request
GET https://nethernite.com/user_api/decline_trade_offer
URL Parameters
Parameter | Type | Required | Description |
---|---|---|---|
key | string | yes | Your API key. |
offer_id | integer | yes | Offer ID. |
Cancel trade offer
The above command returns JSON structured like this:
{
"status": "success",
"error_message": "",
"data": {}
}
Cancel your trade offer sent to another user
HTTP Request
GET https://nethernite.com/user_api/cancel_trade_offer
URL Parameters
Parameter | Type | Required | Description |
---|---|---|---|
key | string | yes | Your API key. |
offer_id | integer | yes | Offer ID. |