API

Store Data

Make a post request to /data endpoint with any data you need to.

[JSON] [Successful] Request sample #1 - A Unique key has been passed

curl -X POST \
  https://randapis.com/data \
  -H 'Authorization: Bearer {{YOUR_API_KEY}}' \
  -H 'Content-Type: application/json' \
  -d '{
    "key": "key_to_fetch_data_later",
    "value": {
        "k1": "v1",
        "k2": "v2",
        "k3": "v3"
    }
}'

Response:
HTTP Status: 201 Created
Body:

{
    "_metadata": {
        "result": "success"
    },
    "item": {
        "key": "key_to_fetch_data_later",
        "value": {
            "k1": "v1",
            "k2": "v2",
            "k3": "v3"
        },
        "uuid": "ccd44ccc-6b14-480f-ac6b-47bc138faf90",
        "deleted_at": null,
        "created_at": "2023-05-27T17:00:17.215Z",
        "updated_at": "2023-05-27T17:00:17.215Z",
        "retrievals": 1,
        "retrieved_at": "2023-06-04T23:53:18.431Z"
    }
}

[Form Data] [Successful] Request sample #2 - A Unique key has been passed

curl -X POST \
  https://randapis.com/data \
  -H 'Authorization: Bearer {{YOUR_API_KEY}}' \
  -H 'content-type: multipart/form-data' \
  -F key=key_non_json \
  -F value=non_json_data_to_store

Response:
HTTP Status: 201 Created
Body:

{
    "_metadata": {
        "result": "success"
    },
    "item": {
        "key": "key_non_json",
        "value": "non_json_data_to_store",
        "uuid": "0a53c6e7-7f77-4069-b7b0-e6c613b43682",
        "deleted_at": null,
        "created_at": "2023-06-04T23:19:50.453Z",
        "updated_at": "2023-06-04T23:19:50.453Z",
        "retrievals": 1,
        "retrieved_at": "2023-06-04T23:53:18.431Z"
    }
}

[JSON] [Successful] Request sample #3 - A Unique key has been passed without a value key

curl -X POST \
  https://randapis.com/data \
  -H 'Authorization: Bearer {{YOUR_API_KEY}}' \
  -H 'Content-Type: application/json' \
  -d '{
    "key": "no_value_key",
    "non_value_data_which_is_fine": {
        "k1": "v1"
    }
}'

Response:
HTTP Status: 201 Created
Body:

{
    "_metadata": {
        "result": "success"
    },
    "item": {
        "uuid": "acd44ccc-6b14-480f-ac6b-47bc138faa90",
        "key": "no_value_key",
        "value": {
            "non_value_data_which_is_fine": {
                "k1": "v1"
            }
        },
        "deleted_at": null,
        "created_at": "2023-05-27T17:00:17.215Z",
        "updated_at": "2023-05-27T17:00:17.215Z",
        "retrievals": 1,
        "retrieved_at": "2023-06-04T23:53:18.431Z"
    }
}

[JSON] [Invalid] Request sample #1 - No key has been passed

curl -X POST \
  https://randapis.com/data \
  -H 'Authorization: Bearer {{YOUR_API_KEY}}' \
  -H 'Content-Type: application/json' \
  -d '{
    "value": "any_data"
    }'

Response:
HTTP Status: 400 Bad Request
Body:

{
    "_metadata": {
        "result": "invalid_data",
        "debug_message": "Data posted was invalid."
    },
    "item": null
}

[JSON] [Invalid] Request sample #2 - No data has been passed

curl -X POST \
  https://randapis.com/data \
  -H 'Authorization: Bearer {{YOUR_API_KEY}}' \
  -H 'Content-Type: application/json' \
  -d '{}'

Response:
HTTP Status: 400 Bad Request
Body:

{
    "_metadata": {
        "result": "invalid_data",
        "debug_message": "Data posted was invalid."
    },
    "item": null
}

[JSON] [Invalid] request sample #3 - Duplicated key has been passed

curl -X POST \
  https://randapis.com/data \
  -H 'Authorization: Bearer {{YOUR_API_KEY}}' \
  -H 'Content-Type: application/json' \
  -d '{
    "key": "key_to_fetch_data_later",
    "value": "data to store"
}'

Response:
HTTP Status: 400 Bad Request
Body:

{
    "_metadata": {
        "result": "non_unique_key",
        "debug_message": "Non unique key was posted. Previously stored key/value has been returned."
    },
    "item": {
        "key": "key_to_fetch_data_later",
        "value": {
            "k1": "v1",
            "k2": "v2",
            "k3": "v3"
        },
        "uuid": "ccd44ccc-6b14-480f-ac6b-47bc138faf90",
        "deleted_at": null,
        "created_at": "2023-05-27T17:00:17.215Z",
        "updated_at": "2023-05-27T17:00:17.215Z",
        "retrievals": 1,
        "retrieved_at": "2023-06-04T23:53:18.431Z"
    }
}

[JSON] [Invalid] Request sample #4 - Authentication Token Is Missing or Invalid

curl -X POST \
  https://randapis.com/data \
  -H 'Authorization: Bearer incorrect_token' \
  -H 'Content-Type: application/json' \
  -d '{
    "key": "a_unique_key_without_proper_auth",
    "value": "data..."
}'

Response:
Body:

HTTP Status: 401 Unauthorized
HTTP **Response:**   HTTP Token: Access denied.

Fetch Data

[Successful] Request Sample #1 - Fetch an item by key

curl -X GET \
  'https://randapis.com/data?key=key_to_fetch_data_later' \
  -H 'Authorization: Bearer {{YOUR_API_KEY}}'

Response:
HTTP Status: 200 OK
Body:

{
    "_metadata": {
        "result": "success"
    },
    "item": {
        "key": "key_to_fetch_data_later",
        "value": {
            "k1": "v1",
            "k2": "v2",
            "k3": "v3"
        },
        "uuid": "ccd44ccc-6b14-480f-ac6b-47bc138faf90",
        "deleted_at": null,
        "created_at": "2023-05-27T17:00:17.215Z",
        "updated_at": "2023-05-27T17:00:17.215Z",
        "retrievals": 1,
        "retrieved_at": "2023-06-04T23:53:18.431Z"
    }
}

[Successful] Request Sample #2 - Fetch an item by ID

curl -X GET \
  'https://randapis.com/data?id=ccd44ccc-6b14-480f-ac6b-47bc138faf90' \
  -H 'Authorization: Bearer {{YOUR_API_KEY}}'

Response:
HTTP Status: 200 OK
Body:

{
    "_metadata": {
        "result": "success"
    },
    "item": {
        "key": "key_to_fetch_data_later",
        "value": {
            "k1": "v1",
            "k2": "v2",
            "k3": "v3"
        },
        "uuid": "ccd44ccc-6b14-480f-ac6b-47bc138faf90",
        "deleted_at": null,
        "created_at": "2023-05-27T17:00:17.215Z",
        "updated_at": "2023-05-27T17:00:17.215Z",
        "retrievals": 1,
        "retrieved_at": "2023-06-04T23:53:18.431Z"
    }
}

[Successful] Request Sample #3 - Fetch all items

curl -X GET \
  https://randapis.com/data \
  -H 'Authorization: Bearer {{YOUR_API_KEY}}'

Response:
HTTP Status: 200 OK
Body:

{
    "_metadata": {
        "result": "success"
    },
    "_items_metadata": {
        "item_count": 2,
        "first_item_created_at": "2023-05-27T17:00:17.215Z",
        "last_item_created_at": "2023-06-10T22:12:40.226Z"
    },
  "items": [
    {
      "item": {
        "key": "key_to_fetch_data_later",
        "value": {
          "k1": "v1",
          "k2": "v2",
          "k3": "v3"
        },
        "uuid": "ccd44ccc-6b14-480f-ac6b-47bc138faf90",
        "deleted_at": null,
        "created_at": "2023-05-27T17:00:17.215Z",
        "updated_at": "2023-05-27T17:00:17.215Z",
        "retrievals": 1,
        "retrieved_at": "2023-06-04T23:53:18.431Z"
      }
    },
    {
      "item": {
        "uuid": "6cf40f09-a3fa-4f17-a21d-6df21ebcfc55",
        "key": "k1",
        "value": {
          "k1": "v1",
          "k2": "v2",
          "k3": "v3"
        },
        "retrievals": 1,
        "retrieved_at": "2023-06-10T22:12:40.226Z",
        "deleted_at": null,
        "created_at": "2023-06-10T22:12:40.226Z",
        "updated_at": "2023-06-10T22:12:40.226Z"
      }
    }
  ]
}

[Unsuccessful] Request Fetch Sample #1 - Invalid key

curl -X GET \
  'https://randapis.com/data?key=invalid_key' \
  -H 'Authorization: Bearer {{YOUR_API_KEY}}'

Response:
HTTP Status: 404 Not Found
Body:

{
    "_metadata": {
        "result": "not_found"
    },
    "item": null
}

[Unsuccessful] Request Sample #2 - Invalid ID

curl -X GET \
  'https://randapis.com/data?id=4c77fa40-6e9b-49e9-' \
  -H 'Authorization: Bearer {{YOUR_API_KEY}}'

Response:
HTTP Status: 404 Not Found
Body:

{
    "_metadata": {
        "result": "not_found"
    },
    "item": null
}

Update Data

[JSON] [Successful] Request Sample #1 - Update an item by key

Data before update:
Body:

{
    "_metadata": {
        "result": "success"
    },
    "item": {
        "key": "key_to_fetch_data_later",
        "value": {
            "k1": "v1",
            "k2": "v2",
            "k3": "v3"
        },
        "uuid": "ccd44ccc-6b14-480f-ac6b-47bc138faf90",
        "deleted_at": null,
        "created_at": "2023-05-27T17:00:17.215Z",
        "updated_at": "2023-05-27T17:00:17.215Z",
        "retrievals": 1,
        "retrieved_at": "2023-06-04T23:53:18.431Z"
    }
}
curl -X PATCH \
  https://randapis.com/data \
  -H 'Authorization: Bearer {{YOUR_API_KEY}}' \
  -H 'Content-Type: application/json' \
  -d '{
    "key": "key_to_fetch_data_later",
    "value": "updated_text_value"
}'

[Form Data] [Successful] Request Sample #2 - Update an item by key

Data before update:
Body:

{
    "_metadata": {
        "result": "success"
    },
    "item": {
        "key": "key_to_fetch_data_later",
        "value": {
            "k1": "v1",
            "k2": "v2",
            "k3": "v3"
        },
        "uuid": "ccd44ccc-6b14-480f-ac6b-47bc138faf90",
        "deleted_at": null,
        "created_at": "2023-05-27T17:00:17.215Z",
        "updated_at": "2023-05-27T17:00:17.215Z",
        "retrievals": 1,
        "retrieved_at": "2023-06-04T23:53:18.431Z"
    }
}
curl -X PATCH \
  https://randapis.com/data \
  -H 'Authorization: Bearer {{YOUR_API_KEY}}' \
  -H 'content-type: multipart/form-data; boundary' \
  -F key=key_to_fetch_data_later \
  -F value=updated_value_thru_form_data

Response:
HTTP Status: 200 OK
Body:

{
    "_metadata": {
        "result": "success"
    },
    "item": {
        "value": "updated_value_thru_form_data",
        "key": "key_to_fetch_data_later",
        "uuid": "ccd44ccc-6b14-480f-ac6b-47bc138faf90",
        "deleted_at": null,
        "created_at": "2023-05-27T17:00:17.215Z",
        "updated_at": "2023-05-27T17:38:10.142Z",
        "retrievals": 1,
        "retrieved_at": "2023-06-04T23:53:18.431Z"
    }
}

[JSON] [Successful] Request Sample #3 - Update an item by ID

Data before update:
Body:

{
    "_metadata": {
        "result": "success"
    },
    "item": {
        "key": "key_to_fetch_data_later",
        "value": {
            "k1": "v1",
            "k2": "v2",
            "k3": "v3"
        },
        "uuid": "ccd44ccc-6b14-480f-ac6b-47bc138faf90",
        "deleted_at": null,
        "created_at": "2023-05-27T17:00:17.215Z",
        "updated_at": "2023-05-27T17:00:17.215Z",
        "retrievals": 1,
        "retrieved_at": "2023-06-04T23:53:18.431Z"
    }
}
curl -X PATCH \
  https://randapis.com/data \
  -H 'Authorization: Bearer {{YOUR_API_KEY}}' \
  -H 'Content-Type: application/json' \
  -d '{
    "id": "ccd44ccc-6b14-480f-ac6b-47bc138faf90",
    "value": "updated_via_id"
}'

Response:
HTTP Status: 200 OK
Body:

{
    "_metadata": {
        "result": "success"
    },
    "item": {
        "value": "updated_via_id",
        "key": "key_to_fetch_data_later",
        "uuid": "ccd44ccc-6b14-480f-ac6b-47bc138faf90",
        "deleted_at": null,
        "created_at": "2023-05-27T17:00:17.215Z",
        "updated_at": "2023-05-27T17:41:31.463Z",
        "retrievals": 1,
        "retrieved_at": "2023-06-04T23:53:18.431Z"
    }
}

[Form Data] [Successful] Request Sample #4 - Update an item by ID

Data before update:
Body:

{
    "_metadata": {
        "result": "success"
    },
    "item": {
        "key": "key_to_fetch_data_later",
        "value": {
            "k1": "v1",
            "k2": "v2",
            "k3": "v3"
        },
        "uuid": "ccd44ccc-6b14-480f-ac6b-47bc138faf90",
        "deleted_at": null,
        "created_at": "2023-05-27T17:00:17.215Z",
        "updated_at": "2023-05-27T17:00:17.215Z",
        "retrievals": 1,
        "retrieved_at": "2023-06-04T23:53:18.431Z"
    }
}
curl -X PATCH \
  https://randapis.com/data \
  -H 'Authorization: Bearer {{YOUR_API_KEY}}' \
  -H 'content-type: multipart/form-data;' \
  -F value=updated_value_thru_form_data_id_ii \
  -F id=0576a664-2749-41ed-9518-843b3f67fcfc

Response:
HTTP Status: 200 OK
Body:

{
    "_metadata": {
        "result": "success"
    },
    "item": {
        "value": "updated_via_id",
        "key": "key_to_fetch_data_later",
        "uuid": "ccd44ccc-6b14-480f-ac6b-47bc138faf90",
        "deleted_at": null,
        "created_at": "2023-05-27T17:00:17.215Z",
        "updated_at": "2023-05-27T17:41:31.463Z",
        "retrievals": 1,
        "retrieved_at": "2023-06-04T23:53:18.431Z"
    }
}

[Unsuccessful] Request Sample #1 - Invalid key

curl -X PATCH \
  https://randapis.com/data \
  -H 'Authorization: Bearer {{YOUR_API_KEY}}' \
  -H 'Content-Type: application/json' \
  -d '{
    "key": "invalid",
    "value": "updated_text_value"
}'

Response:
HTTP Status: 404 Not Found
Body:

{    "_metadata": {
        "result": "not_found"
    },
    "item": null
}

Unsuccessful Request Sample #2 - Invalid ID

curl -X PATCH \
  https://randapis.com/data \
  -H 'Authorization: Bearer {{YOUR_API_KEY}}' \
  -H 'Content-Type: application/json' \
  -d '{
    "id": "invalid_id",
    "value": "updated_text_value"
}'

Response:
HTTP Status: 404 Not Found
Body:

{    "_metadata": {
        "result": "not_found"
    },
    "item": null
}

Delete Data

[Successful] Request Sample #1 - Delete an item by key

curl -X DELETE \
  'http://localhost:3000/data?key=key_non_json2' \
  -H 'Authorization: Bearer da65a6b64be26342072fc1eb460f69e7' \
  -H 'Content-Type: application/json'

Response:
HTTP Status: 200 Success

Body:

{
    "_metadata": {
        "result": "success"
    },
    "item": {
        "uuid": "938dba21-f62f-4ec9-890f-ecbc88d376a8",
        "key": "key_non_json2",
        "value": "non_json_data_to_store2",
        "retrievals": 1,
        "retrieved_at": "2023-06-07T02:21:32.585Z",
        "deleted_at": "2023-10-17T10:59:56.712Z",
        "created_at": "2023-06-07T02:21:32.585Z",
        "updated_at": "2023-10-17T10:59:56.713Z"
    }
}