Skip to content

WebSockets

WebSockets allow you to receive real-time notifications from the server.

Notifications supported:

NameSubscription codeCategoryTypeDescription
Event spawnevent_spawnEventsServerSend ActiveEventSchema when an event spawn.
Event removedevent_removedEventsServerSend ActiveEventSchema when an event expires and is removed.
Grand Exchange new sell ordergrandexchange_sell_orderGrand ExchangeServerSend GEOrderSchema when a sell order is created on the Grand Exchange
Grand Exchange new buy ordergrandexchange_buy_orderGrand ExchangeServerSend GEOrderSchema when a buy order is created on the Grand Exchange
Grand Exchange buygrandexchange_buyGrand ExchangeServerSend GeOrderHistorySchema when a buy is completed (buyer purchases from a sell order)
Grand Exchange sellgrandexchange_sellGrand ExchangeServerSend GeOrderHistorySchema when a sale is completed (seller fills a buy order)
Pending Item Receivedpending_item_receivedPending ItemsServerSend PendingItemSchema when an item is sent to the player’s pending items (from achievements, Grand Exchange purchases, etc.)
Online charactersonline_charactersCharactersServerSend array[ActiveCharacterSchema] at the connection and every 10 minutes with the list of online characters.
VersionversionServerServerSend the API server version at the connection and at every update.
AnnouncementannouncementAnnouncementsServerSends {"message": "string"} when a new announcement is published.
Achievement unlockachievement_unlockedAchievementsAccountSend AchievementSchema when an achievement is unlocked on your account.
Account logaccount_logLogsAccountSend LogSchema every time an action is performed on one of the characters in your account.
TesttestTestTestSend Test message every 60 seconds.

The WebSocket server is: wss://realtime.artifactsmmo.com

Next, you need to include your token and the types of notifications you want to receive in the first message you send to the server.

message = {
"token": token,
"subscriptions": ["event_spawn", "event_removed", "grandexchange_neworder", "grandexchange_sell", "achievement_unlocked", "test"]
}

If you want to receive all notifications, you don’t need to include subscriptions.

import asyncio
import websockets
import json
url = "wss://realtime.artifactsmmo.com"
token = "YOUR_TOKEN" # Replace with your token
message = {
"token": token,
"subscriptions": ["event_spawn", "event_removed", "grandexchange_neworder", "grandexchange_sell", "achievement_unlocked", "test"]
}
async def receive_messages():
async with websockets.connect(url) as websocket:
await websocket.send(json.dumps(message))
print("Connected to the WebSocket server")
try:
while True:
# Waits for a message from the server
message_received = await websocket.recv()
message_received = json.loads(message_received)
print(f"Message received: {message_received}")
except websockets.ConnectionClosed:
print("Connection closed by the server")
# Start the WebSocket client
asyncio.run(receive_messages())

Server messages always include notification type and data. Data is always the same schema returned by the API if possible.

Here’s an example of a server message:

{
'type': 'grandexchange_neworder',
'data': {"id":"67337920ef441b2c7466d5e8","seller":"muigetsu","code":"copper_ore","quantity":1,"price":1,"created_at":"2024-11-12T15:49:52.343Z"}
}