CRUD Store Data

The /v2/store/<login_id> endpoints are used for creation, retrieval, and update of Store data. For more information about the Store, go here.

login_id is optional. If not specified, the API commands operate on the global Store data. If specified, the API commands operate on the Store data for the specified user.

 

Create or update Store data

Sets a key/value pair.

Summary

  • Endpoint: /v2/store/<login_id>
  • Method: POST
  • Permissions: This operation is permitted for Basic User and Business User roles. 

Headers

Content-Type: application/json
Accept: application/json
Cookies: < login cookies >

Body

  • key(required): string meeting Store requirements

  • value (required): string meeting Store requirements or a number if operation is set to "incr"
  • operation (required): string defining operation on the key/value pair
    • Options
      • "set" - associate the specified value with the key
      • "incr" - increment existing value (or set to 0 if doesn't exist) by specified value
 

Can be multiple items, one JSON document per line (with newline character between each JSON document). The POST body has a maximum limit of 10MB.

  • Example of single item

    {"key": "foo", "value": "123", "operation": "set"}
  • Example of multiple items:

    CORRECT

    {"key": "foo", "value": "123", "operation": "set"}
    {"key": "bar", "value": 5, "operation": "incr"}

    INCORRECT

    {"key": "foo", "value": "123", "operation": "set"}{"key": "bar", "value": 5, "operation": "incr"}

HTTP Response

200 OK

  • Store entry successfully created/updated

400 BAD REQUEST

  • The request was missing parameters or the parameters were not formatted correctly.

401 UNAUTHORIZED

  • No authorized user is currently logged in.

403 FORBIDDEN

  • No user matching login_id can be found or not authorized to post data for the given user.

404 NOT FOUND

  • No user matching login_id can be found.

500 SERVER ERROR

  • Could not complete the request due to an internal server error.

503 SERVICE UNAVAILABLE

  • Temporarily unable to complete the request. Please try again.

Examples

Curl

# login as API Basic User and save session cookies
curl -c cookies.txt -i -X POST -d '{"login_id":"biz_user","password":"12345","api_key":"ABCDEFGHIJKLMNOPabcdefghijklmnop1234567890"}' https://api.mediumone.com/v2/login/ --header "Content-Type: application/json"

# send data
curl -b cookies.txt -X POST -k -H 'Content-Type: application/json' -i https://api.mediumone.com/v2/store/biz_user -d '{"key": "foo", "value": "123", "operation": "set"}'

Python

import requests
import json

headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
data = {'login_id': 'biz_user', 'password': '12345', 'api_key': 'ABCDEFGHIJKLmnopabcdefghijklmnop1234567890'}

session = requests.session()
response = session.post('https://api.mediumone.com/v2/login', data=json.dumps(data), headers=headers)

url = 'https://api.mediumone.com/v2/store/biz_user'
data = {"key": "foo", "value": "123", "operation": "set"}

response = session.post(url=url, data=json.dumps(data), headers=headers)

Retrieve Store data

Retrieves either a list of keys or a key/value pair.

Summary

  • Endpoint: /v2/store/<login_id>
  • Method: GET
  • Permissions: This operation is permitted for Basic User and Business User roles. 
 

Headers

Accept: application/json
Cookies: < login cookies >

Path

URL-encoded parameters, all optional:

  • key: Store key to retrieve

HTTP Response

200 OK

  • if key was not specified, a JSON list of the existing Store keys is returned
  • if key was specified, a JSON object with fields "key" and "value" will be returned with associated values of key and the data associated with the Store key, respectively.
    ["foo", "bar"]
    {"key": "foo", "value": "123"}

400 BAD REQUEST

  • The request was missing parameters or the parameters were not formatted correctly.

401 UNAUTHORIZED

  • No authorized user is currently logged in.

403 FORBIDDEN

  • No user matching login_id can be found or insufficient permissions to view that user’s data.

404 NOT FOUND

  • No user matching login_id can be found.

500 SERVER ERROR

  • Could not complete the request due to an internal server error.

503 SERVICE UNAVAILABLE

  • Temporarily unable to complete the request. Please try again.

Examples

Curl

# login as API Basic User and save session cookies
curl -c cookies.txt -i -X POST -d '{"login_id":"biz_user","password":"12345","api_key":"ABCDEFGHIJKLMNOPabcdefghijklmnop1234567890"}' https://api.mediumone.com/v2/login/ --header "Content-Type: application/json"

# get data
curl -b cookies.txt -X GET -k -H 'Accept: application/json' 'https://api.mediumone.com/v2/store?key=foo'

Python

import requests
import json

headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
data = {'login_id': 'biz_user', 'password': '12345', 'api_key': 'ABCDEFGHIJKLmnopabcdefghijklmnop1234567890'}

# Login
session = requests.session()
response = session.post('https://api.mediumone.com/v2/login', data=json.dumps(data), headers=headers)

url = 'https://api.mediumone.com/v2/store'
headers = {'Accept': 'application/json'}
params = {"key":"foo"}

# GET
response = session.get(url=url, params=params, headers=headers)

 

Delete Store data

Removes a key/value pair.

Summary

  • Endpoint: /v2/store/<login_id>
  • Method: DELETE
  • Permissions: This operation is permitted for Basic User and Business User roles. 

Headers

Content-Type: application/json
Accept: application/json
Cookies: < login cookies >

Body

  • key(required): key to delete from Store

Can be multiple items, one JSON document per line (with newline character between each JSON document). The DELETE body has a maximum limit of 10MB.

  • Example of a single item:

    {"key": "foo"}
  • Example of multiple items:

    CORRECT

    {"key": "foo"}
    {"key": "bar"}

    INCORRECT

    {"key": "foo"}{"key": "bar"}

HTTP Response

200 OK

  • Store entry successfully deleted.

400 BAD REQUEST

  • The request was missing parameters.

401 UNAUTHORIZED

  • No authorized user is currently logged in.

403 FORBIDDEN

  • No user matching login_id can be found or not authorized to post data for the given user.

404 NOT FOUND

  • No user matching login_id can be found.

500 SERVER ERROR

  • Could not complete the request due to an internal server error.

503 SERVICE UNAVAILABLE

  • Temporarily unable to complete the request. Please try again.

Examples

Curl

# login as API Basic User and save session cookies
curl -c cookies.txt -i -X POST -d '{"login_id":"biz_user","password":"12345","api_key":"ABCDEFGHIJKLMNOPabcdefghijklmnop1234567890"}' https://api.mediumone.com/v2/login/ --header "Content-Type: application/json"

# send data
curl -b cookies.txt -X DELETE -k -H 'Content-Type: application/json' -i https://api.mediumone.com/v2/store/biz_user -d '{"key": "foo"}'

Python

import requests
import json

headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
data = {'login_id': 'biz_user', 'password': '12345', 'api_key': 'ABCDEFGHIJKLmnopabcdefghijklmnop1234567890'}

session = requests.session()
response = session.post('https://api.mediumone.com/v2/login', data=json.dumps(data), headers=headers)

url = 'https://api.mediumone.com/v2/store/biz_user'
data = {"key": "foo"}

response = session.delete(url=url, data=json.dumps(data), headers=headers)