curl/Postman Example
Example
Authentication
STEDI_API_KEY
environment variable. If using Postman, the API key can be configured under the "Authorization" header with Type set to API Key
, Key set to Authorization
and Value set to Key <your-stedi-api-key>
.Creating a Keyspace
In order to store keys and values, we need to create a Keyspace. We may use a single Keyspace for different situations, as long as we ensure that the keys will not overwrite one another.
curl --request POST 'https://stash.us.stedi.com/2022-04-20/CreateKeyspace' \
--header "Authorization: Key ${STEDI_API_KEY}" \
--header 'Content-Type: application/json' \
--data-raw '{
"keyspaceName": "my-keyspace"
}'
/GetKeyspace
operation
to determine if it is in the ACTIVE
state.Storing Values
foo
and the Value is bar
. Note how we use the same Keyspace name as used in the previous step.curl --request POST 'https://stash.us.stedi.com/2022-04-20/SetValue' \
--header "Authorization: Key ${STEDI_API_KEY}" \
--header 'Content-Type: application/json' \
--data-raw '{
"keyspaceName": "my-keyspace",
"key": "foo",
"value": "bar"
}'
Retrieving Values
GetValue
operation to retrieve any values.curl --request POST 'https://stash.us.stedi.com/2022-04-20/GetValue' \
--header "Authorization: Key ${STEDI_API_KEY}" \
--header 'Content-Type: application/json' \
--data-raw '{
"keyspaceName": "my-keyspace",
"key": "foo"
}'
Atomically increment a number
IncrementValue
operation will atomically increment a number by the amount
specified. If the key does not exist, it will be initialized with 0. If the key exists and is not a number, this results in a ValidationError
error.curl --request POST 'https://stash.us.stedi.com/2022-04-20/IncrementValue' \
--header "Authorization: Key ${STEDI_API_KEY}" \
--header 'Content-Type: application/json' \
--data-raw '{
"keyspaceName": "my-keyspace",
"key": "increasing-number",
"amount": 1
}'
Feedback
Have an idea for something we could improve? Page not clear? We love feedback - send us a message.