Byvalue

Use Byvalue to Create Your Own API Business

Without Using Flask, Heroku, AWS, FastAPI, Zappa…

There are a lot of articles about deploying all kinds of services as an API. They rely on a plethora of different technologies and frameworks, and new tools come out regularly. It’s easy to get lost in the multitude of options, and even harder to find a one-stop-shop for API deployment and monetization.

At Byvalue, our mission is to empower developers by making code deployment and monetization easy. We believe that lowering the technical barriers for developers to monetize their code as APIs will enable them to turn their coding skills into sustainable businesses.

To further that goal, we built a platform that makes it easier than ever to create APIs, with no upfront cost for provisioning servers and compute and no need to become a backend wizard to keep your API running smoothly. With the accessibility of Serverless technologies, we’ve created a service that makes APIs cheaper and easier to maintain, and also enables them to autoscale when request volumes fluctuate.

“You can also share your API with friends and customers! Sharing is also possible later on in the market function page created for your API.”

Serverless functions — provided by different FaaS providers like AWS, Microsoft, and Google — make it much easier to create a microservice architecture for an API. However, there are limitations and technical hurdles that need to be overcome in order to build a full-fledged API in a Serverless way.

Critically, each function is exposed only on its own codebase with has only one entry point — the function handler. This means that an API that wants to expose multiple endpoints needs to consist of separate Serverless functions, even if they’re based on the same code. This makes managing the API quite cumbersome.

Since Byvalue’s goal is to make it easy for users to define and manage APIs as self-contained services, we had to find a way of turning a single-purpose, Serverless function into a function with multiple entry points that will serve as the endpoints in our users’ API.

In order to achieve this, we used……drum roll……a dictionary! The dictionary maps every entry point name to a function defined by our user, so when an API is triggered with “/<a function>” we know the right function to send the request.

Demo-time

Let’s see an example of how easy it is to build a simple calculator API with Byvalue!

Getting Started

First, go to www.byvalue.org and click “Create A Function”:

The default hello_user function will be pre-filled and the function name will appear in the “Entry points” field; that’s how you decide which function to expose in your API —and that your API subscribers can use.

Define Your Functions & Entrypoints

Change this function body to something more fitting for a calculator API:

def hello_user(name):
return f’Welcome {name} and thank you for using our calculator!’

Next, you’ll need to define the rest of the basic calculation functionalities — feel free to add or change any function you want.

Defining our multiplication API

The next step is to add the functions you want to expose to the “Entry points” field.

Use “Your Folder” to add any other files or directories that your API needs to function. These files will be available at the API code URI, although the main functionality is still defined in function.py.

Add Dependencies (if required)

There is also a requirements.txt file included by default. If you need extra pip packages, just add the package names to the requirements.txt and we’ll pip install them when you deploy.

Test & Upload

Now it’s time to test and upload your calculator. You’ll see that each defined entry point has become an API method, and you can create examples for each method and test that everything is working as expected.

Both the inputs and outputs are in JSON format. Let’s run those examples together!

Run an example for every method, and when you’re satisfied with the results continue to the description step.

Share & use

Here you can give a name and a description to your API, and define the per-usage royalty you want to charge. You can also share your API with friends and customers! Sharing is also possible later on in the market function page created for your API.

Let’s use the API live to do a conversion between Celsius and Fahrenheit.

Still here? Good!. We hope you’ll have as much fun creating your own APIs as we had making this one. With the example above serving as inspiration for what can be done on our platform, we’ll let you take it from here — share your own creative code and get rewarded By Value.

Thanks to Elie Bleier.