API Documentation
The Drunken Bytes API provides businesses with a user-friendly way of creating Product and Credential NFTs. Our REST API allows customers to make requests through a simple HTTP GET URL structure and receive responses in lightweight JSON format. With our platform, businesses can easily access the tools and resources they need to create and manage their own NFTs with ease.
The following API documentation can be applied for any major programming language and will present general integration guides and explanations around API endpoints, request parameters and response objects. If any questions remain unanswered for you, simply reach out to the drunken bytes support team for assistance.
Getting Started
API Access Key & Authentication
After creating an drunken bytes account, you will be able to retrieve your unique API access key using your account dashboard. Each drunken bytes account can have multiple API access key.
To connect to the API, simply attach the api_key parameter to any valid API endpoint URL and set it to your api key. Also add the api secret in the Authentication Header as Bearer <api_secret>.
Find a Nodejs example below.
// Set the URL for the API endpoint
const url = 'https://api-drunkenbytes.onrender.com/v1/nft/mint-nft';
// Set the options for the HTTP request
const options = {
method: 'POST', // Use the POST method
headers: { // Set the request headers
'Content-Type': 'application/json', // Set the request content type to JSON
'Authorization': 'Bearer <API SECRET>' // Set the authorization header
},
body: JSON.stringify({ // Set the request body
// Set the values for each of the request parameters
// Replace the placeholders with the actual values
receiverName: 'John Smith', // The name of the NFT recipient
receiverEmail: 'john.smith@example.com', // The email of the NFT recipient
receiverWalletAddress: '0x1234567890123456789012345678901234567890', // The wallet address of the NFT recipient
nftType: 'document', // The type of NFT (document, product, or other)
nftName: 'My NFT', // The name of the NFT
useCustomImage: true, // A boolean flag indicating if a custom image is being used (default is false)
imageBase64: 'base64-encoded-image-data', // The base64-encoded image data, if useCustomImage is true
isTransferable: true, // A boolean flag indicating if the NFT is transferable
isBurnable: false, // A boolean flag indicating if the NFT is burnable (default is false)
burnAfter: null, // The date after which the NFT can be burned, if isBurnable is true
traits: [
{ key: 'color', value: 'blue' }, // The key-value pairs describing the traits of the NFT
{ key: 'size', value: 'medium' },
{ key: 'shape', value: 'circle' }
]
})
};
// Send the HTTP request and handle the response
fetch(url, options)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
console.log(data); // Handle the response data
})
.catch(error => {
console.error('There was a problem with the fetch operation:', error);
});API Error
If your request to the drunken bytes API does not succeed, the API will return a JSON error response that contains error code and message objects indicating the type of error that occurred. The API also supports HTTP status codes, returning a code of 200 for successful requests, and an error status code (e.g. 404) for failed requests.
If a validation error occurs, hence, an API parameter is used in an invalid way, there will be an additional context object containing multiple sub-objects with the associated API parameter as the key and details about the given validation error(s) further sub-objects. Each instance of a validation error contains key and message objects.
Example Error:
{
success: false ,
error: {
message: "Internal Server Error"
}
}Common API Errors:
| Code | Type | Description |
|---|---|---|
403 | invalid_api_key | An invalid API access key was supplied. |
401 | missing_access_key | No API access key was supplied. |
401 | unauthorized_access | Authorization Header was not supplied. |
403 | wallet_balance_is_insufficient | Wallet Balance required to execute the code is not sufficient. |
404 | invalid_api_function | The given API endpoint does not exist. |
404 | 404_not_found | Resource not found. |
500 | internal_error | An internal error occurred. |
API Endpoints
Create NFT
The API is capable of creating customizable Product and Credential NFT's.
Example API Request:
// Set the URL for the API endpoint
const url = 'https://api-drunkenbytes.onrender.com/v1/nft/mint-nft';
// Set the options for the HTTP request
const options = {
method: 'POST', // Use the POST method
headers: { // Set the request headers
'Content-Type': 'application/json', // Set the request content type to JSON
'Authorization': 'Bearer <API SECRET>' // Set the authorization header
},
body: JSON.stringify({ // Set the request body
// Set the values for each of the request parameters
// Replace the placeholders with the actual values
receiverName: 'John Smith', // The name of the NFT recipient
receiverEmail: 'john.smith@example.com', // The email of the NFT recipient
receiverWalletAddress: '0x1234567890123456789012345678901234567890', // The wallet address of the NFT recipient
nftType: 'document', // The type of NFT (document, product, or other)
nftName: 'My NFT', // The name of the NFT
useCustomImage: true, // A boolean flag indicating if a custom image is being used (default is false)
imageBase64: 'base64-encoded-image-data', // The base64-encoded image data, if useCustomImage is true
isTransferable: true, // A boolean flag indicating if the NFT is transferable
isBurnable: false, // A boolean flag indicating if the NFT is burnable (default is false)
burnAfter: null, // The date after which the NFT can be burned, if isBurnable is true
traits: [
{ key: 'color', value: 'blue' }, // The key-value pairs describing the traits of the NFT
{ key: 'size', value: 'medium' },
{ key: 'shape', value: 'circle' }
]
})
};
// Send the HTTP request and handle the response
fetch(url, options)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
console.log(data); // Handle the response data
})
.catch(error => {
console.error('There was a problem with the fetch operation:', error);
});Example API Response:
{
success: true ,
data: {
txid: TRANSACTION_HASH
}
}Code Examples
A number of code examples in different programming languages were prepared for you to get up and running with the drunken bytes API as quickly as possible. You will find them below in PHP, Python, Node.js., jQuery, Go and Ruby.
PHP
require 'uri'
require 'net/http'
# Set the URL for the API endpoint
url = URI('https://api-drunkenbytes.onrender.com/v1/nft/mint-nft')
# Set the request headers
headers = {
'Content-Type' => 'application/json',
'Authorization' => 'Bearer <API SECRET>'
}
# Set the request body
body = {
# Set the values for each of the request parameters
# Replace the placeholders with the actual values
receiverName: 'John Smith',
receiverEmail: 'john.smith@example.com',
receiverWalletAddress: '0x1234567890123456789012345678901234567890',
nftType: 'document', # Only document, product, or other are allowed
nftName: 'My NFT',
useCustomImage: true, #default false, if not required can be omitted
imageBase64: 'base64-encoded-image-data', #Only required if useCustomImage is true
isTransferable: true,
isBurnable: false, #default false, if not required can be omitted
burnAfter: nil, #Only required if isBurnable is true
traits: [
{ key: 'color', value: 'blue' },
{ key: 'size', value: 'medium' },
{ key: 'shape', value: 'circle' }
]
}.to_json
# Set the options for the HTTP request
options = {
method: 'POST', # Use the POST method
headers: headers,
body: body
}
# Send the HTTP request and handle the response
response = Net::HTTP.start(url.host, url.port, use_ssl: true) do |http|
http.request(Net::HTTP::Post.new(url, options))
end
if response.code.to_i >= 200 && response.code.to_i < 300
puts response.body
else
puts "There was an error with the request. HTTP Status Code: #{response.code}"
endPython
import requests
import json
# Set the URL for the API endpoint
url = 'https://api-drunkenbytes.onrender.com/v1/nft/mint-nft'
# Set the values for each of the request parameters
# Replace the placeholders with the actual values
data = {
'receiverName': 'John Smith',
'receiverEmail': 'john.smith@example.com',
'receiverWalletAddress': '0x1234567890123456789012345678901234567890',
'nftType': 'document', # Only document, product, or other are allowed
'nftName': 'My NFT',
'useCustomImage': True, #default false, if not required can be omitted
'imageBase64': 'base64-encoded-image-data', #Only required if useCustomImage is true
'isTransferable': True,
'isBurnable': False, #default false, if not required can be omitted
'burnAfter': None, #Only required if isBurnable is true
'traits': [
{'key': 'color', 'value': 'blue'},
{'key': 'size', 'value': 'medium'},
{'key': 'shape', 'value': 'circle'}
]
}
# Set the request headers
headers = {'Content-Type': 'application/json'}
api_secret = 'your-api-secret'
headers['Authorization'] = f'Bearer {api_secret}'
# Send the HTTP request and handle the response
response = requests.post(url, headers=headers, data=json.dumps(data))
if response.ok:
response_data = response.json()
print(response_data) # Handle the response data
else:
print('Network response was not ok')Nodejs
// Set the URL for the API endpoint
const url = 'https://api-drunkenbytes.onrender.com/v1/nft/mint-nft';
// Set the options for the HTTP request
const options = {
method: 'POST', // Use the POST method
headers: { // Set the request headers
'Content-Type': 'application/json', // Set the request content type to JSON
'Authorization': 'Bearer <API SECRET>' // Set the authorization header
},
body: JSON.stringify({ // Set the request body
// Set the values for each of the request parameters
// Replace the placeholders with the actual values
receiverName: 'John Smith', // The name of the NFT recipient
receiverEmail: 'john.smith@example.com', // The email of the NFT recipient
receiverWalletAddress: '0x1234567890123456789012345678901234567890', // The wallet address of the NFT recipient
nftType: 'document', // The type of NFT (document, product, or other)
nftName: 'My NFT', // The name of the NFT
useCustomImage: true, // A boolean flag indicating if a custom image is being used (default is false)
imageBase64: 'base64-encoded-image-data', // The base64-encoded image data, if useCustomImage is true
isTransferable: true, // A boolean flag indicating if the NFT is transferable
isBurnable: false, // A boolean flag indicating if the NFT is burnable (default is false)
burnAfter: null, // The date after which the NFT can be burned, if isBurnable is true
traits: [
{ key: 'color', value: 'blue' }, // The key-value pairs describing the traits of the NFT
{ key: 'size', value: 'medium' },
{ key: 'shape', value: 'circle' }
]
})
};
// Send the HTTP request and handle the response
fetch(url, options)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
console.log(data); // Handle the response data
})
.catch(error => {
console.error('There was a problem with the fetch operation:', error);
});jQuery
// Set the URL for the API endpoint
const url = 'https://api-drunkenbytes.onrender.com/v1/nft/mint-nft';
// Set the values for each of the request parameters
// Replace the placeholders with the actual values
const data = {
receiverName: 'John Smith',
receiverEmail: 'john.smith@example.com',
receiverWalletAddress: '0x1234567890123456789012345678901234567890',
nftType: 'document',
nftName: 'My NFT',
useCustomImage: true, //default false, if not required can be omitted
imageBase64: 'base64-encoded-image-data', //Only required if useCustomImage is true
isTransferable: true,
isBurnable: false, //default false, if not required can be omitted
burnAfter: null, //Only required if isBurnable is true
traits: [
{ key: 'color', value: 'blue' },
{ key: 'size', value: 'medium' },
{ key: 'shape', value: 'circle' }
]
};
var headers = {'Content-Type': 'application/json'};
var apiSecret = 'your-api-secret';
headers['Authorization'] = 'Bearer ' + apiSecret;
// Send the HTTP request and handle the response
$.ajax({
url: url,
headers: headers,
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(data)
}).done(function(data) {
console.log(data); // Handle the response data
}).fail(function(jqXHR, textStatus, errorThrown) {
console.error('There was a problem with the fetch operation:', errorThrown);
});Go
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
// Set the URL for the API endpoint
url := "https://api-drunkenbytes.onrender.com/v1/nft/mint-nft"
// Define the request parameters
params := struct {
receiverName string `json:"receiverName"`
receiverEmail string `json:"receiverEmail"`
receiverWalletAddress string `json:"receiverWalletAddress"`
nftType string `json:"nftType"`
nftName string `json:"nftName"`
useCustomImage bool `json:"useCustomImage,omitempty"`
imageBase64 string `json:"imageBase64,omitempty"`
isTransferable bool `json:"isTransferable"`
isBurnable bool `json:"isBurnable,omitempty"`
burnAfter interface{} `json:"burnAfter,omitempty"`
traits []struct {
Key string `json:"key"`
Value string `json:"value"`
} `json:"traits"`
}{
receiverName: "John Smith",
receiverEmail: "john.smith@example.com",
receiverWalletAddress: "0x1234567890123456789012345678901234567890",
nftType: "document", // Only document, product, or other are allowed
nftName: "My NFT",
useCustomImage: true, // default false, if not required can be omitted
imageBase64: "base64-encoded-image-data", // Only required if UseCustomImage is true
isTransferable: true,
isBurnable: false, // default false, if not required can be omitted
burnAfter: nil, // Only required if IsBurnable is true
traits: []struct {
Key string `json:"key"`
Value string `json:"value"`
}{
{Key: "color", Value: "blue"},
{Key: "size", Value: "medium"},
{Key: "shape", Value: "circle"},
},
}
// Encode the request body as JSON
body, err := json.Marshal(params)
if err != nil {
panic(err)
}
// Create a new HTTP request with the specified URL and request body
req, err := http.NewRequest("POST", url, bytes.NewBuffer(body))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer <YOUR API SECRET>")
// Send the HTTP request and handle the response
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
fmt.Printf("Error: %v", resp.Status)
return
}
var result map[string]interface{}
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
fmt.Printf("Error: %v", err)
return
}
fmt.Println(result)
}
Ruby
require 'net/http'
require 'uri'
require 'json'
# Set the URL for the API endpoint
url = URI('https://api-drunkenbytes.onrender.com/v1/nft/mint-nft')
# Set the options for the HTTP request
options = {
method: 'POST', # Use the POST method
headers: { # Set the request headers
'Content-Type': 'application/json' # Set the request content type to JSON
'Authorization': 'Bearer <API SECRET>' # Set the authorization header
},
body: {
# Set the values for each of the request parameters
# Replace the placeholders with the actual values
receiverName: 'John Smith',
receiverEmail: 'john.smith@example.com',
receiverWalletAddress: '0x1234567890123456789012345678901234567890',
nftType: 'document', # Only document, product, or other are allowed
nftName: 'My NFT',
useCustomImage: true, #default false, if not required can be omitted
imageBase64: 'base64-encoded-image-data', #Only required if useCustomImage is true
isTransferable: true,
isBurnable: false, #default false, if not required can be omitted
burnAfter: nil, #Only required if isBurnable is true
traits: [
{ key: 'color', value: 'blue' },
{ key: 'size', value: 'medium' },
{ key: 'shape', value: 'circle' }
]
}.to_json
}
# Send the HTTP request and handle the response
response = Net::HTTP.start(url.hostname, url.port, use_ssl: true) do |http|
request = Net::HTTP::Post.new(url)
options.each { |key, value| request[key] = value }
http.request(request)
end
if response.is_a?(Net::HTTPSuccess)
data = JSON.parse(response.body)
puts data # Handle the response data
else
puts "Error: #{response.code} - #{response.message}"
end

