Skip to main content

Spammer API Methods

The Spammer tool lets you add messages to the tangle when running GoShimmer. Note: Make sure you enable the spammer plugin before interacting with the API.

The API provides the following functions and endpoints:

Client lib APIs:

/spammer

In order to start the spammer, you need to send GET requests to a /spammer API endpoint with the following parameters:

Parameters

Parametercmd
Required or Optionalrequired
DescriptionAction to perform. One of two possible values: start and stop.
Typestring
Parameterrate
Required or Optionaloptional
DescriptionMessages per time unit. Only applicable when cmd=start. (default: 1)
Typeint
Parameterunit
Required or Optionaloptional
DescriptionIndicates the unit for the spam rate: message per minute or second. One of two possible values: mpm and mps. (default: mps)
Typestring
Parameterimif (Inter Message Issuing Function)
Required or Optionaloptional
DescriptionParameter indicating time interval between issued messages. Possible values: poisson, uniform.
Typestring

Description of imif values:

  • poisson - emit messages modeled with Poisson point process, whose time intervals are exponential variables with mean 1/rate
  • uniform - issues messages at constant rate

Examples

cURL

curl --location 'http://localhost:8080/spammer?cmd=start&rate=100'
curl --location 'http://localhost:8080/spammer?cmd=start&rate=100&imif=uniform&unit=mpm'
curl --location 'http://localhost:8080/spammer?cmd=stop'

Client lib - ToggleSpammer()

Spammer can be enabled and disabled via ToggleSpammer(enable bool, rate int, imif string) (*jsonmodels.SpammerResponse, error)

res, err := goshimAPI.ToggleSpammer(true, 100, "mps", "uniform")
if err != nil {
// return error
}

// will print the response
fmt.Println(res.Message)

Response examples

{"message": "started spamming messages"}

Results

Return fieldTypeDescription
messagestringMessage with resulting message.
errorstringError message. Omitted if success.