Skip to content

Syaamilmaulana256/nanoflex-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NanoFlex API

NanoFlex is a lightweight API built for simple, beginner-friendly data manipulation. It provides basic functionalities like character counting and calculations, making it suitable for learning, experimentation, and simple integration use cases. NanoFlex is not designed for production-level applications needing complex algorithms or high performance.

Caution

This API is under development, there may be many strange things, bugs and errors, report them by opening issues in this github repository

Becoming a Collaborator

We welcome any collaborators from users with feedback, testing suggestions, corrections and other potential improvements to NanoFlex, You can become a collaborator by opening an issue with the tag collaborator. see this for example

Quick Overview

NanoFlex offers two primary endpoints for simple operations:

  • /api/calc: Performs mathematical calculations (add, reduce, multiply, divide) on a running total. The API supports both GET and POST methods. A current value is persisted in a session (cookie) for cumulative results and reset after 24 hours. An error occurs if division is performed by 0.

  • /api/charCount: Counts characters within a provided string, categorizing them into alphabets (a-z, A-Z), numbers (0-9), symbols, spaces, and others (characters not covered by the other categories). The API supports both GET and POST.

Rate Limit

  • Before you use our API, you should see what our API Rate Limit is to prevent high resource usage and this is important.
  • The minutes referred to in the table are to reset the request to default, This happens if you use it many times, or spam occurs. If spam occurs for 5 minutes and the request exceeds, then it will Rate Limit
Rate Limit Minutes
96 requests per IP 5 mins

Endpoint Details

/api/calc

This endpoint supports both GET and POST requests. The operations supported are "add", "reduce", "multiply":and "divide." The current number to operate on is stored in a session (cookie) and defaults to 0 if not initialized. An error occurs if division is performed by 0.

Endpoint

/api/calc?<operation>=<value>

<operation> is the mathematical operation (add, reduce, multiply and divide), while <value> is the number to be calculated.

GET Request (Example):

/api/calc?add=10

POST Request (Example):

POST /api/calc
{
  "operation": "add",
  "value": 10
}

Example Result (200 OK):

[
  {
    "ok": true,
    "code": "200",
    "message": "Numbers Increased",
    "data": {
      "number": 10
    }
  }
]

Error Responses (Example):

  • 400 Bad Request (missing or invalid value): /api/calc?add=invalid
  • 400 Bad Request (missing or invalid operation): /api/calc?invalid=10
  • 500 Internal Server Error: Basically there is an error in the server
  • 429 Too Many Requests:

/api/charCount

Endpoint

/api/charCount?text=<string>

Fill <string> with text

GET Request (Example):

/api/charCount?text=Hello world!, 123

POST Request (Example):

POST /api/charCount
{
  "text": "Hello world!, 123"
}

The request can have either the text parameter (GET) or a body with the text.

Example Result (200 OK):

[
  {
    "ok": true,
    "code": "200",
    "message": "Character count successful",
    "data": {
      "symbols": 1,
      "alphabet": 10,
      "numbers": 3,
      "spaces": 2,
      "others": 0,
      "total": 16
    }
  }
]

Note

Chances are, Error 400 and 404 are almost impossible to occur because it is just a character count, if you encounter it, open an issue as a bug tag.

Error Handling & Feedback

To report issues, suggest or enhancements, please create an issue on the project repository, specifying the error/suggestion using appropriate tags such as suggestion, bug, and enhancement.