C++ edjLibrary SDK
No Matches
EDJX Library SDK for C++

This SDK is used to develop EDJX serverless functions. Currently, functions are triggered using HTTP only.

Additionally, developers can use the streaming feature while building serverless functions. Streaming optimizes data transfer (upload file/download file) to the EDJX object storage. Using the streaming feature, developers can work with large data sets without allocating huge memory to the functions. Since functions process data as smaller chunks, the use of streaming in functions drastically reduces the response time.

EDJX HTTP Trigger Functions

These functions are triggered from standard HTTP methods. The input for the function is an HTTP request object (represented by edjx::request::HttpRequest in the EDJX SDK) and the return value must be an HTTP response object (represented by edjx::response::HttpResponse in the EDJX SDK).

EDJX sample code for C++ Serverless Application contains two C++ files:

  • lib.cpp
  • serverless_function.cpp


This file contains helper code to fetch HTTP requests and pass the request as input to the serverless function. Additionally, this file has code related to HTTP response processing. Modify this file only when the HTTP response type needs to be changed. See edjx::request::HttpRequest and edjx::response::HttpResponse for more details.

static const HttpStatusCode HTTP_STATUS_BAD_REQUEST = 400;
extern HttpResponse serverless(const HttpRequest & req);
int main(void) {
HttpRequest req;
HttpError err = HttpRequest::from_client(req);
if (err != HttpError::Success) {
HttpResponse res = serverless(req);
err = res.send();
if (err != HttpError::Success) {
std::string to_string(HttpError e)
Returns a string representation of HttpError.
Definition: error.hpp:56


This file contains the code to create a serverless function.

static const HttpStatusCode HTTP_STATUS_OK = 200;
HttpResponse serverless(const HttpRequest & req) {
info("Inside example function");
return HttpResponse("Welcome to EDJX")
.set_header("Server", "EDJX");

Two other important types in the API are edjx::fetch::HttpFetch and edjx::fetch::FetchResponse. HttpFetch is used to execute HTTP requests. FetchResponse is returned as a response for the Fetch HTTP request.

HTTP Body Size Limits

Currently, all HTTP APIs have a size limit of 512 MB for the HTTP body.

Interacting with the EDJX Object Store and KV Store

The most important APIs in the EDJX Library SDK are the APIs that are used to interact with the Object Storage (represented by the edjx::storage namespace in the EDJX SDK) and the KV Store (represented by the edjx::kv namespace in the EDJX SDK).

The Object Store is a decentralized datastore backed by the EDJX P2P network. This SDK uses GET and PUT methods for file contents and associated attributes.

The KV Store is a decentralized Key-Value datastore backed by the EDJX P2P network. There are specific limits on the size of Key and Value. Key size is limited to 512 bytes and Value is limited to 512 KB.


This API provides functions to log std::string messages.