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

Parametermpm
Required or Optionaloptional
DescriptionMessages per minute. Only applicable when cmd=start. (default: 1)
Typeint

Parameterimif (Inter Message Issuing Function)
Required or Optionaloptional
DescriptionParameter indicating time interval between issued messages. Possible values: poisson, uniform. Field only available in HTTP API.
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&mpm=1000'
curl --location 'http://localhost:8080/spammer?cmd=start&mpm=1000&imif=uniform'
curl --location 'http://localhost:8080/spammer?cmd=shutdown'

Client lib - ToggleSpammer()

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

res, err := goshimAPI.ToggleSpammer(true, 100)
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.