nahcrofDB Documentation

Welcome to nahcrofDB, a simple key-value database solution

Supported languages

currently nahcrofDB supports 3 languages

Python

JavaScript (NodeJS)

Ruby

HTTP

while this is a small number, we do intend to create libraries for more programming languages in the future.

Python docs


To begin using nahcrofDB, if you are using python then you will need to run the following command:

pip install nahcrofDB requests

setting up your database in your project


to add and test your database, you will need to paste the following.

import nahcrofDB
nahcrofDB.init("YOUR_API_KEY_HERE")
nahcrofDB.makeKey("test", "test value")
print(nahcrofDB.getKey("test"))

if set up correctly, you should print "test value" to the console. If you need an api key, visit the /dashboard page and click "Create Token"

Resetting the database


after setting up your database and testing some things, you might not want to have the testing keys in your database anymore.
To reset the entire database, do the following.

in your already set up file, use this function

nahcrofDB.resetDB()

this will reset your entire database. Please note that you should NEVER use this under any circumstances in which you have any important information, this is only for when your database is in a testing phase or does not contain any useful information.

Extra functions

GetKeys


if you want to get multiple keys with one request for any reason, you can do that using the "getKeys" function, here is an example.

nahcrofDB.getKeys("key1", "key2", "key3")

This would return the values of key1, key2, and key3 in a dict. To get key2 out of this list would look something like this.

example = nahcrofDB.getKeys("key1", "key2", "key3")
print(example["key2"])

Deleting Keys


to delete a key from your database you will use the "delKey" function.

nahcrofDB.delKey("keyname")

JavaScript docs


To begin using nahcrofDB, using javascript you simply have to run the following command.

npm i nahcrofdb.js

after install nahcrofdb.js, make sure that type is set to module in the package.json file.

setting up your database in your project


to add and test your database to project, you will need to paste the following.

import NahcrofDB from "nahcrofdb.js";
const database = new NahcrofDB("USERNAME", "YOUR_API_KEY_HERE");
await database.create("test", "test value");
console.log(await database.get("test"));

if set up correctly, you should print "test value" to the console. If you need an api key, visit the /dashboard page and click "Create Token"

Resetting the database


after setting up your database and testing some things, you might not want to have the testing keys in your database anymore.
To reset the entire database, do the following.

in your already set up file, use this function

await database.reset();

this will reset your entire database. Please note that you should NEVER use this under any circumstances in which you have any important information, this is only for when your database is in a testing phase or does not contain any useful information.

Extra functions

GetKeys


if you want to get multiple keys with one request for any reason, you can do that using the "getKeys" function, here is an example.

await database.getKeys("key1", "key2", "key3")

This would return the values of key1, key2, and key3 in a dict. To get key2 out of this list would look something like this.

var example = await database.getKeys("key1", "key2", "key3")
console.log(example["key2"])

Deleting Keys
to delete a key from your database you will use the "delete" function.

await database.delete("keyname");

Ruby docs


To begin using nahcrofDB, if you are using ruby then ensure you have the nahcrofDB.rb module installed from the nahcrofDB GitHub page and add it to the same directory as your project

setting up your database in your project


to add and test your database, you can paste the following.

require "./nahcrofDB"
NahcrofDB.init("YOUR_API_KEY_HERE", "USERNAME")
NahcrofDB.makeKey("test", "test value")
puts NahcrofDB.getKey("test")

if set up correctly, you should print "test value" to the console. If you need an api key, visit the /dashboard page and click "Create Token"

Resetting the database


after setting up your database and testing some things, you might not want to have the testing keys in your database anymore.
To reset the entire database, do the following.

in your already set up file, use this function

NahcrofDB.resetDB()

this will reset your entire database. Please note that you should NEVER use this under any circumstances in which you have any important information, this is only for when your database is in a testing phase or does not contain any useful information.

Extra functions

GetKeys


if you want to get multiple keys with one request for any reason, you can do that using the "getKeys" function, here is an example.

NahcrofDB.getKeys("key1", "key2", "key3")

This would return the values of key1, key2, and key3 in a dict. To get key2 out of this list would look something like this.

example = NahcrofDB.getKeys("key1", "key2", "key3")
puts example["key2"]

Deleting Keys


to delete a key from your database you will use the "delKey" function.

NahcrofDB.delKey("keyname")

HTTP docs


getting a key-value

GET /v2/key/:key



HEADERS:
X-API-Key: api-token-here

RESPONSE 200 OK

{
  "value": "value here"
}

getting multiple key-values

GET /v2/keys


QUERY PARAMS
?key[]=key1&key[]=key2&key[]=key3


HEADERS:
X-API-Key: api-token-here

RESPONSE 200 OK
{
    "key1": "val1"
    "key2": "val2"
    "key3": "val3"
}

making key values

POST /v2/keys


BODY (application/json)
{
    "key": "val1"
    "key2": "val2"
    ...
}


RESPONSE 204 NO CONTENT
no data

deleting key values

DELETE /v2/keys


BODY (application/json)
[
    "key1",
    "key2",
    ...
]


RESPONSE 204 NO CONTENT
no data

searching your database

GET /v2/search


QUERY PARAMS
?query=Hello%20World


HEADERS:
X-API-Key: api-token-here

RESPONSE 200 OK
[
    "key1",
    "key2",
    ...
]

ERRORS


401 UNAUTHORIZED
{
    "error": true
    "status": 401
    "message": "Unauthorized"
}

404 NOT FOUND

{
    "error": true
    "status": 404
    "message": "Key (key here) does not exist."
}

500 INTERNAL SERVER ERROR

{
    "error": true
    "status": 500
    "message": "whatever internal error you have goes here"
}