1mbsite API Documentation
API URL: https://api.1mb.site
Deploy To Your Site
In order to deploy to your site you'll need to send a POST request to the API URL mentioned in the beginning of these docs. This API expects 5 parameters:
Parameters
Parameter | About |
---|---|
action | deploy |
site | Your 1mbsite username |
key | Login at https://account.1mb.site to view |
resource | Can only contain alphanumeric characters and can't exceed 50 characters in length. |
code | The code you want to deploy to the page. If any code exists on this page already it'll be replaced. |
API Output
You will receive a JSON response. Here's an example request where there's no error:
{
"error": false,
"data": false
}
error
will be false
if you deploy to your site successfully (otherwise it'll be a string)
Here is an example:
{
"error": "SITE_MISSING",
"data": false
}
Possible Errors
Error | Explanation |
---|---|
SITE_MISSING | site parameter missing |
ACCOUNT_BANNED | self explanatory |
ACCOUNT_NONEXISTENT | The account doesn't exist |
KEY_MISSING | key parameter missing |
KEY_INCORRECT | The key supplied doesn't match the key associated with the account |
EMAIL_VERIFICATION | You need to verify your email to deploy to your site |
KEY_INCLUDED | The deployment was blocked because your code contained your site key |
RESOURCE_MISSING | resource parameter missing |
RESOURCE_INVALID | resource name can only contain alphanumeric characters |
EXTENSION_INVALID | resource name can only end in .html, .css, .js, or .json |
RESOURCE_LONG | resource name can't exceed 50 characters in length |
CODE_MISSING | code parameter missing |
STORAGE_QUOTA | You don't have enough storage for this deployment |
Verify Your Site Key
In order to verify your site key you'll need to send a POST request to the API URL mentioned in the beginning of these docs. This API expects 3 parameters:
Parameters
Parameter | About |
---|---|
action | keyverify |
username | Your 1mbsite username |
key | Login at https://account.1mb.site to view |
API Output
You will receive a JSON response. Here's an example request where there's no error:
{
"error": false,
"data": false
}
error
will be false
if your key was verified successfully (otherwise it'll be a string)
Here is an example:
{
"error": "USERNAME_MISSING",
"data": false
}
Possible Errors
Error | Explanation |
---|---|
USERNAME_MISSING | username parameter missing |
KEY_MISSING | key parameter missing |
KEY_INCORRECT | The key supplied doesn't match the key associated with the account |
View a Site
In order to view a site you'll need to send a POST request to the API URL mentioned in the beginning of these docs. This API expects 3 parameters:
Parameters
Parameter | About |
---|---|
action | view |
site | Site you want to view |
resource | Resource you want to view |
API Output
You will receive a JSON response.
if error
is false
then data
will contain the current site/page code.
Here is an example:
{
"error": false,
"data": "<h1>Hello, World!</h1>"
}
error
will be false
if your key was verified successfully (otherwise it'll be a string)
Here is an example:
{
"error": "SITE_MISSING",
"data": false
}
Possible Errors
Error | Explanation |
---|---|
SITE_MISSING | site parameter missing |
SITE_NONEXISTENT | site doesn't exist |
RESOURCE_MISSING | resource parameter missing |
RESOURCE_NONEXISTENT | resource doesn't exist |
Insert into Database / Create a Database
In order to insert into a database you'll need to send a POST request to the API URL mentioned in the beginning of these docs. This API expects 6 parameters:
Parameters
Parameter | About |
---|---|
action | db-insert |
username | your username |
api_key | your api key |
database | name of database, will create new database if it doesn't exist |
key | database key you want to store your data in, if key already exists it'll be overwritten |
set | JSON data you want to add to database |
API Output
You will receive a JSON response.
if error
is false
then data
will contain the inserted data
Here is an example:
{
"error": false,
"data": {
"hello-world": {
"key": true,
"anotherKey": "some text"
}
}
}
error
will be false
if request was completed successfully (otherwise it'll be a string)
Here is an example:
{
"error": "USERNAME_MISSING",
"data": false
}
Possible Errors
Error | Explanation |
---|---|
USERNAME_MISSING | username parameter missing |
ACCOUNT_NONEXISTENT | account doesn't exist |
API_KEY_MISSING | api_key parameter missing |
API_KEY_INCORRECT | The API key you entered is incorrect. |
LONG_KEY | key name can't exceed 100 characters |
LONG_NAME | datavase name can't exceed 20 characters |
INVALID_NAME | database name can only contain alphanumeric characters |
RESOURCE_QUOTA | you aren't allowed to create anymore resources |
STORAGE_QUOTA | you don't have enough storage to perform this request |
Delete Database or Database Key
In order to perform this request you'll need to send a POST request to the API URL mentioned in the beginning of these docs. This API expects 4 parameters:
Parameters
Parameter | About |
---|---|
action | db-delete |
username | your username |
api_key | your api key |
database | name of database, will create new database if it doesn't exist |
key | database key you want to store your data in, if key already exists it'll be overwritten |
API Output
You will receive a JSON response.
error
will be false
if request was completed successfully (otherwise it'll be a string)
Here is an example:
{
"error": "USERNAME_MISSING",
"data": false
}
Possible Errors
Error | Explanation |
---|---|
USERNAME_MISSING | username parameter missing |
ACCOUNT_NONEXISTENT | account doesn't exist |
API_KEY_MISSING | api_key parameter missing |
API_KEY_INCORRECT | The API key you entered is incorrect. |
DATABASE_NONEXISTENT | database doesn't exist |
View Database
In order to view database you'll need to send a POST request to the API URL mentioned in the beginning of these docs. This API expects 5 parameters, but authentication may not be required for some databases:
Create a config file for database: If you create a resource named databaseName.db.json, for example if you have a database named helloworld create a file called helloworld.db.json insert this data to make database viewable without API key
{
"permissions": {
"read": true
}
}
Parameters
Parameter | About |
---|---|
action | db-view |
username | your username |
api_key | your api key |
database | name of database |
key | database key you want to view, you can also do * to view all keys and ** to view all data |
API Output
You will receive a JSON response.
if error
is false
then data
will contain the data you want to view or be false if no data available
Here is an example:
{
"error": false,
"data": {
"hello-world": {
"key": true,
"anotherKey": "some text"
}
}
}
error
will be false
if request was completed successfully (otherwise it'll be a string)
Here is an example:
{
"error": "USERNAME_MISSING",
"data": false
}
Possible Errors
Error | Explanation |
---|---|
USERNAME_MISSING | username parameter missing |
ACCOUNT_NONEXISTENT | account doesn't exist |
API_KEY_MISSING | api_key parameter missing |
API_KEY_INCORRECT | The API key you entered is incorrect. |
DATABASE_NONEXISTENT | This database doesn't exist |