<<<<<<< HEAD

API Documentation

Integrate with the deepindex.link platform to manage your site's mirror URLs programmatically. Keep your listings up-to-date with our secure API.

📡

API Overview

The deepindex.link API allows market administrators to programmatically submit mirror URLs for their sites. This ensures that our listings remain current and accurate, providing users with reliable access points.

To use the API, you must first obtain an API token by contacting our administrator. The API uses Bearer token authentication and requires all requests to be sent as JSON.

=======

API Documentation V2.0

Integrate with the dnf.fail platform to manage your site's mirror URLs programmatically. Keep your listings up-to-date with our secure API.

📡

API Overview

The API allows you to perform full CRUD (Create, Read, Update, Delete) operations on your mirror URLs. This ensures that our listings remain current and accurate.

The API uses Bearer token authentication and requires all request bodies to be sent as JSON.

>>>>>>> 210d5dc624878638cfbef30cccceda29dd47c3de
<<<<<<< HEAD
🔑

Authentication

All API requests must include an authorization header with your unique API token:

HEADER
Authorization: Bearer YOUR_API_TOKEN
Include this header in all API requests for authentication.

Obtaining an API Token

To get your API token:

  1. Contact the deepindex.link admin via Jabber (OMEMO): deepindexdotlink[at]xmpp.is
  2. Provide your site details and official URL for verification
  3. Upon verification, you'll receive your unique API token
🔌

API Endpoint

POST
https://deepindex.link/api/push-mirror
Submit new mirror URLs for your site.

Request Body

The request body must be a JSON object with a mirrors field. You can submit mirror URLs in either of two formats:

Parameter Type Required Description
mirrors Array or String Yes Array of mirror URLs OR comma-separated string of mirror URLs

Example with JSON Array:

JSON
{
  "mirrors": [
    "http://mirror1.example.onion",
    "http://mirror2.example.onion"
  ]
}

Example with Comma-Separated String:

JSON
{
  "mirrors": "http://mirror1.example.onion, http://mirror2.example.onion"
}
📤

Response

Successful requests will receive a 200 OK response with a JSON object containing:

JSON
{
  "message": "Mirrors added successfully",
  "mirrors": [
    "http://existingmirror.onion",
    "http://mirror1.example.onion",
    "http://mirror2.example.onion"
  ]
}

⚠️ Important Notes

  • Keep your API token secure and never share it publicly
  • Unauthorized or invalid tokens will result in 401 Unauthorized errors
  • You can update your mirrors anytime by pushing new URLs via the API
  • Duplicate URLs will be ignored and not added to the list
  • All submitted URLs are validated before being added
📬

Contact & Support

For API token requests, questions, or support, contact the deepindex.link administrator:

📱
Jabber (OMEMO) deepindexdotlink[at]xmpp.is

Please include detailed information about your site and use case when requesting an API token.

=======
🔑

Authentication

All API requests must include an authorization header with your unique API token:

HEADER
Authorization: Bearer YOUR_API_TOKEN
Include this header in all API requests.
>>>>>>> 210d5dc624878638cfbef30cccceda29dd47c3de
🔌

API Endpoints

The base URL for all endpoints is: https://dnf.fail/api


List All Mirrors (READ)

Retrieve a list of all current mirrors associated with your API token.

GET
/mirrors
Fetches all of your site's current mirror URLs.

Successful Response (200 OK):

JSON
{
  "message": "Mirrors retrieved successfully",
  "mirrors": [
    {
      "id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
      "url": "http://mirror-one.onion",
      "captcha_required": false,
      "signature": "This is a signed message for mirror one."
    },
    {
      "id": "b2c3d4e5-f6a7-8901-2345-67890abcdef1",
      "url": "http://mirror-two-requires-captcha.onion",
      "captcha_required": true,
      "signature": ""
    }
  ]
}

Add New Mirrors (CREATE)

Add one or more new mirror URLs to your existing list. Duplicates will be ignored.

POST
/mirrors
Submits new mirror URLs to be added.

Request Body:

The request body must contain a `mirrors` key with an array of mirror objects. The `id` is generated by the server and should be omitted.

JSON
{
  "mirrors": [
    {
      "url": "http://newmirror1.onion",
      "captcha_required": false,
      "signature": "Optional signed message."
    },
    {
      "url": "http://newmirror2.onion",
      "captcha_required": true,
      "signature": ""
    }
  ]
}

Successful Response (201 Created):

JSON
{
  "message": "Mirrors added successfully",
  "mirrors": [
    // ... existing mirrors ...
    {
      "id": "c3d4e5f6-a7b8-9012-3456-7890abcdef12",
      "url": "http://newmirror1.onion",
      "captcha_required": false,
      "signature": "Optional signed message."
    },
    {
      "id": "d4e5f6a7-b8c9-0123-4567-890abcdef123",
      "url": "http://newmirror2.onion",
      "captcha_required": true,
      "signature": ""
    }
  ]
}

Replace All Mirrors (UPDATE)

Replace your entire list of mirrors with a new one.

PUT
/mirrors
Replaces the entire mirror list with the one provided.

Request Body:

Provide the complete new list of mirrors. An `id` will be generated for any mirror that does not have one.

JSON
{
  "mirrors": [
    {
      "url": "http://onlymirror.onion",
      "captcha_required": true,
      "signature": "This is the only mirror now."
    }
  ]
}

Successful Response (200 OK):

JSON
{
  "message": "Mirrors replaced successfully",
  "mirrors": [
    {
      "id": "e5f6a7b8-c9d0-1234-5678-90abcdef1234",
      "url": "http://onlymirror.onion",
      "captcha_required": true,
      "signature": "This is the only mirror now."
    }
  ]
}

Delete Specific Mirrors (DELETE)

Remove one or more specific mirrors from your list using their unique IDs.

DELETE
/mirrors
Removes the specified mirrors from your list by their ID.

Request Body:

Provide an array of mirror IDs you wish to delete.

JSON
{
  "ids": [
    "a1b2c3d4-e5f6-7890-1234-567890abcdef"
  ]
}

Successful Response (200 OK):

JSON
{
  "message": "Mirrors deleted successfully",
  "mirrors": [
    // ... remaining mirrors ...
  ]
}
💻

Command-Line Tool (Bash Script)

To make interacting with the API easier, we provide an advanced Bash script that handles all CRUD operations and the new data structure.


Installation & Requirements

You need to have curl and jq installed.

Installation Instructions:

SHELL
# On Debian/Ubuntu
sudo apt-get update && sudo apt-get install curl jq

# On macOS (using Homebrew)
brew install curl jq

Script Code

Save the following code into a file named mirror-manager.sh.

BASH
#!/bin/bash
# ==============================================================================
# mirror-manager.sh v2.0
#
# An advanced Bash script to manage mirror URLs via the dnf.fail API,
# supporting captcha flags and signed messages.
#
# Dependencies: curl, jq
# Author: DarknetDotFail
# Date: September 17, 2025
# ==============================================================================

# --- Configuration ---
API_BASE_URL="https://dnf.fail/api"

# --- Helper Functions ---
usage() {
    echo "A command-line client for the dnf.fail Mirror API."
    echo ""
    echo "Usage: $0   [options] [arguments...]"
    echo ""
    echo "Commands:"
    echo "  list                     List all current mirrors."
    echo "  add [mirror_data...]     Add one or more mirrors."
    echo "  replace [mirror_data...] Replace the entire mirror list."
    echo "  delete  [id2...]    Delete mirrors by their unique ID."
    echo ""
    echo "Mirror Data Format for 'add' and 'replace':"
    echo "  A sequence of mirrors, each potentially preceded by flags."
    echo "  [--captcha] [--sig \"message\"] "
    echo ""
    echo "Options for 'add' and 'replace':"
    echo "  --captcha                Set 'captcha_required' to true for the *next* URL."
    echo "  --sig \"your message\"     Set a signature for the *next* URL."
    echo ""
    echo "Examples:"
    echo "  # List mirrors"
    echo "  $0 list YOUR_API_TOKEN"
    echo ""
    echo "  # Add a simple mirror"
    echo "  $0 add YOUR_API_TOKEN http://new1.onion"
    echo ""
    echo "  # Add a mirror that requires a CAPTCHA"
    echo "  $0 add YOUR_API_TOKEN --captcha http://new2.onion"
    echo ""
    echo "  # Add a mirror with a signature"
    echo "  $0 add YOUR_API_TOKEN --sig \"This is a signed message\" http://new3.onion"
    echo ""
    echo "  # Add multiple mirrors with different properties"
    echo "  $0 add YOUR_API_TOKEN http://a.onion --captcha http://b.onion --sig \"sig\" --captcha http://c.onion"
    echo ""
    echo "  # Delete mirrors by ID"
    echo "  $0 delete YOUR_API_TOKEN a1b2c3d4-e5f6... b2c3d4e5-f6a7..."
}

check_dependencies() {
    if ! command -v curl &> /dev/null; then echo "Error: 'curl' is not installed." >&2; exit 1; fi
    if ! command -v jq &> /dev/null; then echo "Error: 'jq' is not installed." >&2; exit 1; fi
}

# --- API Functions ---
API_TOKEN=""
make_request() {
    local method="$1"
    local endpoint="$2"
    local data="$3"
    
    local args=(-s -X "$method" "${API_BASE_URL}${endpoint}")
    args+=(-H "Authorization: Bearer ${API_TOKEN}")
    args+=(-H "Accept: application/json")

    if [[ -n "$data" ]]; then
        args+=(-H "Content-Type: application/json")
        args+=(-d "$data")
    fi

    curl "${args[@]}" | jq
}

# --- Main Script Logic ---
check_dependencies

if [ "$#" -lt 2 ]; then
    usage
    exit 1
fi

COMMAND="$1"
API_TOKEN="$2"
shift 2

case "$COMMAND" in
    list)
        echo "Fetching mirror list..."
        make_request "GET" "/mirrors"
        ;;

    add | replace)
        if [ "$COMMAND" == "add" ]; then
            echo "Adding new mirrors..."
            HTTP_METHOD="POST"
        else
            echo "Replacing all mirrors..."
            HTTP_METHOD="PUT"
        fi

        captcha_flag=false
        signature=""
        json_objects=""

        while [ "$#" -gt 0 ]; do
            case "$1" in
                --captcha)
                    captcha_flag=true
                    shift
                    ;;
                --sig)
                    signature="$2"
                    shift 2
                    ;;
                *)
                    url="$1"
                    # Escape quotes in signature
                    escaped_sig=$(echo "$signature" | sed 's/"/\\"/g')
                    
                    json_object=$(cat <&2
            usage
            exit 1
        fi
        
        payload="{\"mirrors\": [${json_objects%,}]}"
        make_request "$HTTP_METHOD" "/mirrors" "$payload"
        ;;

    delete)
        echo "Deleting specified mirrors..."
        ids=("$@")
        if [ ${#ids[@]} -eq 0 ]; then
            echo "Error: The 'delete' command requires at least one mirror ID." >&2
            usage
            exit 1
        fi
        
        json_array=$(printf '"%s",' "${ids[@]}")
        payload="{\"ids\": [${json_array%,}]}"
        make_request "DELETE" "/mirrors" "$payload"
        ;;

    *)
        echo "Error: Unknown command '$COMMAND'" >&2
        usage
        exit 1
        ;;
esac
                

Usage

First, make the script executable:

SHELL
chmod +x mirror-manager.sh

Then, run the script with the desired command. Replace YOUR_API_TOKEN with your actual token.

List all mirrors:

SHELL
./mirror-manager.sh list YOUR_API_TOKEN

Add new mirrors (with flags):

Use flags to set properties: --captcha for CAPTCHA and --sig "message" for a signature.

SHELL
./mirror-manager.sh add YOUR_API_TOKEN \
  http://new1.onion \
  --captcha http://new2.onion \
  --sig "Signed message" http://new3.onion \
  --captcha --sig "Both flags" http://new4.onion

Replace all mirrors:

The `replace` command works just like `add`.

SHELL
./mirror-manager.sh replace YOUR_API_TOKEN --captcha http://main.onion

Delete mirrors by ID:

SHELL
./mirror-manager.sh delete YOUR_API_TOKEN ID_1 ID_2

⚠️ Important Notes

  • Keep your API token secure and never share it publicly.
  • Unauthorized or invalid tokens will result in a 401 Unauthorized error.
  • Invalid request bodies may result in a 400 Bad Request error.
  • All submitted URLs are validated. Invalid URLs will be ignored.