Introduction

updated: 1 week, 6 days ago
api

Welcome to doprax. In this section we will introduce doprax platform and discuss features and describe how doprax can help you create APIs faster and easier. If you need additional information that you can not find in this documentation please contact us at info@doprax.com and we will get back to you as soon as possible. So let’s start.

Doprax is a platform to create and deploy APIs. If you want to know more about APIs and how you can use them to power your websites and application check out this article: What is an API?

Doprax provides all tools needed to successfully develop and deploy API. For this you only need a web browser (like Chrome or Firefox) and you can create, manage and deploy your APIs easily using your browser across all your devices.

To get started you first need to create an account on doprax. Then, from your dashboard, you need to create a project. Create your first project by clicking “Start first project” in your dashboard and give your project a title and description (optional). Each project can have multiple API bits. An API bit is a single functioning API with a unique endpoint (address). When you create your first project, a “Hello World” API bit will be added to it automatically. Below is a screenshot of the simple hello world API bit.


The hello world API bit has two components. One component that outputs a hello and passes it to the next one which gets the hello and adds a world to it and sends it back to the client. Each API bit consists of one or more components. Each component is supposed to do a single task and do it well and reliably.




from blockdx.blocks import SimpleBlock
class hello(SimpleBlock):
   def __init__(self,inpt):
       super().__init__(inpt)
   def run(self,request):
       return "hello"


   

All components have a class with the same name as component (here hello) which inherits from “SimpleBlock”. SimpleBlock class is imported in the first line. The component is then initialized  with the inputs from the previous component (if any). Since “input” is a built-in function of python, we will use “inpt” as a semi-abbreviation. Throughout the component class the Inpt  which is the input of the component (output of the previous component) is accessible using self.inpt.

Each component has a “run” function and execution of the component starts from there. The run function accepts the original request object sent from the client sp every component can access the request object independently. When run function returns any value, it will be passed to the next component connected to it.

Next component from out hello world API bit is the “world” component which gets the hello from previous component and adds “world!” to it. Each component can have multiple inputs. The value of the inputs can be accessed like a regular list. Here, since there is only one previous component the value can be accessed with inpt[0]. The result is then outputted back to client by using self.result. Each component could independently output a value using self.result and a list of all result will be returned to the client after all components are executed.


from blockdx.blocks import SimpleBlock
class world(SimpleBlock):
   def __init__(self,inpt):
       super().__init__(inpt)
   def run(self,request):
       h = self.inpt[0]
       self.result = h + " world!"