HiveMP Attributes Quickstart

How did we do?

HiveMP Attributes allows you to easily store and retrieve metadata against objects in HiveMP. This quickstart will guide you through setting and retrieving an attribute against the current session.

Create a session

If you don't currently have an active HiveMP session, you'll need to create one as outlined in HiveMP Sessions Quickstart. Once you have a session ID and API key, you can proceed with the guide below.

Set an attribute against your current session

Replace YOUR_SESSION_ID with the ID of your current session. This will set a new attribute against your session:

curl -s \
  -H "X-API-Key: $apiKey" \
  -H "Accept: application/json" \
  -H "Content-Length: 0" \
  -X PUT \
  "https://attribute-api.hivemp.com/v1/attribute"\
"?id=YOUR_SESSION_ID"\
"&key=test"\
"&value=Hello+World"

Retrieve a list of owners who have set an attribute against your current session

You can retrieve a list of owners that have set values for an attribute against your current session by using the GET /attributes. Note that this doesn't get the value of those attributes, you need to make a separate call to GET /attribute to retrieve the actual value.

Replace YOUR_SESSION_ID with the ID of your current session. This will retrieve all the owners of attribute values against your session:

curl -s \
  -H "X-API-Key: $apiKey" \
  -H "Accept: application/json" \
  -H "Content-Length: 0" \
  -X GET \
  "https://attribute-api.hivemp.com/v1/attributes"\
"?id=YOUR_SESSION_ID"

After executing this method, you'll receive the list of attribute owners similar to the one below:

[
  {
    "key": "us-5705148370255872",
    "ownerId": "u-5705148370255872"
  }
]

Retrieve an attribute value against your current session

Replace YOUR_SESSION_ID with the ID of your current session and OWNER_ID based on the owner retrieved in the previous request.

curl -s \
  -H "X-API-Key: $apiKey" \
  -H "Accept: application/json" \
  -H "Content-Length: 0" \
  -X GET \
  "https://attribute-api.hivemp.com/v1/attribute"\
"?id=YOUR_SESSION_ID"\
"&key=test"\
"&ownerId=OWNER_ID"

After executing this method, you'll receive the list of attribute owners similar to the one below:

{
  "key": "us-5705148370255872",
  "ownerId": "u-5705148370255872",
  "value": "Hello World"
}