Git Product home page Git Product logo

bad-ip-api's Introduction

BAD IP API

Detect bad IPS on your network and applications with this JSON REST API built with TypeScript and Hono, designed to run on Cloudflare Workers.

Overview

The primary purpose of this API is to detect bad IP addresses. It checks whether an IP address is associated with proxies, spammers, or abusers by querying various DNS-based blacklists (DNSBLs).

It Offers two search strategies: quick and full.

  • Quick: Resolves as soon as it finds the IP address in any blacklist.
  • Full: Searches in all configured blacklists before returning a result.

Demo: https://api.badip.info/103.183.106.19?strategy=full

Running locally

  1. Install dependencies:

    npm install
  2. Run in development:

    npm run dev

Usage

Making API Requests

You can make a GET request to the API by passing the IP address as a parameter. Here's an example using curl:

curl http://localhost:8787/123.11.22.33&strategy=full
  • Replace http://localhost:8787 with the actual URL of your API.
  • Specify the IP address you want to check.
  • Use the strategy parameter to choose between "quick" or "full" search strategies.

Response

The API will respond with a JSON object containing information about the the IP address:

{
  "success": true,
  "isBad": true,
  "blacklists": ["dnsbl.example.info"]
}
  • success: A boolean indicating whether the request was successful.
  • isBad: A boolean indicating whether the IP address is classified as "bad" or not.
  • blacklists: List of DNSBLs where the ip is listed. Returns only 1 when using the quick strategy.

Configuration

You can customize the DNSBLs to query by editing the config.ts file.

Note that Cloudflare Workers currently only supports 6 simultaneous requests, so the more DNSBLs you add, the longer it will take to search with the "full" strategy.

Deployment

  1. Deploy the API to Cloudflare Workers. Ensure you have the Cloudflare Workers configured with your Cloudflare account.

    npx wrangler publish
  2. This may require authentication to your Cloudflare account. Once the API is deployed, you will receive a unique URL endpoint where the API is accessible.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

If you'd like to contribute to this project or report issues, please open an issue or submit a pull request on the GitHub repository.

Acknowledgments

Special thanks to the DNSBLs maintainers for their contributions to a better internet.

bad-ip-api's People

Contributors

anarkrypto avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.