NAV

Introduction to echoValue API

echoValue is a lightweight and easy-to-use API designed for freelancers and developers working on small projects. It serves as a simple key-value database system, specifically tailored to store and retrieve random key-value data without the need for complex server platforms.

Note

echoValue is not intended to replace robust databases or caching systems in large and security-critical applications. It is specifically tailored to cater to the needs of small projects where simplicity, ease of use, and quick setup are the primary concerns.

Authentication

To authorize, use this code:

# With shell, you can just pass the correct header with each request
curl 'api_endpoint_here'
  -H 'x-token: mytoken'

Remember to replace mytoken with your actual token.

echoValue uses API tokens to allow access to the API.

The echoValue API offers a streamlined way for users to interact with its services. To authenticate your requests, include the following header in your API calls:

x-token: mytoken

Token Management

Generating a New Token

To obtain a new API token, execute this command:

curl 'https://token.echovalue.dev' \
-d 'token=new'

This will return a new token as a string.:

mytoken

This endpoint requests a new API Token.

HTTP Request

POST https://token.echovalue.dev

Parameter Value
token new

HTTP Response

200 - String with the new user’s token

Checking Wallet Balance

To view your remaining credits, use:

curl 'https://token.echovalue.dev' \
-H 'x-token: mytoken'

The response will be a JSON object detailing your credit balance and token creation date.

{"wallet":12345,"created":"2023-08-09T15:40:09.77Z"}

To view your remaining credits, use:

HTTP Request

GET https://token.echovalue.dev

HTTP Response

JSON with this values

Key Description
wallet Integer with the remaining credit
created Date when the token has been created

Recharging Wallet

To add credits to your wallet, use:

curl 'https://token.echovalue.dev' \
-H 'x-token: mytoken' \
-d 'token=recharge' \
-d 'amount=1'

This returns a Stripe payment link for the recharge process:

https://buy.stripe.com/<productID>?client_reference_id=mytoken

To add credits to your wallet, use:

HTTP Request

POST https://token.echovalue.dev

Parameter Value Description
token recharge constant
amount 1 Select the number of million operations you wish to recharge. Available options are 1 and 3, with the default set to 1.

HTTP Response

200 - String with the payment link

Follow the link to make a payment and recharge your wallet

Key/Value Operations

Setting a Key/Value Pair

To store a new key/value pair, use:

curl 'https://api.echovalue.dev/default/mykey' \
-H 'x-token: mytoken' \
-d 'newdata'

// with 30 seconds expiration
curl 'https://api.echovalue.dev/default/mykey?ttl=30' \
-H 'x-token: mytoken' \
-d 'newdata'

This endpoint sets the value of the key. The maximum length of a key is 30 characters. The maximum length of a group name is 30 characters. The maximum length of value is 30 characters.

Optionally, you can set a time-to-live (TTL) for the key.

HTTP Request

POST https://api.echovalue.dev/<group>/<key>?ttl=<seconds>

PATH Parameters

Parameter Description
group You can specify in which group of keys save the value. You can start using just default
key Key to set

HTTP Parameters

Parameter Description Optional
ttl You can specify in seconds the time to live for this key. If omitted key will expire in 30 days if not updated. Maximum value is 2592000 ( 30 days) Yes

Retrieving a Key/Value Pair

Retrieve the value of a key with:

curl 'https://api.echovalue.dev/default/mykey' \
-H 'x-token: mytoken'

This endpoint gets the value of the key.

HTTP Request

GET https://api.echovalue.dev/<group>/<key>

PATH Parameters

Parameter Description
group You can specify in which group of keys save the value. You can start using just default
key Key to retreve

Delete a Key/Value

To delete a key/value pair, use:

curl 'https://api.echovalue.dev/default/mykey' \
-H 'x-token: mytoken' \
-X DELETE

This endpoint delete the key and it’s value.

HTTP Request

DELETE https://api.echovalue.dev/<group>/<key>

PATH Parameters

Parameter Description
group You can specify in which group of keys save the value. You can start using just default
key Key to retreve

Logs Retrieval

To access logs, execute:

curl 'https://token.echovalue.dev/logs?n=5' \
-H 'x-token: mytoken'

The above command returns a JSON with :

{
    "logs": [
        {
            "id": "jd9kImh8U4In3odfNeKf",
            "method": "GET",
            "path": "/default/mykey",
            "error": "Key Not Found",
            "timestamp": "2023-12-07T12:14:16.124481Z",
            "expiration": "2023-12-14T12:14:16.12448Z",
            "cost": 1,
            "balance": 97
        },
        {
            "id": "6Ss3GtZPbVwqeyhGHSo1",
            "method": "POST",
            "path": "/default/test",
            "timestamp": "2023-12-07T12:04:11.453575Z",
            "expiration": "2023-12-14T12:04:11.453575Z",
            "cost": 1,
            "balance": 98
        },
        {
            "id": "T4rR1GHCteMwYOFRJLkx",
            "method": "GET",
            "path": "/default/test",
            "timestamp": "2023-12-07T12:01:58.63676Z",
            "expiration": "2023-12-14T12:01:58.63676Z",
            "cost": 1,
            "balance": 99
        }
    ],
    "n": 3
}

Retrieves a list of the latest API calls made using the user’s tokens. Logs have a TTL of 7 days and they are typically deleted within 24 hours after they expiration date.

HTTP Request

GET https://token.echovalue.dev/logs?n=5

HTTP Parameters

Parameter Description Optional
n Number of log entries to retrieve. Defaults to 5 if not specified. Yes

HTTP Response

JSON with this values

Key Description
n Number of entries returned
logs Array of Log entries
Key Description
id unique id of the log entry
method Method requested
path Path requested
error Optional, error message
timestamp Timestamp of Log Creation.
expiration Expiration Timestamp of the Log Entry
cost Cost deducted from the wallet
balance Wallet balance

Reponse Headers

Every response contains this Headers

Header Value
x-cost How many operations were deducted from the user Token wallet
x-balance How many operations are left in the user Token wallet

Errors Codes

The API uses standard HTTP error codes, including 400 (Bad Request), 401 (Unauthorized), 402 (Payment Required), and others, to indicate various types of errors.

The API uses the following error codes:

4xx

Error Code Meaning
400 Bad Request – Your request is malformed
401 Unauthorized – Your API token is wrong
402 Payment Required – Your wallet is empty
403 Forbidden – You don’t have the rights to call this endpoint
404 Not Found – The specified key could not be found
405 Method Not Allowed – You tried to access with an invalid method
406 Not Acceptable – You requested a format that isn’t json
418 I’m a teapot
429 Too Many Requests – You reached the rate limit

5xx

Error Code Meaning
500 Internal Server Error – We had a problem with our service. Try again later.
501 Not Implemented – Endpoint is not implemented
503 Service Unavailable – We’re temporarily offline. Please try again later.