BytesToBits

A Powerful, Free-to-use API!

INFORMATION


The BytesToBits API is a free, open-source API available to everyone.
In order to use the API, you need to use a key. To obtain one, create an account! API keys are unique, and they should not be shared with others.
API keys are also used to prevent API spams. That's why there is a 50 requests/minute limit set to all accounts. Surpassing this limit will result in getting rate-limited, which is a temporary block from using the API. The more frequent the rate-limit is triggered, the longer the timeouts will be, so be aware. Check out How to not get rate-limited to prevent it.

HOW TO USE


Let's get you started with the API!

  • First of all, Obtain Your API Key! Keep this hidden, as you are the registered owner of the token, and all requests will be done on your behalf!
  • Write Code! Yep, it was that easy. Once you get your API Key you can start using the API. Here are some examples:

Python Example

1import requests
2
3api_key = "YourApiKey"
4headers = {
5    "Authorization": api_key
6}
7url = "https://api.bytestobits.dev/text/"
8
9response = requests.get(url, headers)
10text = response.json()
11
12print(text)

JavaScript Example

1const apiKey = "YourApiKey"
2let url = "https://api.bytestobist.dev/text/"
3
4fetch(url, {
5    method: "POST",
6    headers: {
7        Authorization: apiKey
8    }
9}).then(response => response.json()).then(text => console.log(text))

For more information on how to use the API and the available endpoints, check the documentation page.

RATELIMITS


Like we mentioned before, you are allowed 50 requests per minute on the API. Surpassing that limit will result in an instant rate-limit.
The first rate-limit will last for a minute. However, we store the times a token has been rate-limited, and the timeout increases on each addition.
The formula for calculating the rate-limit timeout is as follows: 1+(0.1*RateLimitCount) minutes, pretty simple, right?
It might not look much time at first, but continuously surpassing the limit will result in a very long timeout. This is why we can tell you exactly how to prevent getting rate-limited in the first place!

Check the headers

That's it. The headers contain the following keys: X-RateLimit-Limit, X-Rate-Limit-Remaining, X-Rate-Limit-Reset
So, what does each of these do?

  • X-RateLimit-Limit returns the amount of requests the token is allowed to make. That is a constant value for default tokens, and it does not get affected by whether or not the token is rate-limited.
  • X-RateLimit-Remaining returns the amount of requests the token is allowed to make before getting rate-limited. If this hits 0, it means the next request will rate-limit the token.
  • X-Rate-Limit-Reset returns the remaining seconds before the rate-limit is removed! If the token is not rate-limited, the value will be 0.

Here is a very bad example on how to prevent rate-limits. You're better off making your own logic.

1import requests
2
3remaining = None
4
5def api_call(url, *args, **kwargs):
6    global remaining
7    # If "remaining" is None or over 0, it means we can make requests!
8    if not remaining or remaining > 0:
9        response = requests.get(url, *args, **kwargs)
10
11        # Save the header values in the variable
12        remaining = response.headers["X-RateLimit-Remaining"]
13
14        return response
15    
16    else:
17        print("You cannot make another request yet!")
18        return None
19
20res = api_call("https://api.bytestobits.dev/text", headers={"Authorization":"YourApiKey"})
21
22if res:
23    print(res.json())

CONTRIBUTING


Do you want to help us maintain the API?

Epic!

The API is open-source, which means everyone can view the code, edit it, and request to merge the changes to the main application! We really appreciate any effort towards improving the API, in any way, so do not hesitate to create a Pull Request!
Go to the Repository.
We also like to reward any contributors we believe have improved our code. That's why if you're dedicated and your requests are actually useful, you will gain access to a developers-only server made, where all BytesToBits developers, maintainers, and contributors are to test any code they want, or to collaborate on projects on the organization. Even if we do not end up inviting you, you will earn a role in the main server.